本文整理汇总了PHP中wp_update_themes函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_update_themes函数的具体用法?PHP wp_update_themes怎么用?PHP wp_update_themes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_update_themes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_sync_update_themes
public function test_sync_update_themes()
{
wp_update_themes();
$this->client->do_sync();
$updates = $this->server_replica_storage->get_updates('themes');
$this->assertTrue(is_int($updates->last_checked));
}
示例2: _wprp_get_themes
/**
* Return an array of installed themes
*
* @return array
*/
function _wprp_get_themes()
{
require_once ABSPATH . '/wp-admin/includes/theme.php';
// Get all themes
$themes = get_themes();
// Get the list of active themes
$active = get_option('current_theme');
// Force a theme update check
wp_update_themes();
// Different versions of wp store the updates in different places
// TODO can we depreciate
if (function_exists('get_site_transient') && ($transient = get_site_transient('update_themes'))) {
$current = $transient;
} elseif ($transient = get_transient('update_themes')) {
$current = $transient;
} else {
$current = get_option('update_themes');
}
foreach ((array) $themes as $theme) {
$new_version = isset($current->response[$theme['Template']]) ? $current->response[$theme['Template']]['new_version'] : null;
if ($active == $theme['Name']) {
$themes[$theme['Name']]['active'] = true;
} else {
$themes[$theme['Name']]['active'] = false;
}
if ($new_version) {
$themes[$theme['Name']]['latest_version'] = $new_version;
$themes[$theme['Name']]['latest_package'] = $current->response[$theme['Template']]['package'];
} else {
$themes[$theme['Name']]['latest_version'] = $theme['Version'];
}
}
return $themes;
}
示例3: update
function update()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// Clear the cache.
wp_update_themes();
foreach ($this->themes as $theme) {
/**
* Pre-upgrade action
*
* @since 3.9.3
*
* @param object $theme WP_Theme object
* @param array $themes Array of theme objects
*/
do_action('jetpack_pre_theme_upgrade', $theme, $this->themes);
// Objects created inside the for loop to clean the messages for each theme
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Theme_Upgrader($skin);
$upgrader->init();
$result = $upgrader->upgrade($theme);
$this->log[$theme][] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result) {
return new WP_Error('update_fail', __('There was an error updating your theme', 'jetpack'), 400);
}
return true;
}
示例4: test_sync_update_themes
public function test_sync_update_themes()
{
if (is_multisite()) {
$this->markTestSkipped('Not compatible with multisite mode');
}
wp_update_themes();
$this->sender->do_sync();
$updates = $this->server_replica_storage->get_updates('themes');
$this->assertTrue(is_int($updates->last_checked));
}
示例5: wp_ajax_update_theme
/**
* AJAX handler for updating a theme.
*
* @since 4.X.0
*/
function wp_ajax_update_theme()
{
check_ajax_referer('updates');
if (empty($_POST['slug'])) {
wp_send_json_error(array('slug' => '', 'errorCode' => 'no_theme_specified', 'error' => __('No theme specified.')));
}
$stylesheet = sanitize_key($_POST['slug']);
$status = array('update' => 'theme', 'slug' => $stylesheet, 'oldVersion' => sprintf(__('Version %s'), wp_get_theme($stylesheet)->get('Version')), 'newVersion' => '');
if (!current_user_can('update_themes')) {
$status['error'] = __('You do not have sufficient permissions to update themes on this site.');
wp_send_json_error($status);
}
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$current = get_site_transient('update_themes');
if (empty($current)) {
wp_update_themes();
}
$upgrader = new Theme_Upgrader(new Automatic_Upgrader_Skin());
$result = $upgrader->bulk_upgrade(array($stylesheet));
if (defined('WP_DEBUG') && WP_DEBUG) {
$status['debug'] = $upgrader->skin->get_upgrade_messages();
}
if (is_array($result) && !empty($result[$stylesheet])) {
// Theme is already at the latest version.
if (true === $result[$stylesheet]) {
$status['error'] = $upgrader->strings['up_to_date'];
wp_send_json_error($status);
}
$theme = wp_get_theme($stylesheet);
if ($theme->get('Version')) {
$status['theme'] = wp_prepare_themes_for_js(array($theme));
$status['newVersion'] = sprintf(__('Version %s'), $theme->get('Version'));
}
wp_send_json_success($status);
} else {
if (is_wp_error($result)) {
$status['error'] = $result->get_error_message();
wp_send_json_error($status);
} else {
if (is_bool($result) && !$result) {
global $wp_filesystem;
$status['errorCode'] = 'unable_to_connect_to_filesystem';
$status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
// Pass through the error from WP_Filesystem if one was raised.
if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
$status['error'] = $wp_filesystem->errors->get_error_message();
}
wp_send_json_error($status);
}
}
}
// An unhandled error occurred.
$status['error'] = __('Update failed.');
wp_send_json_error($status);
}
示例6: _wprp_get_themes
/**
* Return an array of installed themes
*
* @return array
*/
function _wprp_get_themes()
{
require_once ABSPATH . '/wp-admin/includes/theme.php';
// Get all themes
if (function_exists('wp_get_themes')) {
$themes = wp_get_themes();
} else {
$themes = get_themes();
}
// Get the active theme
$active = get_option('current_theme');
// Delete the transient so wp_update_themes can get fresh data
if (function_exists('get_site_transient')) {
delete_site_transient('update_themes');
} else {
delete_transient('update_themes');
}
// Force a theme update check
wp_update_themes();
// Different versions of wp store the updates in different places
// TODO can we depreciate
if (function_exists('get_site_transient') && ($transient = get_site_transient('update_themes'))) {
$current = $transient;
} elseif ($transient = get_transient('update_themes')) {
$current = $transient;
} else {
$current = get_option('update_themes');
}
foreach ((array) $themes as $key => $theme) {
// WordPress 3.4+
if (is_object($theme) && is_a($theme, 'WP_Theme')) {
/* @var $theme WP_Theme */
$new_version = isset($current->response[$theme->get_stylesheet()]) ? $current->response[$theme->get_stylesheet()]['new_version'] : null;
$theme_array = array('Name' => $theme->get('Name'), 'active' => $active == $theme->get('Name'), 'Template' => $theme->get_template(), 'Stylesheet' => $theme->get_stylesheet(), 'Screenshot' => $theme->get_screenshot(), 'AuthorURI' => $theme->get('AuthorURI'), 'Author' => $theme->get('Author'), 'latest_version' => $new_version ? $new_version : $theme->get('Version'), 'Version' => $theme->get('Version'), 'ThemeURI' => $theme->get('ThemeURI'));
$themes[$key] = $theme_array;
} else {
$new_version = isset($current->response[$theme['Stylesheet']]) ? $current->response[$theme['Stylesheet']]['new_version'] : null;
if ($active == $theme['Name']) {
$themes[$key]['active'] = true;
} else {
$themes[$key]['active'] = false;
}
if ($new_version) {
$themes[$key]['latest_version'] = $new_version;
$themes[$key]['latest_package'] = $current->response[$theme['Template']]['package'];
} else {
$themes[$key]['latest_version'] = $theme['Version'];
}
}
}
return $themes;
}
示例7: wp_oracle_get_theme_updates
public function wp_oracle_get_theme_updates()
{
if (!function_exists('get_theme_updates')) {
require_once ABSPATH . 'wp-admin/includes/update.php';
}
// force refresh
wp_update_themes();
$updates = get_theme_updates();
if (empty($updates)) {
return array('blog' => array('themes' => 'no_updates'));
} else {
return $updates;
}
}
示例8: result
protected function result()
{
// pass an option to do it conditional;
wp_update_themes();
$update_data = wp_get_update_data();
if (!isset($update_data['counts'])) {
return new WP_Error('get_update_data_error', __('There was an error while getting the update data for this site.', 'jetpack'), 500);
}
$result = $update_data['counts'];
include ABSPATH . WPINC . '/version.php';
// $wp_version;
$result['wp_version'] = isset($wp_version) ? $wp_version : null;
$result['jp_version'] = JETPACK__VERSION;
return $result;
}
示例9: result
protected function result()
{
wp_update_themes();
wp_update_plugins();
$update_data = wp_get_update_data();
if (!isset($update_data['counts'])) {
return new WP_Error('get_update_data_error', __('There was an error while getting the update data for this site.', 'jetpack'), 500);
}
$result = $update_data['counts'];
include ABSPATH . WPINC . '/version.php';
// $wp_version;
$result['wp_version'] = isset($wp_version) ? $wp_version : null;
if (!empty($result['wordpress'])) {
$cur = get_preferred_from_update_core();
if (isset($cur->response) && $cur->response === 'upgrade') {
$result['wp_update_version'] = $cur->current;
}
}
$result['jp_version'] = JETPACK__VERSION;
return $result;
}
示例10: update_translations
function update_translations()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// Clear the cache.
wp_update_themes();
$available_themes_updates = get_site_transient('update_themes');
if (!isset($available_themes_updates->translations) || empty($available_themes_updates->translations)) {
return new WP_Error('nothing_to_translate');
}
foreach ($available_themes_updates->translations as $translation) {
$theme = $translation['slug'];
if (!in_array($translation['slug'], $this->themes)) {
$this->log[$theme][] = __('No update needed', 'jetpack');
continue;
}
/**
* Pre-upgrade action
*
* @since 4.4
*
* @param object $theme WP_Theme object
* @param array $themes Array of theme objects
*/
do_action('jetpack_pre_theme_upgrade_translations', $theme, $this->themes);
// Objects created inside the for loop to clean the messages for each theme
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader($skin);
$upgrader->init();
$result = $upgrader->upgrade((object) $translation);
$this->log[$theme] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result) {
return new WP_Error('update_fail', __('There was an error updating your theme', 'jetpack'), 400);
}
return true;
}
示例11: getSiteStats
//.........这里部分代码省略.........
$information['premium_updates'][$slug] = $informationPremiumUpdates[$i];
$information['premium_updates'][$slug]['update'] = (object) array('new_version' => $new_version, 'premium' => true, 'slug' => $slug);
if (!in_array($slug, $premiumUpdates)) {
$premiumUpdates[] = $slug;
}
}
MainWP_Helper::update_option('mainwp_premium_updates', $premiumUpdates);
}
remove_filter('default_option_active_plugins', array(&$this, 'default_option_active_plugins'));
remove_filter('option_active_plugins', array(&$this, 'default_option_active_plugins'));
if (null !== $this->filterFunction) {
add_filter('pre_site_transient_update_plugins', $this->filterFunction, 99);
}
global $wp_current_filter;
$wp_current_filter[] = 'load-plugins.php';
@wp_update_plugins();
include_once ABSPATH . '/wp-admin/includes/plugin.php';
$plugin_updates = get_plugin_updates();
if (is_array($plugin_updates)) {
$information['plugin_updates'] = array();
foreach ($plugin_updates as $slug => $plugin_update) {
if (in_array($plugin_update->Name, $premiumPlugins)) {
continue;
}
$information['plugin_updates'][$slug] = $plugin_update;
}
}
if (null !== $this->filterFunction) {
remove_filter('pre_site_transient_update_plugins', $this->filterFunction, 99);
}
if (null !== $this->filterFunction) {
add_filter('pre_site_transient_update_themes', $this->filterFunction, 99);
}
@wp_update_themes();
include_once ABSPATH . '/wp-admin/includes/theme.php';
$theme_updates = $this->upgrade_get_theme_updates();
if (is_array($theme_updates)) {
$information['theme_updates'] = array();
foreach ($theme_updates as $slug => $theme_update) {
$name = is_array($theme_update) ? $theme_update['Name'] : $theme_update->Name;
if (in_array($name, $premiumThemes)) {
continue;
}
$information['theme_updates'][$slug] = $theme_update;
}
}
if (null !== $this->filterFunction) {
remove_filter('pre_site_transient_update_themes', $this->filterFunction, 99);
}
$information['recent_comments'] = $this->get_recent_comments(array('approve', 'hold'), 5);
$information['recent_posts'] = $this->get_recent_posts(array('publish', 'draft', 'pending', 'trash'), 5);
$information['recent_pages'] = $this->get_recent_posts(array('publish', 'draft', 'pending', 'trash'), 5, 'page');
$securityIssuess = 0;
if (!MainWP_Security::prevent_listing_ok()) {
$securityIssuess++;
}
if (!MainWP_Security::remove_wp_version_ok()) {
$securityIssuess++;
}
if (!MainWP_Security::remove_rsd_ok()) {
$securityIssuess++;
}
if (!MainWP_Security::remove_wlw_ok()) {
$securityIssuess++;
}
// if (!MainWP_Security::remove_core_update_ok()) $securityIssuess++;
示例12: wp_version_check
$remote_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$remote_ip = $_SERVER['REMOTE_ADDR'];
}
// Check if the requesting server is allowed
if (!in_array($remote_ip, $allowed_ips)) {
echo "CRITICAL#IP {$remote_ip} not allowed.";
exit;
}
require_once 'wp-load.php';
global $wp_version;
$core_updates = FALSE;
$plugin_updates = FALSE;
wp_version_check();
wp_update_plugins();
wp_update_themes();
if (function_exists('get_transient')) {
$core = get_transient('update_core');
$plugins = get_transient('update_plugins');
$themes = get_transient('update_themes');
if ($core == FALSE) {
$core = get_site_transient('update_core');
$plugins = get_site_transient('update_plugins');
$themes = get_site_transient('update_themes');
}
} else {
$core = get_site_transient('update_core');
$plugins = get_site_transient('update_plugins');
$themes = get_site_transient('update_themes');
}
$core_available = FALSE;
示例13: perform_auto_updates
/**
* Kicks off a upgrade request for each item in the upgrade "queue"
*/
static function perform_auto_updates()
{
$lock_name = 'auto_upgrader.lock';
if (get_site_option($lock_name)) {
// Test to see if it was set more than an hour ago, if so, cleanup.
if (get_site_option($lock_name) < time() - HOUR_IN_SECONDS) {
delete_site_option($lock_name);
} else {
// The process is already locked
return;
}
}
// Lock upgrades for us for half an hour
if (!add_site_option($lock_name, microtime(true), HOUR_IN_SECONDS / 2)) {
return;
}
// Don't automatically run these thins, as we'll handle it ourselves
remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20, 3);
remove_action('upgrader_process_complete', 'wp_version_check');
remove_action('upgrader_process_complete', 'wp_update_plugins');
remove_action('upgrader_process_complete', 'wp_update_themes');
// Next, Plugins
wp_update_plugins();
// Check for Plugin updates
$plugin_updates = get_site_transient('update_plugins');
if ($plugin_updates && !empty($plugin_updates->response)) {
foreach (array_keys($plugin_updates->response) as $plugin) {
self::upgrade('plugin', $plugin);
}
// Force refresh of plugin update information
wp_clean_plugins_cache();
}
// Next, those themes we all love
wp_update_themes();
// Check for Theme updates
$theme_updates = get_site_transient('update_themes');
if ($theme_updates && !empty($theme_updates->response)) {
foreach (array_keys($theme_updates->response) as $theme) {
self::upgrade('theme', $theme);
}
// Force refresh of theme update information
wp_clean_themes_cache();
}
// Next, Process any core upgrade
wp_version_check();
// Check for Core updates
$core_update = find_core_auto_update();
if ($core_update) {
self::upgrade('core', $core_update);
delete_site_transient('update_core');
}
// Cleanup, and check for any pending translations
wp_version_check();
// check for Core updates
wp_update_themes();
// Check for Theme updates
wp_update_plugins();
// Check for Plugin updates
// Finally, Process any new translations
$language_updates = wp_get_translation_updates();
if ($language_updates) {
foreach ($language_updates as $update) {
self::upgrade('language', $update);
}
// Clear existing caches
wp_clean_plugins_cache();
wp_clean_themes_cache();
delete_site_transient('update_core');
wp_version_check();
// check for Core updates
wp_update_themes();
// Check for Theme updates
wp_update_plugins();
// Check for Plugin updates
}
/**
* Filter whether to email an update summary to the site administrator.
*
* @since 3.7.0
*
* @param bool Whether or not email should be sent to administrator. Default true.
* @param bool|array $core_update An array of core update data, false otherwise.
* @param object $theme_updates Object containing theme update properties.
* @param object $plugin_updates Object containing plugin update properties.
* @param array $language_updates Array containing the Language updates available.
* @param array $upgrade_results Array of the upgrade results keyed by upgrade type, and plugin/theme slug.
*/
if (apply_filters('enable_auto_upgrade_email', true, $core_update, $theme_updates, $plugin_updates, $language_updates, self::$upgrade_results)) {
self::send_email();
}
// Clear the lock
delete_site_option($lock_name);
}
示例14: upgrade_themes
public function upgrade_themes($themes = false)
{
if (!$themes || empty($themes)) {
return array('error' => 'No theme files for upgrade.');
}
$current = $this->mmb_get_transient('update_themes');
$versions = array();
if (!empty($current)) {
foreach ($themes as $theme) {
if (isset($current->checked[$theme])) {
$versions[$current->checked[$theme]] = $theme;
}
}
}
if (class_exists('Theme_Upgrader')) {
/** @handled class */
$upgrader = new Theme_Upgrader(mwp_container()->getUpdaterSkin());
$result = $upgrader->bulk_upgrade($themes);
if (!function_exists('wp_update_themes')) {
include_once ABSPATH . 'wp-includes/update.php';
}
@wp_update_themes();
$current = $this->mmb_get_transient('update_themes');
$return = array();
if (!empty($result)) {
foreach ($result as $theme_tmp => $theme_info) {
if (is_wp_error($theme_info) || empty($theme_info)) {
$return[$theme_tmp] = $this->mmb_get_error($theme_info);
} else {
if (!empty($result[$theme_tmp]) || isset($current->checked[$theme_tmp]) && version_compare(array_search($theme_tmp, $versions), $current->checked[$theme_tmp], '<') == true) {
$return[$theme_tmp] = 1;
} else {
$return[$theme_tmp] = 'Could not refresh upgrade transients, please reload website data';
}
}
}
return array('upgraded' => $return);
} else {
return array('error' => 'Upgrade failed.');
}
} else {
return array('error' => 'WordPress update required first');
}
}
示例15: upgrade_themes
function upgrade_themes($themes = false)
{
if (!$themes || empty($themes)) {
return array('error' => 'No theme files for upgrade.', 'error_code' => 'no_theme_files_for_upgrade');
}
$current = $this->iwp_mmb_get_transient('update_themes');
$versions = array();
if (!empty($current)) {
foreach ($themes as $theme) {
if (isset($current->checked[$theme])) {
$versions[$current->checked[$theme]] = $theme;
}
}
}
if (class_exists('Theme_Upgrader') && class_exists('Bulk_Theme_Upgrader_Skin')) {
$upgrader = new Theme_Upgrader(new Bulk_Theme_Upgrader_Skin(compact('title', 'nonce', 'url', 'theme')));
$result = $upgrader->bulk_upgrade($themes);
if (!function_exists('wp_update_themes')) {
include_once ABSPATH . 'wp-includes/update.php';
}
@wp_update_themes();
$current = $this->iwp_mmb_get_transient('update_themes');
$return = array();
if (!empty($result)) {
foreach ($result as $theme_tmp => $theme_info) {
if (is_wp_error($theme_info) || empty($theme_info)) {
$return[$theme_tmp] = array('error' => $this->iwp_mmb_get_error($theme_info), 'error_code' => 'upgrade_themes_wp_error');
} else {
if (!empty($result[$theme_tmp]) || isset($current->checked[$theme_tmp]) && version_compare(array_search($theme_tmp, $versions), $current->checked[$theme_tmp], '<') == true) {
$return[$theme_tmp] = 1;
} else {
update_option('iwp_client_forcerefresh', true);
$return[$theme_tmp] = array('error' => 'Could not refresh upgrade transients, please reload website data', 'error_code' => 'upgrade_themes_could_not_refresh_upgrade_transients_reload_website');
}
}
}
return array('upgraded' => $return);
} else {
return array('error' => 'Upgrade failed.', 'error_code' => 'upgrade_failed_upgrade_themes');
}
} else {
ob_end_clean();
return array('error' => 'WordPress update required first', 'error_code' => 'wordPress_update_required_first_upgrade_themes');
}
}