当前位置: 首页>>代码示例>>PHP>>正文


PHP TGM_Plugin_Activation::can_plugin_update方法代码示例

本文整理汇总了PHP中TGM_Plugin_Activation::can_plugin_update方法的典型用法代码示例。如果您正苦于以下问题:PHP TGM_Plugin_Activation::can_plugin_update方法的具体用法?PHP TGM_Plugin_Activation::can_plugin_update怎么用?PHP TGM_Plugin_Activation::can_plugin_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TGM_Plugin_Activation的用法示例。


在下文中一共展示了TGM_Plugin_Activation::can_plugin_update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_bulk_actions

 /**
  * Processes bulk installation and activation actions.
  *
  * The bulk installation process looks for the $_POST information and passes that
  * through if a user has to use WP_Filesystem to enter their credentials.
  *
  * @since 2.2.0
  */
 public function process_bulk_actions()
 {
     // Bulk installation process.
     if ('tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action()) {
         check_admin_referer('bulk-' . $this->_args['plural']);
         $install_type = 'install';
         if ('tgmpa-bulk-update' === $this->current_action()) {
             $install_type = 'update';
         }
         $plugins_to_install = array();
         // Did user actually select any plugins to install/update ?
         if (empty($_POST['plugin'])) {
             if ('install' === $install_type) {
                 $message = __('No plugins were selected to be installed. No action taken.', 'sociallyviral');
             } else {
                 $message = __('No plugins were selected to be updated. No action taken.', 'sociallyviral');
             }
             echo '<div id="message" class="error"><p>', esc_html($message), '</p></div>';
             return false;
         }
         if (is_array($_POST['plugin'])) {
             $plugins_to_install = (array) $_POST['plugin'];
         } elseif (is_string($_POST['plugin'])) {
             // Received via Filesystem page - un-flatten array (WP bug #19643).
             $plugins_to_install = explode(',', $_POST['plugin']);
         }
         // Sanitize the received input.
         $plugins_to_install = array_map('urldecode', $plugins_to_install);
         $plugins_to_install = array_map(array($this->tgmpa, 'sanitize_key'), $plugins_to_install);
         // Validate the received input.
         foreach ($plugins_to_install as $key => $slug) {
             // Check if the plugin was registered with TGMPA and remove if not.
             if (!isset($this->tgmpa->plugins[$slug])) {
                 unset($plugins_to_install[$key]);
                 continue;
             }
             // For updates: make sure this is a plugin we *can* update (update available and WP version ok).
             if ('update' === $install_type && ($this->tgmpa->is_plugin_installed($slug) && (false === $this->tgmpa->does_plugin_have_update($slug) || !$this->tgmpa->can_plugin_update($slug)))) {
                 unset($plugins_to_install[$key]);
             }
         }
         // No need to proceed further if we have no plugins to handle.
         if (empty($plugins_to_install)) {
             if ('install' === $install_type) {
                 $message = __('No plugins are available to be installed at this time.', 'sociallyviral');
             } else {
                 $message = __('No plugins are available to be updated at this time.', 'sociallyviral');
             }
             echo '<div id="message" class="error"><p>', esc_html($message), '</p></div>';
             return false;
         }
         // Pass all necessary information if WP_Filesystem is needed.
         $url = wp_nonce_url($this->tgmpa->get_tgmpa_url(), 'bulk-' . $this->_args['plural']);
         // Give validated data back to $_POST which is the only place the filesystem looks for extra fields.
         $_POST['plugin'] = implode(',', $plugins_to_install);
         // Work around for WP bug #19643.
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary.
         $fields = array_keys($_POST);
         // Extra fields to pass to WP_Filesystem.
         if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, $fields))) {
             return true;
             // Stop the normal page form from displaying, credential request form will be shown.
         }
         // Now we have some credentials, setup WP_Filesystem.
         if (!WP_Filesystem($creds)) {
             // Our credentials were no good, ask the user for them again.
             request_filesystem_credentials(esc_url_raw($url), $method, true, false, $fields);
             return true;
         }
         /* If we arrive here, we have the filesystem */
         // Store all information in arrays since we are processing a bulk installation.
         $names = array();
         $sources = array();
         // Needed for installs.
         $file_paths = array();
         // Needed for upgrades.
         $to_inject = array();
         // Information to inject into the update_plugins transient.
         // Prepare the data for validated plugins for the install/upgrade.
         foreach ($plugins_to_install as $slug) {
             $name = $this->tgmpa->plugins[$slug]['name'];
             $source = $this->tgmpa->get_download_url($slug);
             if (!empty($name) && !empty($source)) {
                 $names[] = $name;
                 switch ($install_type) {
                     case 'install':
                         $sources[] = $source;
                         break;
                     case 'update':
                         $file_paths[] = $this->tgmpa->plugins[$slug]['file_path'];
                         $to_inject[$slug] = $this->tgmpa->plugins[$slug];
//.........这里部分代码省略.........
开发者ID:bigpopakap,项目名称:clickworthy,代码行数:101,代码来源:plugin-activation.php


注:本文中的TGM_Plugin_Activation::can_plugin_update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。