本文整理汇总了PHP中Plugin_Upgrader类的典型用法代码示例。如果您正苦于以下问题:PHP Plugin_Upgrader类的具体用法?PHP Plugin_Upgrader怎么用?PHP Plugin_Upgrader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin_Upgrader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: hooks_plugin_install_or_update
/**
* @param Plugin_Upgrader $upgrader
* @param array $extra
*/
public function hooks_plugin_install_or_update($upgrader, $extra)
{
if (!isset($extra['type']) || 'plugin' !== $extra['type']) {
return;
}
if ('install' === $extra['action']) {
$path = $upgrader->plugin_info();
if (!$path) {
return;
}
$data = get_plugin_data($upgrader->skin->result['local_destination'] . '/' . $path, true, false);
aal_insert_log(array('action' => 'installed', 'object_type' => 'Plugin', 'object_name' => $data['Name'], 'object_subtype' => $data['Version']));
}
if ('update' === $extra['action']) {
if (isset($extra['bulk']) && true == $extra['bulk']) {
$slugs = $extra['plugins'];
} else {
if (!isset($upgrader->skin->plugin)) {
return;
}
$slugs = array($upgrader->skin->plugin);
}
foreach ($slugs as $slug) {
$data = get_plugin_data(WP_PLUGIN_DIR . '/' . $slug, true, false);
aal_insert_log(array('action' => 'updated', 'object_type' => 'Plugin', 'object_name' => $data['Name'], 'object_subtype' => $data['Version']));
}
}
}
开发者ID:JDjimenezdelgado,项目名称:old-mmexperience,代码行数:32,代码来源:class-aal-hook-plugins.php
示例3: install
protected function install()
{
foreach ($this->plugins as $index => $slug) {
$skin = new Jetpack_Automatic_Install_Skin();
$upgrader = new Plugin_Upgrader($skin);
$zip_url = self::generate_wordpress_org_plugin_download_link($slug);
$result = $upgrader->install($zip_url);
if (!$this->bulk && is_wp_error($result)) {
return $result;
}
$plugin = self::get_plugin_id_by_slug($slug);
$error_code = 'install_error';
if (!$plugin) {
$error = $this->log[$slug]['error'] = __('There was an error installing your plugin', 'jetpack');
}
if (!$this->bulk && !$result) {
$error_code = $upgrader->skin->get_main_error_code();
$message = $upgrader->skin->get_main_error_message();
$error = $this->log[$slug]['error'] = $message ? $message : __('An unknown error occurred during installation', 'jetpack');
}
$this->log[$plugin][] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && isset($error)) {
if ('download_failed' === $error_code) {
// For backwards compatibility: versions prior to 3.9 would return no_package instead of download_failed.
$error_code = 'no_package';
}
return new WP_Error($error_code, $this->log[$slug]['error'], 400);
}
// replace the slug with the actual plugin id
$this->plugins[$index] = $plugin;
return true;
}
开发者ID:automattic,项目名称:jetpack,代码行数:33,代码来源:class.jetpack-json-api-plugins-install-endpoint.php
示例4: rtbiz_install_plugin
public function rtbiz_install_plugin($plugin_slug)
{
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
$api = plugins_api('plugin_information', array('slug' => $plugin_slug, 'fields' => array('sections' => false)));
if (is_wp_error($api)) {
die(sprintf(__('ERROR: Error fetching plugin information: %s', RTBIZ_TEXT_DOMAIN), $api->get_error_message()));
}
if (!class_exists('Plugin_Upgrader')) {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
}
if (!class_exists('Rtbiz_Plugin_Upgrader_Skin')) {
require_once RTBIZ_PATH . 'admin/abstract/class-rtbiz-plugin-upgrader-skin.php';
}
$upgrader = new Plugin_Upgrader(new Rtbiz_Plugin_Upgrader_Skin(array('nonce' => 'install-plugin_' . $plugin_slug, 'plugin' => $plugin_slug, 'api' => $api)));
$install_result = $upgrader->install($api->download_link);
if (!$install_result || is_wp_error($install_result)) {
// $install_result can be false if the file system isn't writeable.
$error_message = __('Please ensure the file system is writeable', RTBIZ_TEXT_DOMAIN);
if (is_wp_error($install_result)) {
$error_message = $install_result->get_error_message();
}
die(sprintf(__('ERROR: Failed to install plugin: %s', RTBIZ_TEXT_DOMAIN), $error_message));
}
$activate_result = activate_plugin($this->rtbiz_get_path_for_plugin($plugin_slug));
if (is_wp_error($activate_result)) {
die(sprintf(__('ERROR: Failed to activate plugin: %s', RTBIZ_TEXT_DOMAIN), $activate_result->get_error_message()));
}
}
开发者ID:chandra-patel,项目名称:rtbiz,代码行数:28,代码来源:class-rtbiz-plugin-check.php
示例5: install
protected function install()
{
foreach ($this->plugins as $index => $slug) {
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Plugin_Upgrader($skin);
$result = $upgrader->install($this->download_links[$slug]);
if (!$this->bulk && is_wp_error($result)) {
return $result;
}
$plugin = $this::get_plugin_id_by_slug($slug);
if (!$plugin) {
$error = $this->log[$slug]['error'] = __('There was an error installing your plugin', 'jetpack');
}
if (!$this->bulk && !$result) {
$error = $this->log[$slug]['error'] = __('An unknown error occurred during installation', 'jetpack');
}
$this->log[$plugin][] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && isset($error)) {
return new WP_Error('install_error', $this->log[$slug]['error'], 400);
}
// replace the slug with the actual plugin id
$this->plugins[$index] = $plugin;
return true;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:25,代码来源:class.jetpack-json-api-plugins-install-endpoint.php
示例6: 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
示例7: mpi_plugin_handle_download
function mpi_plugin_handle_download($plugin_name, $package, $mpi_action, $whform)
{
global $wp_version;
if (version_compare($wp_version, '3.0', '<')) {
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader();
$upgrader->install($package);
if ($upgrader->plugin_info()) {
echo '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $upgrader->plugin_info(), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
}
} else {
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'nonce', 'url')));
$res = $upgrader->install($package);
//remove temp files
if ($whform == "upload_locFiles") {
@unlink($package);
}
if (!$upgrader->plugin_info()) {
echo $res;
} elseif ($mpi_action == "activate") {
$mpiplugins = get_option('active_plugins');
if ($mpiplugins) {
$puginsToActiv = array($upgrader->plugin_info());
foreach ($puginsToActiv as $mpiplugin) {
if (!in_array($mpiplugin, $mpiplugins)) {
array_push($mpiplugins, $mpiplugin);
update_option('active_plugins', $mpiplugins);
}
}
}
_e('<b class="mpi_act">Plugin activated successfully.</b><br/>', 'mpi');
}
}
}
开发者ID:linniepinski,项目名称:perssistant,代码行数:35,代码来源:mpi-Class.php
示例8: bruteprotect_bulk_update_plugins
/**
* Updates the given list of plugins.
*
* Accepts an array of plugin paths such as 'bruteprotect/bruteprotect.php'
* Returns a detailed array showing the status of each plugin and a log of messages output during the process
*
* @param array $plugins
* @return array
*/
function bruteprotect_bulk_update_plugins($plugins)
{
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Plugin_Upgrader($skin);
$results = $upgrader->bulk_upgrade($plugins);
$messages = $upgrader->skin->get_upgrade_messages();
$o['results'] = $results;
$o['messages'] = $messages;
return $o;
}
开发者ID:jeremylightsmith,项目名称:blog,代码行数:19,代码来源:update.php
示例9: pl_ui_build_body
function pl_ui_build_body($obj)
{
if (isset($_GET['install_faves']) && 'true' == $_GET['install_faves'] || isset($_GET['install_multi']) && 'true' == $_GET['install_multi']) {
if (isset($_GET['install_multi'])) {
$mode = 'multi';
} else {
$mode = 'fav';
}
if ('multi' == $mode) {
$banner = 'Installing Selected Products';
$favs = explode(',', $_GET['slugs']);
foreach ($favs as $k => $fav) {
$favs[$fav] = $fav;
unset($favs[$k]);
}
} else {
$banner = 'Installing Favourite Products';
$favs = (array) get_user_meta(wp_get_current_user()->ID, '_card_fav', true);
}
printf('<h2>%s</2>', $banner);
// lets go!
if (!empty($favs)) {
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'nonce', 'url')));
$data = PL_Platform()->functions->cache_get('connect_updates');
foreach ($data as $k => $prod) {
$data[$prod->slug] = $prod;
unset($data[$k]);
}
foreach ($favs as $slug => $k) {
$path = sprintf('%s/%s.php', $slug, $slug);
if (PL_Platform()->extend->is_plugin_installed($path)) {
printf('<p>%s is already installed, skipping.</p>', $data[$slug]->post_title);
} else {
printf('<p><i class="%s-spinner fa fa-cog fa-spin"></i><div style="display:none">', $slug);
$link = PL_Platform_Updater::get_download_link($data[$slug]->download_data);
$res = $upgrader->install($link);
printf('</div></p><script>jQuery(".%s-spinner").hide()</script>', $slug);
if ($upgrader->plugin_info()) {
$result = activate_plugin($path);
printf('<p><strong>%s</strong> has been installed successfully and is activated.</p>', $data[$slug]->post_title);
} else {
echo $res;
break;
}
}
}
echo '</p><h3>All Done!</h3></p><script>localStorage.clear();setTimeout(function(){window.location.href=window.PLAdmin.extendURL},3000)</script>';
}
} else {
$obj->build_body();
}
}
开发者ID:voomco,项目名称:WordPress,代码行数:53,代码来源:extend.php
示例10: install_wp_super_cache
function install_wp_super_cache()
{
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// code from wp-admin/update.php
$api = plugins_api('plugin_information', array('slug' => 'wp-super-cache', 'fields' => array('short_description' => false, 'sections' => false, 'requires' => false, 'rating' => false, 'ratings' => false, 'downloaded' => false, 'last_updated' => false, 'added' => false, 'tags' => false, 'compatibility' => false, 'homepage' => false, 'donate_link' => false)));
if (is_wp_error($api)) {
wp_die($api);
}
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
$upgrader->install($api->download_link);
}
开发者ID:iamtakashi,项目名称:jetpack,代码行数:12,代码来源:test_class.jetpack-sync-plugins.php
示例11: 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
示例12: siteorigin_plugin_activation_do_plugin_install
/**
* Install a plugin
*/
function siteorigin_plugin_activation_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('siteorigin-pa-install')]) && 'install-plugin' == $_GET[sanitize_key('siteorigin-pa-install')]) && current_user_can('install_plugins')) {
check_admin_referer('siteorigin-pa-install');
$plugin['name'] = $_GET['plugin_name'];
// Plugin name
$plugin['slug'] = $_GET['plugin'];
// Plugin slug
if (!empty($_GET['plugin_source'])) {
$plugin['source'] = $_GET['plugin_source'];
} else {
$plugin['source'] = false;
}
/** Pass all necessary information via URL if WP_Filesystem is needed */
$url = wp_nonce_url(add_query_arg(array('page' => 'siteorigin_plugin_activation', 'plugin' => $plugin['slug'], 'plugin_name' => $plugin['name'], 'plugin_source' => $plugin['source'], 'siteorigin-pa-install' => 'install-plugin'), admin_url('themes.php')), 'siteorigin-pa-install');
$method = '';
// Leave blank so WP_Filesystem can populate it as necessary
$fields = array(sanitize_key('siteorigin-pa-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
/** Prep variables for Plugin_Installer_Skin class */
$title = sprintf(__('Installing %s', 'vantage'), $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'];
// Find the source of the plugin
$source = !empty($plugin['source']) ? $plugin['source'] : 'http://downloads.wordpress.org/plugin/' . urlencode($plugin['slug']) . '.zip';
/** 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() */
$upgrader->install($source);
/** Flush plugins cache so we can make sure that the installed plugins list is always up to date */
wp_cache_flush();
}
}
开发者ID:CUPolishSociety,项目名称:campolsoc,代码行数:54,代码来源:plugin-activation.php
示例13: installAddon
/**
* @usage Single click add-on install
*/
function installAddon()
{
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');
$upgrader->install($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("Installed Successfully");
} else {
die("Only site admin is authorized to install add-on");
}
}
开发者ID:wilxsv,项目名称:prevensionPublicLibrary,代码行数:20,代码来源:class.WordPressDownloadManagerAdmin.php
示例14: is_uploading_allowed
public function is_uploading_allowed()
{
if (!isset($this->uploading_allowed)) {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once WP_Installer()->plugin_path() . '/includes/installer-upgrader-skins.php';
$upgrader_skins = new Installer_Upgrader_Skins();
//use our custom (mute) Skin
$upgrader = new Plugin_Upgrader($upgrader_skins);
ob_start();
$res = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR));
ob_end_clean();
if (!$res || is_wp_error($res)) {
$this->uploading_allowed = false;
} else {
$this->uploading_allowed = true;
}
}
return $this->uploading_allowed;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:19,代码来源:class-installer-dependencies.php
示例15: download_plugin
/**
* Install plugin from a URL.
*
* A mix of install-plugin and upload-plugin actions from wp-admin/update.php:93.
*/
public function download_plugin()
{
if (!current_user_can('upload_plugins')) {
wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
}
check_admin_referer('plugin-download');
require_once ABSPATH . 'wp-admin/admin-header.php';
$download_url = esc_url_raw($_REQUEST['pluginurl']);
// Remove "-master" from GitHub URL-s
if (false !== strstr($download_url, '//github.com/')) {
add_filter('upgrader_source_selection', array($this, 'remove_github_master'), 9, 3);
}
$type = 'web';
$title = sprintf(__('Installing Plugin from URL: %s'), esc_html($download_url));
$url = 'update.php?action=install-plugin';
$nonce = 'plugin-download';
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'url', 'nonce')));
$upgrader->install($download_url);
include ABSPATH . 'wp-admin/admin-footer.php';
}
开发者ID:vrkansagara,项目名称:wordpress-plugin-construction,代码行数:25,代码来源:plugin-upload-from-url.php
示例16: install
function install()
{
$args = $this->input();
if (isset($args['zip'][0]['id'])) {
$plugin_attachment_id = $args['zip'][0]['id'];
$local_file = get_attached_file($plugin_attachment_id);
if (!$local_file) {
return new WP_Error('local-file-does-not-exist');
}
$skin = new Jetpack_Automatic_Install_Skin();
$upgrader = new Plugin_Upgrader($skin);
$pre_install_plugin_list = get_plugins();
$result = $upgrader->install($local_file);
// clean up.
wp_delete_attachment($plugin_attachment_id, true);
if (is_wp_error($result)) {
return $result;
}
$after_install_plugin_list = get_plugins();
$plugin = array_values(array_diff(array_keys($after_install_plugin_list), array_keys($pre_install_plugin_list)));
if (!$result) {
$error_code = $upgrader->skin->get_main_error_code();
$message = $upgrader->skin->get_main_error_message();
if (empty($message)) {
$message = __('An unknown error occurred during installation', 'jetpack');
}
if ('download_failed' === $error_code) {
$error_code = 'no_package';
}
return new WP_Error($error_code, $message, 400);
}
if (empty($plugin)) {
return new WP_Error('plugin_already_installed');
}
$this->plugins = $plugin;
$this->log[$plugin[0]] = $upgrader->skin->get_upgrade_messages();
return true;
}
return new WP_Error('no_plugin_installed');
}
开发者ID:automattic,项目名称:jetpack,代码行数:40,代码来源:class.jetpack-json-api-plugins-new-endpoint.php
示例17: handle_download
function handle_download($plugin_name, $package)
{
global $wp_version;
if (version_compare($wp_version, '2.8', '<')) {
$this->update_plugin_advanced($plugin_name, $package);
} else {
if (version_compare($wp_version, '3.0', '<')) {
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader();
$upgrader->install($package);
if ($upgrader->plugin_info()) {
echo '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $upgrader->plugin_info(), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
}
} else {
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'nonce', 'url')));
$res = $upgrader->install($package);
if (!$upgrader->plugin_info()) {
echo $res;
}
}
}
}
开发者ID:87surendra,项目名称:mbr,代码行数:23,代码来源:plugin-central.class.php
示例18: 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
示例19: updateFromZip
public static function updateFromZip($fileRaw, $updateInfo)
{
N2Loader::import('libraries.zip.zip_read');
$tmpHandle = tmpfile();
fwrite($tmpHandle, $fileRaw);
$metaData = stream_get_meta_data($tmpHandle);
$tmpFilename = $metaData['uri'];
$_GET['plugins'] = $updateInfo['plugin'];
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(compact('title', 'nonce', 'url', 'plugin')));
$upgrader->init();
$upgrader->upgrade_strings();
add_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'), 10, 4);
$upgrader->run(array('package' => $tmpFilename, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $updateInfo['plugin'], 'type' => 'plugin', 'action' => 'update')));
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'));
// Force refresh of plugin update information
wp_clean_plugins_cache(true);
fclose($tmpHandle);
include ABSPATH . 'wp-admin/admin-footer.php';
return true;
}
开发者ID:MBerguer,项目名称:wp-demo,代码行数:24,代码来源:platform.php
示例20: wp_update_plugin
/**
* This was once used to kick-off the Plugin Updater.
*
* Deprecated in favor of instantating a Plugin_Upgrader instance directly,
* and calling the 'upgrade' method.
* Unused since 2.8.0.
*
* @since 2.5.0
* @deprecated 3.7.0
* @see Plugin_Upgrader
*/
function wp_update_plugin($plugin, $feedback = '')
{
_deprecated_function(__FUNCTION__, '3.7', 'new Plugin_Upgrader();');
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:valiror,项目名称:sharingdais_demo1,代码行数:21,代码来源:deprecated.php
注:本文中的Plugin_Upgrader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论