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


PHP Plugin_Upgrader::upgrade方法代码示例

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


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

示例1: _wprp_upgrade_plugin

/**
 * Update a plugin
 *
 * @access private
 * @param mixed $plugin
 * @return array
 */
function _wprp_upgrade_plugin($plugin)
{
    include_once ABSPATH . 'wp-admin/includes/admin.php';
    if (!_wprp_supports_plugin_upgrade()) {
        return array('status' => 'error', 'error' => 'WordPress version too old for plugin upgrades');
    }
    $skin = new WPRP_Plugin_Upgrader_Skin();
    $upgrader = new Plugin_Upgrader($skin);
    $is_active = is_plugin_active($plugin);
    // Do the upgrade
    ob_start();
    $result = $upgrader->upgrade($plugin);
    $data = ob_get_contents();
    ob_clean();
    if (!$result && !is_null($result) || $data) {
        return array('status' => 'error', 'error' => 'file_permissions_error');
    } elseif (is_wp_error($result)) {
        return array('status' => 'error', 'error' => $result->get_error_code());
    }
    if ($skin->error) {
        return array('status' => 'error', 'error' => $skin->error);
    }
    // If the plugin was activited, we have to re-activate it
    // @todo Shouldn't this use activate_plugin?
    if ($is_active) {
        $current = get_option('active_plugins', array());
        $current[] = plugin_basename(trim($plugin));
        sort($current);
        update_option('active_plugins', $current);
    }
    return array('status' => 'success');
}
开发者ID:redferriswheel,项目名称:ZachFonville,代码行数:39,代码来源:wprp.plugins.php

示例2: update_plugin

 /**
  * Update plugin.
  *
  * @param  string $plugin_slug
  * @param string  $tag
  *
  * @throws \Exception
  */
 public function update_plugin($plugin_slug, $tag = 'master')
 {
     $plugin = null;
     $is_plugin_active = false;
     foreach ((array) Plugin::instance()->get_plugin_configs() as $config_entry) {
         if ($config_entry->repo === $plugin_slug) {
             $plugin = $config_entry;
             break;
         }
     }
     if (!$plugin) {
         throw new \Exception(esc_html__('Plugin not found or not updatable with GitHub Updater: ', 'github-updater') . $plugin_slug);
     }
     if (is_plugin_active($plugin->slug)) {
         $is_plugin_active = true;
     }
     $this->get_remote_repo_meta($plugin);
     $updates_transient = get_site_transient('update_plugins');
     $update = array('slug' => $plugin->repo, 'plugin' => $plugin->slug, 'new_version' => null, 'url' => $plugin->uri, 'package' => $this->repo_api->construct_download_link(false, $tag));
     $updates_transient->response[$plugin->slug] = (object) $update;
     set_site_transient('update_plugins', $updates_transient);
     $upgrader = new \Plugin_Upgrader($this->upgrader_skin);
     $upgrader->upgrade($plugin->slug);
     if ($is_plugin_active) {
         $activate = is_multisite() ? activate_plugin($plugin->slug, null, true) : activate_plugin($plugin->slug);
         if (!$activate) {
             $this->upgrader_skin->messages[] = esc_html__('Plugin reactivated successfully.', 'github-updater');
         }
     }
 }
开发者ID:limikael,项目名称:github-updater,代码行数:38,代码来源:Rest_Update.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $env = Validators::validateEnv($input->getOption('env'));
     $root = $this->skeleton->getWebRoot();
     $plugins = $this->skeleton->get(sprintf('wordpress.%s.plugins', $env));
     require $root . '/wp-load.php';
     require ABSPATH . 'wp-admin/includes/admin.php';
     require ABSPATH . 'wp-admin/includes/plugin-install.php';
     foreach ($plugins as $slug => $version) {
         $plugin = plugins_api('plugin_information', array('slug' => $slug));
         if (is_wp_error($plugin)) {
             throw new \Exception('Could not get plugin information for ' . $slug);
         }
         if ($version) {
             list($prefix) = explode($slug, $plugin->download_link);
             $link = sprintf('%s%s.%s.zip', $prefix, $slug, $version);
             $response = wp_remote_head($link);
             if (!isset($response['response']['code']) || $response['response']['code'] != 200) {
                 throw new \Exception('Unable to verify ' . $link);
             }
             $plugin->download_link = $link;
             $plugin->version = $version;
         }
         require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         $status = install_plugin_install_status($plugin);
         $upgrader = new \Plugin_Upgrader(new UpgraderSkin($output));
         $current = current(get_plugins("/{$slug}"));
         switch ($status['status']) {
             case 'install':
                 $output->write(sprintf('Installing <info>%s</info> v<comment>%s</comment>', $plugin->name, $plugin->version));
                 $upgrader->install($plugin->download_link);
                 break;
             case 'update_available':
                 if ($plugin->version == $current['Version']) {
                     $output->writeln(sprintf('<info>%s</info> v<comment>%s</comment> is already installed!', $plugin->name, $plugin->version));
                 } else {
                     $output->write(sprintf('Upgrading <info>%s</info> from <comment>%s</comment> to <comment>%s</comment>', $plugin->name, $current['Version'], $plugin->version));
                     $file = sprintf('%s/%s', $slug, key(get_plugins("/{$slug}")));
                     $upgrader->upgrade($file);
                 }
                 break;
             case 'latest_installed':
                 $output->writeln(sprintf('<info>%s</info> v<comment>%s</comment> is already installed!', $plugin->name, $current['Version']));
                 break;
             case 'newer_installed':
                 $output->writeln(sprintf('<info>%s</info> v<comment>%s</comment> is installed & newer than <comment>%s</comment>', $plugin->name, $current['Version'], $plugin->version));
                 break;
         }
     }
     if ($plugins) {
         $output->writeln(sprintf('<info>Activate plugins in the WordPress Admin</info>', $plugin->name));
     }
 }
开发者ID:ericclemmons,项目名称:wordpress-generator,代码行数:53,代码来源:InstallPluginsWordPressCommand.php

示例4: updateAddon

 /**
  * @usage Single click add-on update
  */
 function updateAddon()
 {
     if (isset($_POST['updateurl']) && current_user_can(WPDM_ADMIN_CAP)) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         $upgrader = new \Plugin_Upgrader(new \Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
         $downloadlink = $_POST['updateurl'] . '&preact=login&user=' . get_option('__wpdm_suname') . '&pass=' . get_option('__wpdm_supass') . '&__wpdmnocache=' . uniqid();
         $upgrader->upgrade($downloadlink);
         $plugininfo = wpdm_plugin_data($_POST['plugin']);
         if (file_exists(dirname(WPDM_BASE_DIR) . '/' . $plugininfo['plugin_index_file'])) {
             activate_plugin($plugininfo['plugin_index_file']);
         }
         die("Updated Successfully");
     } else {
         die("Only site admin is authorized to install add-on");
     }
 }
开发者ID:wilxsv,项目名称:prevensionPublicLibrary,代码行数:20,代码来源:class.WordPressDownloadManagerAdmin.php

示例5: svn_update_plugin

 public function svn_update_plugin()
 {
     global $title, $parent_file, $submenu_file;
     if (!current_user_can('update_plugins')) {
         wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
     }
     check_admin_referer('svn_update_plugin');
     $this->plugin = $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
     if (empty($plugin)) {
         wp_die('Plugin name is missing.');
     }
     add_filter('site_transient_update_plugins', array($this, 'rewrite_update_plugins_url'));
     $title = __('Update Plugin');
     $parent_file = 'plugins.php';
     $submenu_file = 'plugins.php';
     wp_enqueue_script('updates');
     require_once ABSPATH . 'wp-admin/admin-header.php';
     $nonce = 'upgrade-plugin_' . $plugin;
     $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode($plugin);
     $upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(compact('title', 'nonce', 'url', 'plugin')));
     $upgrader->upgrade($plugin);
     include ABSPATH . 'wp-admin/admin-footer.php';
 }
开发者ID:szepeviktor,项目名称:svn-updater,代码行数:23,代码来源:svn-updater.php

示例6: autoUpdate

 public static function autoUpdate()
 {
     try {
         if (getenv('noabort') != '1' && stristr($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) {
             $lastEmail = self::get('lastLiteSpdEmail', false);
             if (!$lastEmail || time() - (int) $lastEmail > 86400 * 30) {
                 self::set('lastLiteSpdEmail', time());
                 wordfence::alert("Wordfence Upgrade not run. Please modify your .htaccess", "To preserve the integrity of your website we are not running Wordfence auto-update.\n" . "You are running the LiteSpeed web server which has been known to cause a problem with Wordfence auto-update.\n" . "Please go to your website now and make a minor change to your .htaccess to fix this.\n" . "You can find out how to make this change at:\n" . "https://support.wordfence.com/solution/articles/1000129050-running-wordfence-under-litespeed-web-server-and-preventing-process-killing-or\n" . "\nAlternatively you can disable auto-update on your website to stop receiving this message and upgrade Wordfence manually.\n", '127.0.0.1');
             }
             return;
         }
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         require_once ABSPATH . 'wp-admin/includes/misc.php';
         /* We were creating show_message here so that WP did not write to STDOUT. This had the strange effect of throwing an error about redeclaring show_message function, but only when a crawler hit the site and triggered the cron job. Not a human. So we're now just require'ing misc.php which does generate output, but that's OK because it is a loopback cron request.  
         			if(! function_exists('show_message')){ 
         				function show_message($msg = 'null'){}
         			}
         			*/
         define('FS_METHOD', 'direct');
         require_once ABSPATH . 'wp-includes/update.php';
         require_once ABSPATH . 'wp-admin/includes/file.php';
         wp_update_plugins();
         ob_start();
         $upgrader = new Plugin_Upgrader();
         $upret = $upgrader->upgrade('wordfence/wordfence.php');
         if ($upret) {
             $cont = file_get_contents(WP_PLUGIN_DIR . '/wordfence/wordfence.php');
             if (wfConfig::get('alertOn_update') == '1' && preg_match('/Version: (\\d+\\.\\d+\\.\\d+)/', $cont, $matches)) {
                 wordfence::alert("Wordfence Upgraded to version " . $matches[1], "Your Wordfence installation has been upgraded to version " . $matches[1], '127.0.0.1');
             }
         }
         $output = @ob_get_contents();
         @ob_end_clean();
     } catch (Exception $e) {
     }
 }
开发者ID:HandsomeDogStudio,项目名称:peanutbutterplan,代码行数:36,代码来源:wfConfig.php

示例7: upgrade_plugin_multisite

 /**
  * Auto-Update Plugin in multisite
  *
  * Manage the non standard upgrade-plugin-multisite action
  *
  * @return void
  *
  * @since    1.0
  * @see      upgrade-plugin action
  * @author   Andrea Grillo <andrea.grillo@yithemes.com>
  */
 public function upgrade_plugin_multisite()
 {
     $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
     if ('upgrade-plugin-multisite' != $action) {
         wp_die(__('You can\'t update the plugins for this site.', 'yith-plugin-fw'));
     }
     if (!current_user_can('update_plugins')) {
         wp_die(__('You do not have sufficient permissions to update the plugins for this site.', 'yith-plugin-fw'));
     }
     $this->check_update(get_site_transient('update_plugins'), true);
     check_admin_referer('upgrade-plugin-multisite_' . $plugin);
     $title = __('Update Plugin', 'yith-plugin-fw');
     $parent_file = 'plugins.php';
     $submenu_file = 'plugins.php';
     wp_enqueue_script('updates');
     require_once ABSPATH . 'wp-admin/admin-header.php';
     $nonce = 'upgrade-plugin-multisite_' . $plugin;
     $url = 'update.php?action=upgrade-plugin-multisite&plugin=' . urlencode($plugin);
     $upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(compact('title', 'nonce', 'url', 'plugin')));
     $upgrader->upgrade($plugin);
     include ABSPATH . 'wp-admin/admin-footer.php';
 }
开发者ID:lieison,项目名称:IndustriasFenix,代码行数:34,代码来源:yit-upgrade.php

示例8: download_plugin

 public function download_plugin()
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once $this->plugin_path() . '/includes/installer-upgrader-skins.php';
     if (isset($_POST['data'])) {
         $data = json_decode(base64_decode($_POST['data']), true);
     }
     $ret = false;
     $plugin_id = false;
     if ($data['nonce'] == wp_create_nonce('install_plugin_' . $data['url'])) {
         $upgrader_skins = new Installer_Upgrader_Skins();
         //use our custom (mute) Skin
         $upgrader = new Plugin_Upgrader($upgrader_skins);
         remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
         $plugins = get_plugins();
         //upgrade or install?
         foreach ($plugins as $id => $plugin) {
             if (dirname($id) == $data['basename']) {
                 $plugin_id = $id;
                 break;
             }
         }
         if ($plugin_id) {
             //upgrade
             $response['upgrade'] = 1;
             $plugin_is_active = is_plugin_active($plugin_id);
             $ret = $upgrader->upgrade($plugin_id);
             if ($plugin_is_active) {
                 activate_plugin($plugin_id);
             }
         } else {
             //install
             $response['install'] = 1;
             $ret = $upgrader->install($data['url']);
         }
         $plugins = get_plugins();
         //read again
         if ($ret && !empty($_POST['activate'])) {
             foreach ($plugins as $id => $plugin) {
                 if (dirname($id) == $data['basename']) {
                     $plugin_version = $plugin['Version'];
                     $plugin_id = $id;
                     break;
                 }
             }
         }
     }
     $response['version'] = isset($plugin_version) ? $plugin_version : 0;
     $response['plugin_id'] = $plugin_id;
     $response['nonce'] = wp_create_nonce('activate_' . $plugin_id);
     $response['success'] = $ret;
     echo json_encode($response);
     exit;
 }
开发者ID:Nguyenkain,项目名称:Elearning,代码行数:54,代码来源:installer.class.php

示例9: wpdm_activate_shop

function wpdm_activate_shop()
{
    if (current_user_can('manage_options')) {
        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
        $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
        $downloadlink = 'http://www.wpdownloadmanager.com/?wpdmdl=15671';
        ob_start();
        echo "<div id='acto'>";
        if (file_exists(dirname(dirname(__FILE__)) . '/wpdm-premium-packages/')) {
            $upgrader->upgrade($downloadlink);
        } else {
            $upgrader->install($downloadlink);
        }
        echo '</div><style>#acto .wrap { display: none; }</style>';
        @ob_clean();
        activate_plugin('wpdm-premium-packages/wpdm-premium-packages.php');
        echo "Congratulation! Your Digital Store is Activated. <a href='' class='btn btn-warning'>Refresh The Page!</a>";
        die;
    } else {
        die("Only site admin is authorized to install add-on");
    }
}
开发者ID:antoninab,项目名称:t2c,代码行数:23,代码来源:functions.php

示例10: wptouch_free_upgrade_plugin

function wptouch_free_upgrade_plugin()
{
    global $wptouch_pro;
    $wptouch_pro->bnc_api = false;
    $settings = wptouch_get_settings('bncid');
    $wptouch_pro->setup_bncapi($settings->bncid, $settings->wptouch_license_key, true);
    $bnc_api = $wptouch_pro->get_bnc_api();
    $plugin_name = 'wptouch/wptouch.php';
    // Check for WordPress 3.0 function
    if (function_exists('is_super_admin')) {
        $option = get_site_transient('update_plugins');
    } else {
        $option = function_exists('get_transient') ? get_transient('update_plugins') : get_option('update_plugins');
    }
    $version_available = false;
    $latest_info = $bnc_api->get_product_version();
    if ($latest_info && $latest_info['version'] != WPTOUCH_VERSION) {
        WPTOUCH_DEBUG(WPTOUCH_INFO, 'A new product update is available [' . $latest_info['version'] . ']');
        if (isset($latest_info['upgrade_url']) && wptouch_has_license()) {
            if (!isset($option->response[$plugin_name])) {
                $option->response[$plugin_name] = new stdClass();
            }
            // Update upgrade options
            $option->response[$plugin_name]->url = 'http://www.wptouch.com/';
            $option->response[$plugin_name]->package = $latest_info['upgrade_url'];
            $option->response[$plugin_name]->new_version = $latest_info['version'];
            $option->response[$plugin_name]->id = '0';
            $option->response[$plugin_name]->slug = WPTOUCH_ROOT_NAME;
        } else {
            if (is_object($option) && isset($option->response)) {
                unset($option->response[$plugin_name]);
            }
        }
        $wptouch_pro->latest_version_info = $latest_info;
        $upgrade_available = $latest_info['version'];
    } else {
        if (is_object($option) && isset($option->response)) {
            unset($option->response[$plugin_name]);
        }
    }
    if (isset($option->response[$plugin_name])) {
        // WordPress 3.0 changed some stuff, so we check for a WP 3.0 function
        if (function_exists('is_super_admin')) {
            set_site_transient('update_plugins', $option);
        } else {
            if (function_exists('set_transient')) {
                set_transient('update_plugins', $option);
            }
        }
        // Do Upgrade
        include_once ABSPATH . 'wp-admin/includes/admin.php';
        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
        $upgrader->upgrade('wptouch/wptouch.php');
        if (is_array($upgrader->skin->result)) {
            deactivate_plugins('wptouch/wptouch.php');
            $new_plugin_identifier = 'wptouch-pro/wptouch-pro.php';
            $active_plugins = get_option('active_plugins', array());
            if (!in_array($new_plugin_identifier, $active_plugins)) {
                $active_plugins[] = $new_plugin_identifier;
                update_option('active_plugins', $active_plugins);
            }
            return '1';
        } else {
            return '0';
        }
    } else {
        return '0';
    }
}
开发者ID:sumwander,项目名称:unyil,代码行数:70,代码来源:globals.php

示例11: do_plugin_install

 /**
  * Installs, updates or activates a plugin depending on the action link clicked by the user.
  *
  * Checks the $_GET variable to see which actions have been
  * passed and responds with the appropriate method.
  *
  * Uses WP_Filesystem to process and handle the plugin installation
  * method.
  *
  * @since 1.0.0
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  * @uses Plugin_Upgrader_Skin
  *
  * @return boolean True on success, false on failure.
  */
 protected function do_plugin_install()
 {
     if (empty($_GET['plugin'])) {
         return false;
     }
     // All plugin information will be stored in an array for processing.
     $slug = $this->sanitize_key(urldecode($_GET['plugin']));
     if (!isset($this->plugins[$slug])) {
         return false;
     }
     // Was an install or upgrade action link clicked?
     if (isset($_GET['tgmpa-install']) && 'install-plugin' === $_GET['tgmpa-install'] || isset($_GET['tgmpa-update']) && 'update-plugin' === $_GET['tgmpa-update']) {
         $install_type = 'install';
         if (isset($_GET['tgmpa-update']) && 'update-plugin' === $_GET['tgmpa-update']) {
             $install_type = 'update';
         }
         check_admin_referer('tgmpa-' . $install_type, 'tgmpa-nonce');
         // Pass necessary information via URL if WP_Filesystem is needed.
         $url = wp_nonce_url(add_query_arg(array('plugin' => urlencode($slug), 'tgmpa-' . $install_type => $install_type . '-plugin'), $this->get_tgmpa_url()), 'tgmpa-' . $install_type, 'tgmpa-nonce');
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary.
         if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, array()))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials(esc_url_raw($url), $method, true, false, array());
             // Setup WP_Filesystem.
             return true;
         }
         /* If we arrive here, we have the filesystem. */
         // Prep variables for Plugin_Installer_Skin class.
         $extra = array();
         $extra['slug'] = $slug;
         // Needed for potentially renaming of directory name.
         $source = $this->get_download_url($slug);
         $api = 'repo' === $this->plugins[$slug]['source_type'] ? $this->get_plugins_api($slug) : null;
         $api = false !== $api ? $api : null;
         $url = add_query_arg(array('action' => $install_type . '-plugin', 'plugin' => urlencode($slug)), 'update.php');
         if (!class_exists('Plugin_Upgrader', false)) {
             require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         }
         $skin_args = array('type' => 'bundled' !== $this->plugins[$slug]['source_type'] ? 'web' : 'upload', 'title' => sprintf($this->strings['installing'], $this->plugins[$slug]['name']), 'url' => esc_url_raw($url), 'nonce' => $install_type . '-plugin_' . $slug, 'plugin' => '', 'api' => $api, 'extra' => $extra);
         if ('update' === $install_type) {
             $skin_args['plugin'] = $this->plugins[$slug]['file_path'];
             $skin = new Plugin_Upgrader_Skin($skin_args);
         } else {
             $skin = new Plugin_Installer_Skin($skin_args);
         }
         // Create a new instance of Plugin_Upgrader.
         $upgrader = new Plugin_Upgrader($skin);
         // Perform the action and install the plugin from the $source urldecode().
         add_filter('upgrader_source_selection', array($this, 'maybe_adjust_source_dir'), 1, 3);
         if ('update' === $install_type) {
             // Inject our info into the update transient.
             $to_inject = array($slug => $this->plugins[$slug]);
             $to_inject[$slug]['source'] = $source;
             $this->inject_update_info($to_inject);
             $upgrader->upgrade($this->plugins[$slug]['file_path']);
         } else {
             $upgrader->install($source);
         }
         remove_filter('upgrader_source_selection', array($this, 'maybe_adjust_source_dir'), 1, 3);
         // Make sure we have the correct file path now the plugin is installed/updated.
         $this->populate_file_path($slug);
         // Only activate plugins if the config option is set to true and the plugin isn't
         // already active (upgrade).
         if ($this->is_automatic && !$this->is_plugin_active($slug)) {
             $plugin_activate = $upgrader->plugin_info();
             // Grab the plugin info from the Plugin_Upgrader method.
             if (false === $this->activate_single_plugin($plugin_activate, $slug, true)) {
                 return true;
                 // Finish execution of the function early as we encountered an error.
             }
         }
         $this->show_tgmpa_version();
         // Display message based on if all plugins are now active or not.
         if ($this->is_tgmpa_complete()) {
             echo '<p>', sprintf(esc_html($this->strings['complete']), '<a href="' . esc_url(self_admin_url()) . '">' . esc_html__('Return to the Dashboard', 'tgmpa') . '</a>'), '</p>';
             echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
         } else {
//.........这里部分代码省略.........
开发者ID:GvarimAZA,项目名称:website,代码行数:101,代码来源:class-tgm-plugin-activation.php

示例12:

 function do_plugin_update($slug)
 {
     if (empty($this->plugins[$slug])) {
         $status['error'] = 'We have no data about this plugin.';
         wp_send_json_error($status);
     }
     if ($this->plugin_has_update($slug)) {
         if (!class_exists('Plugin_Upgrader', false)) {
             require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         }
         $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
         $result = $upgrader->upgrade($slug);
         if (is_wp_error($result)) {
             $status['error'] = $result->get_error_message();
             wp_send_json_error($status);
         }
         if (!empty($this->plugins[$slug]['force_activation'])) {
             $this->do_plugin_activate($slug);
         }
     }
 }
开发者ID:rock1media,项目名称:wordpress,代码行数:21,代码来源:class-zn-plugins.php

示例13: wp_update_plugin

function wp_update_plugin($plugin, $feedback = '')
{
    if (!empty($feedback)) {
        add_filter('update_feedback', $feedback);
    }
    include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $upgrader = new Plugin_Upgrader();
    return $upgrader->upgrade($plugin);
}
开发者ID:netconstructor,项目名称:WordPress,代码行数:9,代码来源:update.php

示例14: do_plugin_install

 /**
  * Installs a plugin or activates a plugin depending on the hover
  * link clicked by the user.
  *
  * Checks the $_GET variable to see which actions have been
  * passed and responds with the appropriate method.
  *
  * Uses WP_Filesystem to process and handle the plugin installation
  * method.
  *
  * @since 1.0.0
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  *
  * @return boolean True on success, false on failure
  */
 protected function do_plugin_install()
 {
     // All plugin information will be stored in an array for processing.
     $plugin = array();
     // Checks for actions from hover links to process the installation.
     if (isset($_GET[sanitize_key('plugin')]) && (isset($_GET[sanitize_key('tgmpa-install')]) && 'install-plugin' == $_GET[sanitize_key('tgmpa-install')] || isset($_GET[sanitize_key('tgmpa-update')]) && 'update-plugin' == $_GET[sanitize_key('tgmpa-update')])) {
         check_admin_referer('tgmpa-install');
         $plugin['name'] = $_GET['plugin_name'];
         // Plugin name.
         $plugin['slug'] = $_GET['plugin'];
         // Plugin slug.
         $plugin['source'] = urldecode($_GET['plugin_source']);
         // Plugin source.
         $plugin['version'] = isset($_GET[sanitize_key('version')]) ? $_GET[sanitize_key('version')] : '';
         // Plugin source
         $install_type = isset($_GET[sanitize_key('tgmpa-update')]) ? $_GET[sanitize_key('tgmpa-update')] : '';
         // Install type
         // Pass all necessary information via URL if WP_Filesystem is needed.
         $url = wp_nonce_url(add_query_arg(array('page' => $this->menu, 'plugin' => $plugin['slug'], 'plugin_name' => $plugin['name'], 'plugin_source' => $plugin['source'], 'tgmpa-install' => 'install-plugin'), admin_url('themes.php')), 'tgmpa-install');
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary.
         $fields = array('tgmpa-install');
         // Extra fields to pass to WP_Filesystem.
         if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $fields))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials($url, $method, true, false, $fields);
             // Setup WP_Filesystem.
             return true;
         }
         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         // Need for plugins_api.
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         // Need for upgrade classes.
         // Set plugin source to WordPress API link if available.
         if (isset($plugin['source']) && 'repo' == $plugin['source']) {
             $api = plugins_api('plugin_information', array('slug' => $plugin['slug'], 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 wp_die($this->strings['oops'] . var_dump($api));
             }
             if (isset($api->download_link)) {
                 $plugin['source'] = $api->download_link;
             }
         }
         // Set type, based on whether the source starts with http:// or https://.
         $type = preg_match('|^http(s)?://|', $plugin['source']) ? 'web' : 'upload';
         // Prep variables for Plugin_Installer_Skin class.
         $title = sprintf($this->strings['installing'], $plugin['name']);
         $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => $plugin['slug']), 'update.php');
         if (isset($_GET['from'])) {
             $url .= add_query_arg('from', urlencode(stripslashes($_GET['from'])), $url);
         }
         $nonce = 'install-plugin_' . $plugin['slug'];
         // Prefix a default path to pre-packaged plugins.
         $source = 'upload' == $type ? $this->default_path . $plugin['source'] : $plugin['source'];
         // Create a new instance of Plugin_Upgrader.
         $upgrader = new Plugin_Upgrader($skin = new Plugin_Installer_Skin(compact('type', 'title', 'url', 'nonce', 'plugin', 'api')));
         // Perform the action and install the plugin from the $source urldecode().
         if ($install_type == 'update-plugin') {
             delete_site_transient('update_plugins');
             $data = get_site_transient('update_plugins');
             if (!is_object($data)) {
                 $data = new stdClass();
             }
             $data->response[$plugin['slug']] = new stdClass();
             $data->response[$plugin['slug']]->package = $source;
             $data->response[$plugin['slug']]->version = $plugin['version'];
             set_site_transient('update_plugins', $data);
             $upgrader->upgrade($plugin['slug']);
         } else {
             $upgrader->install($source);
         }
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
         // Only activate plugins if the config option is set to true.
         if ($this->is_automatic) {
             $plugin_activate = $upgrader->plugin_info();
             // Grab the plugin info from the Plugin_Upgrader method.
             $activate = activate_plugin($plugin_activate);
//.........这里部分代码省略.........
开发者ID:shimion,项目名称:localinsurance-theme,代码行数:101,代码来源:class-tgmpa.php

示例15: define

 function mail_bank_plugin_autoUpdate()
 {
     try {
         require_once ABSPATH . "wp-admin/includes/class-wp-upgrader.php";
         require_once ABSPATH . "wp-admin/includes/misc.php";
         define("FS_METHOD", "direct");
         require_once ABSPATH . "wp-includes/update.php";
         require_once ABSPATH . "wp-admin/includes/file.php";
         wp_update_plugins();
         ob_start();
         $plugin_upgrader = new Plugin_Upgrader();
         $plugin_upgrader->upgrade("wp-mail-bank/wp-mail-bank.php");
         $output = @ob_get_contents();
         @ob_end_clean();
     } catch (Exception $e) {
     }
 }
开发者ID:ntnvu,项目名称:tcb_online,代码行数:17,代码来源:wp-mail-bank.php


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