本文整理汇总了PHP中wp_clean_plugins_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_clean_plugins_cache函数的具体用法?PHP wp_clean_plugins_cache怎么用?PHP wp_clean_plugins_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_clean_plugins_cache函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: rollback
public function rollback($plugin, $args = array())
{
$defaults = array('clear_update_cache' => true);
$parsed_args = wp_parse_args($args, $defaults);
$this->init();
$this->upgrade_strings();
// TODO: Add final check to make sure plugin exists
if (0) {
$this->skin->before();
$this->skin->set_result(false);
$this->skin->error('up_to_date');
$this->skin->after();
return false;
}
$plugin_slug = $this->skin->plugin;
$plugin_version = $this->skin->options['version'];
$download_endpoint = 'https://downloads.wordpress.org/plugin/';
$url = $download_endpoint . $plugin_slug . '.' . $plugin_version . '.zip';
add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
$this->run(array('package' => $url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin, 'type' => 'plugin', 'action' => 'update')));
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
if (!$this->result || is_wp_error($this->result)) {
return $this->result;
}
// Force refresh of plugin update information
wp_clean_plugins_cache($parsed_args['clear_update_cache']);
return true;
}
开发者ID:kenaku,项目名称:style,代码行数:31,代码来源:class-rollback-plugin-upgrader.php
示例2: 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
示例3: languages_page
public function languages_page()
{
// prepare the list of tabs
$tabs = array('lang' => __('Languages', 'polylang'));
// only if at least one language has been created
if ($listlanguages = $this->model->get_languages_list()) {
$tabs['strings'] = __('Strings translation', 'polylang');
$tabs['settings'] = __('Settings', 'polylang');
}
// allows plugins to add tabs
$tabs = apply_filters('pll_settings_tabs', $tabs);
switch ($this->active_tab) {
case 'lang':
// prepare the list table of languages
$list_table = new PLL_Table_Languages();
$list_table->prepare_items($listlanguages);
break;
case 'strings':
// get the strings to translate
$data = PLL_Admin_Strings::get_strings();
// get the groups
foreach ($data as $key => $row) {
$groups[] = $row['context'];
}
$groups = array_unique($groups);
$selected = empty($_GET['group']) || !in_array($_GET['group'], $groups) ? -1 : $_GET['group'];
$s = empty($_GET['s']) ? '' : wp_unslash($_GET['s']);
// filter for search string
foreach ($data as $key => $row) {
if (-1 != $selected && $row['context'] != $selected || !empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false) {
unset($data[$key]);
}
}
// load translations
foreach ($listlanguages as $language) {
// filters by language if requested
if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) {
continue;
}
$mo = new PLL_MO();
$mo->import_from_db($language);
foreach ($data as $key => $row) {
$data[$key]['translations'][$language->slug] = $mo->translate($row['string']);
$data[$key]['row'] = $key;
// store the row number for convenience
}
}
// get an array with language slugs as keys, names as values
$languages = array_combine(wp_list_pluck($listlanguages, 'slug'), wp_list_pluck($listlanguages, 'name'));
$string_table = new PLL_Table_String(compact('languages', 'groups', 'selected'));
$string_table->prepare_items($data);
break;
case 'settings':
$post_types = get_post_types(array('public' => true, '_builtin' => false));
$post_types = array_diff($post_types, get_post_types(array('_pll' => true)));
$post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true));
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
$taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true)));
$taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true));
break;
}
$action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
switch ($action) {
case 'add':
check_admin_referer('add-lang', '_wpnonce_add-lang');
if ($this->model->add_language($_POST) && 'en_US' != $_POST['locale']) {
// attempts to install the language pack
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
if (!wp_download_language_pack($_POST['locale'])) {
add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'));
}
// force checking for themes and plugins translations updates
wp_clean_themes_cache();
wp_clean_plugins_cache();
}
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'delete':
check_admin_referer('delete-lang');
if (!empty($_GET['lang'])) {
$this->model->delete_language((int) $_GET['lang']);
}
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'edit':
if (!empty($_GET['lang'])) {
$edit_lang = $this->model->get_language((int) $_GET['lang']);
}
break;
case 'update':
check_admin_referer('add-lang', '_wpnonce_add-lang');
$error = $this->model->update_language($_POST);
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'default-lang':
check_admin_referer('default-lang');
if ($lang = $this->model->get_language((int) $_GET['lang'])) {
//.........这里部分代码省略.........
开发者ID:britwayresources,项目名称:website,代码行数:101,代码来源:settings.php
示例4: wp_install_plugins
function wp_install_plugins($array)
{
require_once $this->data['dir'] . '/wp-admin/includes/class-wp-upgrader.php';
global $WPQI_Installer_Skin;
$WPQI_Installer_Skin();
foreach ($array as $name) {
if (!$name) {
continue;
}
$is_url = preg_match("/^(http|https):\\/\\//i", $name);
$url = $is_url ? $name : "https://downloads.wordpress.org/plugin/{$name}.zip";
$upgrader = new Plugin_Upgrader(new WPQI_Installer_Skin());
$upgrader->install($url);
activate_plugin($upgrader->plugin_info());
}
wp_clean_plugins_cache();
}
开发者ID:pravdomil,项目名称:WP-Quick-Install,代码行数:17,代码来源:wp-quick-install.php
示例5: update_translations
function update_translations()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// Clear the cache.
wp_clean_plugins_cache();
ob_start();
wp_update_plugins();
// Check for Plugin updates
ob_end_clean();
$available_updates = get_site_transient('update_plugins');
if (!isset($available_updates->translations) || empty($available_updates->translations)) {
return new WP_Error('nothing_to_translate');
}
$update_attempted = false;
$result = false;
foreach ($this->plugins as $plugin) {
$this->slug = Jetpack_Autoupdate::get_plugin_slug($plugin);
$translation = array_filter($available_updates->translations, array($this, 'get_translation'));
if (empty($translation)) {
$this->log[$plugin][] = __('No update needed', 'jetpack');
continue;
}
/**
* Pre-upgrade action
*
* @since 4.4
*
* @param array $plugin Plugin data
* @param array $plugin Array of plugin objects
* @param bool $updated_attempted false for the first update, true subsequently
*/
do_action('jetpack_pre_plugin_upgrade_translations', $plugin, $this->plugins, $update_attempted);
$update_attempted = true;
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader($skin);
$upgrader->init();
$result = $upgrader->upgrade((object) $translation[0]);
$this->log[$plugin] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result) {
return new WP_Error('update_fail', __('There was an error updating your plugin', 'jetpack'), 400);
}
return true;
}
开发者ID:automattic,项目名称:jetpack,代码行数:44,代码来源:class.jetpack-json-api-plugins-modify-endpoint.php
示例6: background_installer
/**
* Install a plugin from .org in the background via a cron job (used by
* installer - opt in).
* @param string $plugin_to_install_id
* @param array $plugin_to_install
* @since 2.6.0
*/
public static function background_installer($plugin_to_install_id, $plugin_to_install)
{
if (!empty($plugin_to_install['repo-slug'])) {
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
WP_Filesystem();
$skin = new Automatic_Upgrader_Skin();
$upgrader = new WP_Upgrader($skin);
$installed_plugins = array_map(array(__CLASS__, 'format_plugin_slug'), array_keys(get_plugins()));
$plugin_slug = $plugin_to_install['repo-slug'];
$plugin = $plugin_slug . '/' . $plugin_slug . '.php';
$installed = false;
$activate = false;
// See if the plugin is installed already
if (in_array($plugin_to_install['repo-slug'], $installed_plugins)) {
$installed = true;
$activate = !is_plugin_active($plugin);
}
// Install this thing!
if (!$installed) {
// Suppress feedback
ob_start();
try {
$plugin_information = plugins_api('plugin_information', array('slug' => $plugin_to_install['repo-slug'], 'fields' => array('short_description' => false, 'sections' => false, 'requires' => false, 'rating' => false, 'ratings' => false, 'downloaded' => false, 'last_updated' => false, 'added' => false, 'tags' => false, 'homepage' => false, 'donate_link' => false, 'author_profile' => false, 'author' => false)));
if (is_wp_error($plugin_information)) {
throw new Exception($plugin_information->get_error_message());
}
$package = $plugin_information->download_link;
$download = $upgrader->download_package($package);
if (is_wp_error($download)) {
throw new Exception($download->get_error_message());
}
$working_dir = $upgrader->unpack_package($download, true);
if (is_wp_error($working_dir)) {
throw new Exception($working_dir->get_error_message());
}
$result = $upgrader->install_package(array('source' => $working_dir, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'hook_extra' => array('type' => 'plugin', 'action' => 'install')));
if (is_wp_error($result)) {
throw new Exception($result->get_error_message());
}
$activate = true;
} catch (Exception $e) {
WC_Admin_Notices::add_custom_notice($plugin_to_install_id . '_install_error', sprintf(__('%1$s could not be installed (%2$s). <a href="%3$s">Please install it manually by clicking here.</a>', 'woocommerce'), $plugin_to_install['name'], $e->getMessage(), esc_url(admin_url('index.php?wc-install-plugin-redirect=' . $plugin_to_install['repo-slug']))));
}
// Discard feedback
ob_end_clean();
}
wp_clean_plugins_cache();
// Activate this thing
if ($activate) {
try {
$result = activate_plugin($plugin);
if (is_wp_error($result)) {
throw new Exception($result->get_error_message());
}
} catch (Exception $e) {
WC_Admin_Notices::add_custom_notice($plugin_to_install_id . '_install_error', sprintf(__('%1$s was installed but could not be activated. <a href="%2$s">Please activate it manually by clicking here.</a>', 'woocommerce'), $plugin_to_install['name'], admin_url('plugins.php')));
}
}
}
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:70,代码来源:class-wc-install.php
示例7: update
protected function update()
{
wp_clean_plugins_cache();
ob_start();
wp_update_plugins();
// Check for Plugin updates
ob_end_clean();
$update_plugins = get_site_transient('update_plugins');
if (isset($update_plugins->response)) {
$plugin_updates_needed = array_keys($update_plugins->response);
} else {
$plugin_updates_needed = array();
}
$update_attempted = false;
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// unhook this functions that output things before we send our response header.
remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
remove_action('upgrader_process_complete', 'wp_version_check');
remove_action('upgrader_process_complete', 'wp_update_themes');
$result = false;
foreach ($this->plugins as $plugin) {
if (!in_array($plugin, $plugin_updates_needed)) {
$this->log[$plugin][] = __('No update needed', 'jetpack');
continue;
}
/**
* Pre-upgrade action
*
* @since 3.9.3
*
* @param array $plugin Plugin data
* @param array $plugin Array of plugin objects
* @param bool $updated_attempted false for the first update, true subsequently
*/
do_action('jetpack_pre_plugin_upgrade', $plugin, $this->plugins, $update_attempted);
$update_attempted = true;
// Object created inside the for loop to clean the messages for each plugin
$skin = new Automatic_Upgrader_Skin();
// The Automatic_Upgrader_Skin skin shouldn't output anything.
$upgrader = new Plugin_Upgrader($skin);
$upgrader->init();
// This avoids the plugin to be deactivated.
defined('DOING_CRON') or define('DOING_CRON', true);
$result = $upgrader->upgrade($plugin);
$this->log[$plugin][] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result && $update_attempted) {
return new WP_Error('update_fail', __('There was an error updating your plugin', 'jetpack'), 400);
}
return $this->default_action();
}
开发者ID:kanei,项目名称:vantuch.cz,代码行数:51,代码来源:class.jetpack-json-api-plugins-modify-endpoint.php
示例8: wp_clean_update_cache
/**
* Clear existing update caches for plugins, themes, and core.
*
* @since 4.1.0
*/
function wp_clean_update_cache()
{
if (function_exists('wp_clean_plugins_cache')) {
wp_clean_plugins_cache();
} else {
delete_site_transient('update_plugins');
}
wp_clean_themes_cache();
delete_site_transient('update_core');
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:15,代码来源:update.php
示例9: handle_actions
/**
* Manages the user input for the languages pages
*
* @since 1.9
*
* @param string $action
*/
public function handle_actions($action)
{
switch ($action) {
case 'add':
check_admin_referer('add-lang', '_wpnonce_add-lang');
if ($this->model->add_language($_POST) && 'en_US' !== $_POST['locale']) {
// attempts to install the language pack
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
if (!wp_download_language_pack($_POST['locale'])) {
add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'));
}
// force checking for themes and plugins translations updates
wp_clean_themes_cache();
wp_clean_plugins_cache();
}
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'delete':
check_admin_referer('delete-lang');
if (!empty($_GET['lang'])) {
$this->model->delete_language((int) $_GET['lang']);
}
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'update':
check_admin_referer('add-lang', '_wpnonce_add-lang');
$error = $this->model->update_language($_POST);
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'default-lang':
check_admin_referer('default-lang');
if ($lang = $this->model->get_language((int) $_GET['lang'])) {
$this->model->update_default_lang($lang->slug);
}
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'content-default-lang':
check_admin_referer('content-default-lang');
if ($nolang = $this->model->get_objects_with_no_lang()) {
if (!empty($nolang['posts'])) {
$this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']);
}
if (!empty($nolang['terms'])) {
$this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']);
}
}
self::redirect();
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
break;
case 'activate':
check_admin_referer('pll_activate');
$this->modules[$_GET['module']]->activate();
self::redirect();
break;
case 'deactivate':
check_admin_referer('pll_deactivate');
$this->modules[$_GET['module']]->deactivate();
self::redirect();
break;
default:
/**
* Fires when a non default action has been sent to Polylang settings
*
* @since 1.8
*/
do_action("mlang_action_{$action}");
break;
}
}
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:80,代码来源:settings.php
示例10: update
protected function update()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// unhook this functions that output things before we send our response header.
remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
remove_action('upgrader_process_complete', 'wp_version_check');
remove_action('upgrader_process_complete', 'wp_update_themes');
foreach ($this->plugins as $plugin) {
wp_clean_plugins_cache();
ob_start();
wp_update_plugins();
// Check for Plugin updates
ob_end_clean();
// Object created inside the for loop to clean the messages for each plugin
$skin = new Automatic_Upgrader_Skin();
// The Automatic_Upgrader_Skin skin shouldn't output anything.
$upgrader = new Plugin_Upgrader($skin);
$upgrader->init();
$result = $upgrader->upgrade($plugin);
$this->log[$plugin][] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result) {
return new WP_Error('update_fail', __('There was an error updating your plugin', 'jetpack'), 400);
}
return $this->default_action();
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:26,代码来源:class.jetpack-json-api-plugins-modify-endpoint.php
示例11: install_bsf_product
function install_bsf_product($install_id)
{
global $bsf_product_validate_url, $bsf_support_url;
if (!current_user_can('install_plugins')) {
wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'bsf'));
}
$brainstrom_bundled_products = get_option('brainstrom_bundled_products') ? get_option('brainstrom_bundled_products') : array();
$install_product_data = array();
if (!empty($brainstrom_bundled_products)) {
foreach ($brainstrom_bundled_products as $keys => $products) {
if (strlen($keys) > 1) {
foreach ($products as $key => $product) {
if ($product->id === $install_id) {
$install_product_data = $product;
break;
}
}
} else {
if ($products->id === $install_id) {
$install_product_data = $products;
break;
}
}
}
}
if (empty($install_product_data)) {
return false;
}
if ($install_product_data->type !== 'plugin') {
return false;
}
/* temp */
/*$install_product_data->in_house = 'wp';
$install_product_data->download_url = 'https://downloads.wordpress.org/plugin/redux-framework.3.5.9.zip';*/
$is_wp = isset($install_product_data->in_house) && $install_product_data->in_house === 'wp' ? true : false;
if ($is_wp) {
$download_path = $install_product_data->download_url;
} else {
$path = $bsf_product_validate_url;
$timezone = date_default_timezone_get();
$call = 'file=' . $install_product_data->download_url . '&hashtime=' . strtotime(date('d-m-Y h:i:s a')) . '&timezone=' . $timezone;
$hash = $call;
//$parse = parse_url($path);
//$download = $parse['scheme'].'://'.$parse['host'];
$get_path = 'http://downloads.brainstormforce.com/';
$download_path = rtrim($get_path, '/') . '/download.php?' . $hash . '&base=ignore';
}
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
global $wp_filesystem;
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$WP_Upgrader = new WP_Upgrader();
$res = $WP_Upgrader->fs_connect(array(WP_CONTENT_DIR));
if (!$res) {
wp_die(new WP_Error('Server error', __("Error! Can't connect to filesystem", 'bsf')));
}
$Plugin_Upgrader = new Plugin_Upgrader();
$defaults = array('clear_update_cache' => true);
$args = array();
$parsed_args = wp_parse_args($args, $defaults);
$Plugin_Upgrader->init();
$Plugin_Upgrader->install_strings();
$Plugin_Upgrader->strings['downloading_package'] = __('Downloading package from Server', 'bsf');
$Plugin_Upgrader->strings['remove_old'] = __('Removing old plugin, if exists', 'bsf');
add_filter('upgrader_source_selection', array($Plugin_Upgrader, 'check_package'));
$Plugin_Upgrader->run(array('package' => $download_path, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('type' => 'plugin', 'action' => 'install')));
remove_filter('upgrader_source_selection', array($Plugin_Upgrader, 'check_package'));
if (!$Plugin_Upgrader->result || is_wp_error($Plugin_Upgrader->result)) {
return $Plugin_Upgrader->result;
}
// Force refresh of plugin update information
wp_clean_plugins_cache($parsed_args['clear_update_cache']);
//return true;
$response = array('status' => true, 'type' => 'plugin', 'name' => $install_product_data->name, 'init' => $install_product_data->init);
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $install_product_data->init;
if (is_file($plugin_abs_path)) {
if (!isset($_GET['action']) && !isset($_GET['id'])) {
echo '|bsf-plugin-installed|';
}
$is_plugin_installed = true;
if (!is_plugin_active($install_product_data->init)) {
activate_plugin($install_product_data->init);
if (is_plugin_active($install_product_data->init)) {
if (!isset($_GET['action']) && !isset($_GET['id'])) {
echo '|bsf-plugin-activated|';
}
}
} else {
if (!isset($_GET['action']) && !isset($_GET['id'])) {
echo '|bsf-plugin-activated|';
}
}
}
return $response;
}
开发者ID:ksan5835,项目名称:maadithottam,代码行数:95,代码来源:admin-functions.php
示例12: run
/**
* Performs the actual installation of each plugin.
*
* This method also activates the plugin in the automatic flag has been
* set to true for the TGMPA class.
*
* @since 2.2.0
*
* @param array $options The installation config options
* @return null/array Return early if error, array of installation data on success
*/
public function run($options)
{
// Default config options.
$defaults = array('package' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => true, 'is_multi' => false, 'hook_extra' => array());
// Parse default options with config options from $this->bulk_upgrade and extract them.
$options = wp_parse_args($options, $defaults);
extract($options);
// Connect to the Filesystem.
$res = $this->fs_connect(array(WP_CONTENT_DIR, $destination));
if (!$res) {
return false;
}
// Return early if there is an error connecting to the Filesystem.
if (is_wp_error($res)) {
$this->skin->error($res);
return $res;
}
// Call $this->header separately if running multiple times.
if (!$is_multi) {
$this->skin->header();
}
// Set strings before the package is installed.
$this->skin->before();
// Download the package (this just returns the filename of the file if the package is a local file).
$download = $this->download_package($package);
if (is_wp_error($download)) {
$this->skin->error($download);
$this->skin->after();
return $download;
}
// Don't accidentally delete a local file.
$delete_package = $download != $package;
// Unzip file into a temporary working directory.
$working_dir = $this->unpack_package($download, $delete_package);
if (is_wp_error($working_dir)) {
$this->skin->error($working_dir);
$this->skin->after();
return $working_dir;
}
// Install the package into the working directory with all passed config options.
$result = $this->install_package(array('source' => $working_dir, 'destination' => $destination, 'clear_destination' => $clear_destination, 'clear_working' => $clear_working, 'hook_extra' => $hook_extra));
// Pass the result of the installation.
$this->skin->set_result($result);
// Set correct strings based on results.
if (is_wp_error($result)) {
$this->skin->error($result);
$this->skin->feedback('process_failed');
} else {
$this->skin->feedback('process_success');
}
// Only process the activation of installed plugins if the automatic flag is set to true.
if (TGM_Plugin_Activation::$instance->is_automatic) {
// Flush plugins cache so we can make sure that the installed plugins list is always up to date.
wp_cache_flush();
// Get the installed plugin file and activate it.
$plugin_info = $this->plugin_info($package);
$activate = activate_plugin($plugin_info);
// Re-populate the file path now that the plugin has been installed and activated.
TGM_Plugin_Activation::$instance->populate_file_path();
// Set correct strings based on results.
if (is_wp_error($activate)) {
$this->skin->error($activate);
$this->skin->feedback('activation_failed');
} else {
$this->skin->feedback('activation_success');
}
}
// Flush plugins cache so we can make sure that the installed plugins list is always up to date.
if ($hook_extra['update']) {
// Force refresh of plugin update information
wp_clean_plugins_cache(true);
} else {
wp_cache_flush();
}
// Set install footer strings.
$this->skin->after();
if (!$is_multi) {
$this->skin->footer();
}
return $result;
}
开发者ID:severnrescue,项目名称:web,代码行数:92,代码来源:class-tgm-plugin-activation.php
示例13: upgrade_bsf_product
//.........这里部分代码省略.........
}
}
}
if ($bsf_username === '' || $purchase_key === '' || $request_product_id === '') {
if ($ajax) {
return __('Not valid to update product', 'bsf');
} else {
wp_die('Not valid to update product');
}
}
$path = $bsf_product_validate_url;
$data = array('action' => 'bsf_product_update_request', 'id' => $request_product_id, 'username' => $bsf_username, 'purchase_key' => $purchase_key, 'site_url' => get_site_url(), 'bundled' => $bundled_id);
$request = @wp_remote_post($path, array('body' => $data, 'timeout' => '60', 'sslverify' => false));
if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {
$result = json_decode($request['body']);
if (isset($result->error) && !$result->error) {
$download_path = $result->update_data->download_url;
$timezone = date_default_timezone_get();
$call = 'file=' . $download_path . '&hashtime=' . strtotime(date('d-m-Y h:i:s a')) . '&timezone=' . $timezone;
$hash = $call;
$parse = parse_url($path);
$download = $parse['scheme'] . '://' . $parse['host'];
$get_path = 'http://downloads.brainstormforce.com/';
$download_path = rtrim($get_path, '/') . '/download.php?' . $hash . '&base=ignore';
//echo $download_path;
//die();
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
global $wp_filesystem;
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$WP_Upgrader = new WP_Upgrader();
$res = $WP_Upgrader->fs_connect(array(WP_CONTENT_DIR));
if (!$res) {
wp_die(new WP_Error('Server error', __("Error! Can't connect to filesystem", 'bsf')));
} else {
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade_tmp/bsf_package';
$package_filename = basename($download_path);
$plugin_folder = dirname($template);
if ($type === 'theme' && $bundled_id === false) {
$defaults = array('clear_update_cache' => true);
$args = array();
$parsed_args = wp_parse_args($args, $defaults);
$Theme_Upgrader = new Theme_Upgrader();
$Theme_Upgrader->init();
$Theme_Upgrader->upgrade_strings();
$Theme_Upgrader->strings['downloading_package'] = __('Downloading package from Server', 'bsf');
add_filter('upgrader_pre_install', array(&$Theme_Upgrader, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array(&$Theme_Upgrader, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array(&$Theme_Upgrader, 'delete_old_theme'), 10, 4);
$Theme_Upgrader->run(array('package' => $download_path, 'destination' => get_theme_root($template), 'clear_destination' => true, 'abort_if_destination_exists' => false, 'clear_working' => true, 'hook_extra' => array('theme' => $template, 'type' => 'theme', 'action' => 'update')));
remove_filter('upgrader_pre_install', array(&$Theme_Upgrader, 'current_before'));
remove_filter('upgrader_post_install', array(&$Theme_Upgrader, 'current_after'));
remove_filter('upgrader_clear_destination', array(&$Theme_Upgrader, 'delete_old_theme'));
if (!$Theme_Upgrader->result || is_wp_error($Theme_Upgrader->result)) {
return $Theme_Upgrader->result;
}
wp_clean_themes_cache($parsed_args['clear_update_cache']);
$response = array('status' => true, 'type' => 'theme', 'name' => $name);
return $response;
} elseif ($type === 'plugin') {
$is_activated = is_plugin_active($template);
$Plugin_Upgrader = new Plugin_Upgrader();
$defaults = array('clear_update_cache' => true);
$Plugin_Upgrader->init();
$Plugin_Upgrader->upgrade_strings();
$Plugin_Upgrader->strings['downloading_package'] = __('Downloading package from Server', 'bsf');
add_filter('upgrader_pre_install', array($Plugin_Upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array($Plugin_Upgrader, 'delete_old_plugin'), 10, 4);
//'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
$Plugin_Upgrader->run(array('package' => $download_path, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $template, 'type' => 'plugin', 'action' => 'update')));
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter('upgrader_pre_install', array($Plugin_Upgrader, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array($Plugin_Upgrader, 'delete_old_plugin'));
if (!$Plugin_Upgrader->result || is_wp_error($Plugin_Upgrader->result)) {
return $Plugin_Upgrader->result;
}
// Force refresh of plugin update information
wp_clean_plugins_cache($defaults['clear_update_cache']);
if ($is_activated) {
activate_plugin($template);
}
$response = array('status' => true, 'type' => 'plugin', 'name' => $name);
return $response;
}
}
} else {
if ($ajax) {
return $result->message;
} else {
echo $result->message;
}
}
} else {
if ($ajax) {
return $request->get_error_message();
} else {
echo $request->get_error_message();
}
}
}
开发者ID:ksan5835,项目名称:maadithottam,代码行数:101,代码来源:admin-functions.php
示例14: activate_plugins
private function activate_plugins()
{
echo '<h3>' . esc_html__('Activating plugins...', '1and1-wordpress-wizard') . '</h3>';
require_once ABSPATH . '/wp-admin/includes/plugin.php';
wp_clean_plugins_cache(true);
$plugins = get_plugins();
$plugin_slugs = wp_list_pluck($this->plugins, 'slug');
foreach ($plugins as $key => $plugin) {
$parts = explode('/', $key);
if (in_array($parts[0], $plugin_slugs)) {
activate_plugin($key);
}
}
}
开发者ID:Ajoinsardegna,项目名称:wp,代码行数:14,代码来源:batch-installer.php
示例15: execute
//.........这里部分代码省略.........
} else {
// Verify authentication data
$authentication = (bool) $_GET['authentication'];
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
if ($authentication && (empty($username) || empty($password))) {
// Check if user has customer account saved
$customer_account = get_option('ig_customer_account', null);
if (is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password'])) {
$username = $customer_account['username'];
$password = $customer_account['password'];
} else {
throw new Exception(null);
}
}
// Try to authenticate or download addon installation package
try {
$package = self::download($addon, $authentication, $username, $password, 'authenticate' == $action);
} catch (Exception $e) {
throw $e;
}
// Get WordPress's WordPress Filesystem Abstraction object
$wp_filesystem = IG_Init_File_System::get_instance();
// Check if addon should be installed or updated
if ('authenticate' != $action) {
// Verify core and add-on compatibility
if (isset($_GET['core']) && ($core = self::get($_GET['core']))) {
// Extract downloaded add-on package
$tmp_dir = substr($package, 0, -4);
$result = unzip_file($package, $tmp_dir);
if (is_wp_error($result)) {
throw new Exception($result->get_error_message());
}
// Find constant definition file
if (@is_file("{$tmp_dir}/defines.php")) {
include "{$tmp_dir}/defines.php";
} elseif (count($defines = glob("{$tmp_dir}/*/defines.php"))) {
include current($defines);
}
// Get minimum core version required for this add-on
if (defined($core_version = strtoupper($addon) . '_CORE_VERSION')) {
eval('$core_version = ' . $core_version . ';');
}
if ($core_version && version_compare($core_version, $core['Version'], '>')) {
// Delete downloaded add-on package and clean-up temporary directory
$wp_filesystem->delete($package);
$wp_filesystem->delete($tmp_dir, true);
// Skip add-on installation
throw new Exception(sprintf(__("Cannot install %1\$s v%2\$s.\nThis version requires %3\$s v%4\$s while you are using %5\$s v%6\$s.", IG_LIBRARY_TEXTDOMAIN), $core['Addons'][$addon]->name, $core['Addons'][$addon]->version, $core['Name'], $core_version, $core['Name'], $core['Version']));
}
// Verification done, clean-up temporary directory
$wp_filesystem->delete($tmp_dir, true);
}
// Init WordPress Plugin Upgrader
class_exists('Plugin_Upgrader') || (include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
function_exists('screen_icon') || (include_once ABSPATH . 'wp-admin/includes/screen.php');
function_exists('show_message') || (include_once ABSPATH . 'wp-admin/includes/misc.php');
function_exists('get_plugin_data') || (include_once ABSPATH . 'wp-admin/includes/plugin.php');
// Either install or update add-on
$upgrader = new Plugin_Upgrader();
if ('install' == $action) {
// Install plugin
$result = $upgrader->install($package);
// Verify installation result
if (is_wp_error($result)) {
throw new Exception($result->get_error_message());
}
} else {
// Update plugin
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' => $package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' =>
|
请发表评论