本文整理汇总了PHP中Theme_Upgrader类的典型用法代码示例。如果您正苦于以下问题:PHP Theme_Upgrader类的具体用法?PHP Theme_Upgrader怎么用?PHP Theme_Upgrader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Theme_Upgrader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: hooks_theme_install_or_update
/**
* @param Theme_Upgrader $upgrader
* @param array $extra
*/
public function hooks_theme_install_or_update($upgrader, $extra)
{
if (!isset($extra['type']) || 'theme' !== $extra['type']) {
return;
}
if ('install' === $extra['action']) {
$slug = $upgrader->theme_info();
if (!$slug) {
return;
}
wp_clean_themes_cache();
$theme = wp_get_theme($slug);
$name = $theme->name;
$version = $theme->version;
aal_insert_log(array('action' => 'installed', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
}
if ('update' === $extra['action']) {
if (isset($extra['bulk']) && true == $extra['bulk']) {
$slugs = $extra['themes'];
} else {
$slugs = array($upgrader->skin->theme);
}
foreach ($slugs as $slug) {
$theme = wp_get_theme($slug);
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
$theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
$name = $theme['Name'];
$version = $theme_data['Version'];
aal_insert_log(array('action' => 'updated', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
}
}
}
开发者ID:leogopal,项目名称:wordpress-aryo-activity-log,代码行数:36,代码来源:class-aal-hook-theme.php
示例2: 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;
}
开发者ID:automattic,项目名称:jetpack,代码行数:27,代码来源:class.jetpack-json-api-themes-modify-endpoint.php
示例3: install
protected function install()
{
foreach ($this->themes as $theme) {
$skin = new Jetpack_Automatic_Install_Skin();
$upgrader = new Theme_Upgrader($skin);
$link = $this->download_links[$theme];
$result = $upgrader->install($link);
if (file_exists($link)) {
// Delete if link was tmp local file
unlink($link);
}
if (!$this->bulk && is_wp_error($result)) {
return $result;
}
if (!$result) {
$error = $this->log[$theme]['error'] = __('An unknown error occurred during installation', 'jetpack');
} elseif (!self::is_installed_theme($theme)) {
$error = $this->log[$theme]['error'] = __('There was an error installing your theme', 'jetpack');
} else {
$this->log[$theme][] = $upgrader->skin->get_upgrade_messages();
}
}
if (!$this->bulk && isset($error)) {
return new WP_Error('install_error', $error, 400);
}
return true;
}
开发者ID:netmagik,项目名称:netmagik,代码行数:27,代码来源:class.jetpack-json-api-themes-install-endpoint.php
示例4: bruteprotect_bulk_update_themes
/**
* Updates the given list of themes.
*
* Accepts an array of theme slugs such as 'twentyfourteen'
* Returns a detailed array showing the status of each theme and a log of messages output during the process
*
* @param array $themes
* @return array
*/
function bruteprotect_bulk_update_themes($themes)
{
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Theme_Upgrader($skin);
$results = $upgrader->bulk_upgrade($themes);
$messages = $upgrader->skin->get_upgrade_messages();
$o['results'] = $results;
$o['messages'] = $messages;
return $o;
}
开发者ID:jeremylightsmith,项目名称:blog,代码行数:19,代码来源:update.php
示例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);
}
开发者ID:ethitter,项目名称:shiny-updates,代码行数:60,代码来源:ajax-actions.php
示例6: install
protected function install()
{
foreach ($this->themes as $theme) {
/**
* Filters whether to use an alternative process for installing a WordPress.com theme.
* The alternative process can be executed during the filter.
*
* The filter can also return an instance of WP_Error; in which case the endpoint response will
* contain this error.
*
* @module json-api
*
* @since 4.4.2
*
* @param bool $use_alternative_install_method Whether to use the alternative method of installing
* a WPCom theme.
* @param string $theme_slug Theme name (slug). If it is a WPCom theme,
* it should be suffixed with `-wpcom`.
*/
$result = apply_filters('jetpack_wpcom_theme_install', false, $theme);
$skin = null;
$upgrader = null;
$link = null;
// If the alternative install method was not used, use the standard method.
if (!$result) {
$skin = new Jetpack_Automatic_Install_Skin();
$upgrader = new Theme_Upgrader($skin);
$link = $this->download_links[$theme];
$result = $upgrader->install($link);
}
if (file_exists($link)) {
// Delete if link was tmp local file
unlink($link);
}
if (!$this->bulk && is_wp_error($result)) {
return $result;
}
if (!$result) {
$error = $this->log[$theme]['error'] = __('An unknown error occurred during installation', 'jetpack');
} elseif (!self::is_installed_theme($theme)) {
$error = $this->log[$theme]['error'] = __('There was an error installing your theme', 'jetpack');
} elseif ($upgrader) {
$this->log[$theme][] = $upgrader->skin->get_upgrade_messages();
}
}
if (!$this->bulk && isset($error)) {
return new WP_Error('install_error', $error, 400);
}
return true;
}
开发者ID:automattic,项目名称:jetpack,代码行数:50,代码来源:class.jetpack-json-api-themes-install-endpoint.php
示例7: install
function install()
{
$args = $this->input();
if (isset($args['zip'][0]['id'])) {
$attachment_id = $args['zip'][0]['id'];
$local_file = get_attached_file($attachment_id);
if (!$local_file) {
return new WP_Error('local-file-does-not-exist');
}
$skin = new Jetpack_Automatic_Install_Skin();
$upgrader = new Theme_Upgrader($skin);
$pre_install_list = wp_get_themes();
$result = $upgrader->install($local_file);
// clean up.
wp_delete_attachment($attachment_id, true);
if (is_wp_error($result)) {
return $result;
}
$after_install_list = wp_get_themes();
$plugin = array_values(array_diff(array_keys($after_install_list), array_keys($pre_install_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('theme_already_installed');
}
$this->themes = $plugin;
$this->log[$plugin[0]] = $upgrader->skin->get_upgrade_messages();
return true;
}
return new WP_Error('no_theme_installed');
}
开发者ID:automattic,项目名称:jetpack,代码行数:40,代码来源:class.jetpack-json-api-themes-new-endpoint.php
示例8: autoupdater_refresh_theme
/**
* Refresh families from meteor function
*/
function autoupdater_refresh_theme()
{
// refresh WordPress information of new theme versions
get_transient('update_themes');
global $wp_version, $theme_version, $theme_to_update, $api_url;
log_me('checking the update and stuff...');
if (function_exists('wp_get_theme')) {
$theme_data = wp_get_theme($theme_to_update);
$theme_version = $theme_data->Version;
} else {
$theme_data = get_theme_data(ABSPATH . '/wp-content/themes/' . $theme_to_update . '/style.css');
$theme_version = $theme_data['Version'];
}
$request = array('slug' => $theme_to_update, 'version' => $theme_version);
// Start checking for an update
$send_for_check = array('body' => array('action' => 'theme_update', 'request' => serialize($request), 'api-key' => md5(get_bloginfo('url'))), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'));
$raw_response = wp_remote_post($api_url, $send_for_check);
if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200) {
$response = unserialize($raw_response['body']);
}
// check if the new version is higher
// if (version_compare($theme_version, $response['new_version']))
if (version_compare($theme_version, $response['new_version'], '<')) {
require ABSPATH . 'wp-admin/includes/screen.php';
require ABSPATH . 'wp-admin/includes/plugin.php';
require ABSPATH . 'wp-admin/includes/template.php';
require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require ABSPATH . 'wp-admin/includes/file.php';
require ABSPATH . 'wp-admin/includes/misc.php';
$theme = $theme_to_update;
$title = __('Update Theme');
$parent_file = 'themes.php';
$submenu_file = 'themes.php';
// require_once(ABSPATH . 'wp-admin/admin-header.php');
$nonce = 'upgrade-theme_' . $theme_to_update;
$url = 'update.php?action=upgrade-theme&theme=' . urlencode($theme_to_update);
$upgrader = new Theme_Upgrader(new Theme_Upgrader_Skin(compact('title', 'nonce', 'url', 'theme')));
$upgrader->upgrade($theme_to_update);
}
}
开发者ID:pemiu01,项目名称:autoupdater,代码行数:43,代码来源:autoupdater.php
示例9: puma_theme_update_callback
function puma_theme_update_callback()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$update_data = array('theme_version' => get_transient('puma_latest'), 'update_link' => 'https://github.com/bigfa/Puma/archive/master.zip');
$name = "Puma";
$slug = "Puma";
$version = $update_data['theme_version'];
$download_link = $update_data['update_link'];
delete_site_transient('update_themes');
$themes = wp_get_themes();
$current = (object) array("last_checked" => time(), "checked" => array(), "response" => array(), "translations" => array());
foreach ($themes as $theme) {
$current->checked[$theme->get('Slug')] = $theme->get('Version');
}
$current->response[$slug] = array('theme' => $slug, 'new_version' => $version, 'url' => '', 'package' => $download_link);
set_site_transient('update_themes', $current);
$title = __('Update Theme');
$nonce = 'upgrade-theme_' . $slug;
$url = 'update.php?action=upgrade-theme&theme=' . urlencode($slug);
$upgrader = new Theme_Upgrader(new Theme_Upgrader_Skin(compact('title', 'nonce', 'url', 'theme')));
$upgrader->upgrade($slug);
exit;
}
开发者ID:bigfa,项目名称:Puma,代码行数:23,代码来源:update.php
示例10: _wprp_upgrade_theme
/**
* Update a theme
*
* @param mixed $theme
* @return array
*/
function _wprp_upgrade_theme($theme)
{
include_once ABSPATH . 'wp-admin/includes/admin.php';
if (!_wprp_supports_theme_upgrade()) {
return array('status' => 'error', 'error' => 'WordPress version too old for theme upgrades');
}
$skin = new WPRP_Theme_Upgrader_Skin();
$upgrader = new Theme_Upgrader($skin);
// Do the upgrade
ob_start();
$result = $upgrader->upgrade($theme);
$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);
}
return array('status' => 'success');
}
开发者ID:redferriswheel,项目名称:ZachFonville,代码行数:29,代码来源:wprp.themes.php
示例11: upgrade_bsf_product
function upgrade_bsf_product($request_product_id, $bundled_id)
{
global $bsf_product_validate_url, $bsf_support_url;
if (!current_user_can('update_plugins')) {
wp_die(__('You do not have sufficient permissions to update plugins for this site.', 'bsf'));
}
$brainstrom_users = get_option('brainstrom_users') ? get_option('brainstrom_users') : array();
$brainstrom_products = get_option('brainstrom_products') ? get_option('brainstrom_products') : array();
$brainstrom_bundled_products = get_option('brainstrom_bundled_products') ? get_option('brainstrom_bundled_products') : array();
$plugins = $themes = $mix = array();
if (!empty($brainstrom_products)) {
$plugins = isset($brainstrom_products['plugins']) ? $brainstrom_products['plugins'] : array();
$themes = isset($brainstrom_products['themes']) ? $brainstrom_products['themes'] : array();
}
$mix = array_merge($plugins, $themes);
$bsf_username = $purchase_key = $type = $template = $name = '';
if (!empty($brainstrom_users)) {
foreach ($brainstrom_users as $bsf_user) {
$bsf_username = $bsf_user['email'];
}
}
$found_in_bsf_products = false;
if ($bundled_id !== false) {
$product_details_id = $bundled_id;
} else {
$product_details_id = $request_product_id;
}
foreach ($mix as $key => $product) {
$pid = $product['id'];
if ($pid === $product_details_id) {
$purchase_key = $product['purchase_key'];
$type = $product['type'];
$template = $product['template'];
$name = $product['product_name'];
$found_in_bsf_products = true;
break;
}
}
if ($bundled_id !== false) {
if (!empty($brainstrom_bundled_products)) {
foreach ($brainstrom_bundled_products as $bp) {
if ($bp->id === $request_product_id) {
$type = $bp->type;
$template = $bp->init;
$name = $bp->name;
}
}
}
}
if ($bsf_username === '' || $purchase_key === '' || $request_product_id === '') {
wp_die('Not valid to update product');
}
$path = base64_decode($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 = base64_encode($call);
$parse = parse_url($path);
$download = $parse['scheme'] . '://' . $parse['host'];
$get_path = 'http://downloads.brainstormforce.com/';
$download_path = rtrim($get_path, '/') . '/download.php?hash=' . $hash;
//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' => false, '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);
//.........这里部分代码省略.........
开发者ID:jfitzsimmons,项目名称:soundtrackforspace,代码行数:101,代码来源:admin-functions.php
示例12: install_theme
static function install_theme()
{
check_ajax_referer(self::AJAX_NONCE, 'nonce');
$theme_id = $_REQUEST['themeId'];
$theme = wp_get_theme($theme_id);
if (!$theme->exists()) {
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/theme-install.php';
$theme_info = themes_api('theme_information', array('slug' => $theme_id, 'fields' => array('sections' => false, 'tags' => false)));
error_log(print_r($theme_info, true));
if (is_wp_error($theme_info)) {
wp_send_json_error('Could not look up theme ' . $theme_id . ': ' . $theme_info->get_error_message());
die;
} else {
$upgrader = new Theme_Upgrader(new Automatic_Upgrader_Skin());
$install_response = $upgrader->install($theme_info->download_link);
if (is_wp_error($install_response)) {
wp_send_json_error('Could not install theme: ' . $install_response->get_error_message());
die;
} elseif (!$install_response) {
wp_send_json_error('Could not install theme (unspecified server error)');
die;
}
}
}
wp_send_json_success($theme_id);
}
开发者ID:hyperhy,项目名称:hyperhy,代码行数:27,代码来源:class.jetpack-start-end-points.php
示例13: theme_action
function theme_action()
{
//Read form data
$action = $_POST['action'];
$theme = $_POST['theme'];
if ('activate' === $action) {
include_once ABSPATH . '/wp-admin/includes/theme.php';
$theTheme = get_theme($theme);
if (null !== $theTheme && '' !== $theTheme) {
switch_theme($theTheme['Template'], $theTheme['Stylesheet']);
}
} else {
if ('delete' === $action) {
include_once ABSPATH . '/wp-admin/includes/theme.php';
// if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php');
if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
include_once ABSPATH . '/wp-admin/includes/screen.php';
}
include_once ABSPATH . '/wp-admin/includes/file.php';
include_once ABSPATH . '/wp-admin/includes/template.php';
include_once ABSPATH . '/wp-admin/includes/misc.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
$wp_filesystem = $this->getWPFilesystem();
if (empty($wp_filesystem)) {
$wp_filesystem = new WP_Filesystem_Direct(null);
}
$themeUpgrader = new Theme_Upgrader();
$theme_name = wp_get_theme()->get('Name');
$themes = explode('||', $theme);
foreach ($themes as $idx => $themeToDelete) {
if ($themeToDelete !== $theme_name) {
$theTheme = get_theme($themeToDelete);
if (null !== $theTheme && '' !== $theTheme) {
$tmp['theme'] = $theTheme['Template'];
if (true === $themeUpgrader->delete_old_theme(null, null, null, $tmp)) {
$args = array('action' => 'delete', 'Name' => $theTheme['Name']);
do_action('mainwp_child_theme_action', $args);
}
}
}
}
} else {
$information['status'] = 'FAIL';
}
}
if (!isset($information['status'])) {
$information['status'] = 'SUCCESS';
}
$information['sync'] = $this->getSiteStats(array(), false);
MainWP_Helper::write($information);
}
开发者ID:jexmex,项目名称:mainwp-child,代码行数:53,代码来源:class-mainwp-child.php
示例14: theme_install_or_update
/**
* Theme install of update
*
* @since 0.1.0
*
* @param Theme_Upgrader $upgrader
* @param array $extra
*/
public function theme_install_or_update($upgrader, $extra)
{
// Bail if not a theme
if (!isset($extra['type']) || 'theme' !== $extra['type']) {
return;
}
// Install
if ('install' === $extra['action']) {
// Bail if no theme found
$slug = $upgrader->theme_info();
if (empty($slug)) {
return;
}
wp_clean_themes_cache();
$theme = wp_get_theme($slug);
$name = $theme->name;
$version = $theme->version;
// Insert activity
wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $version, 'object_name' => $name, 'action' => 'install'));
// Update
} elseif ('update' === $extra['action']) {
// Get theme slugs
if (isset($extra['bulk']) && true == $extra['bulk']) {
$slugs = $extra['themes'];
} else {
$slugs = array($upgrader->skin->theme);
}
// Activity for each theme
foreach ($slugs as $slug) {
$theme = wp_get_theme($slug);
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
$theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
$name = $theme['Name'];
$version = $theme_data['Version'];
// Insert activity
wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $version, 'object_name' => $name, 'action' => 'update'));
}
}
}
开发者ID:wir,项目名称:wp-user-activity,代码行数:47,代码来源:class-action-themes.php
示例15: _update_theme
private function _update_theme($theme)
{
global $wp_filesystem;
$status = array('update' => 'theme', 'theme' => $theme, 'oldVersion' => '', 'newVersion' => '');
if (false !== strpos($theme, '/') || false !== strpos($theme, '\\')) {
$status['error'] = 'not_found';
return $status;
}
$theme_version = $this->get_theme_version($theme);
if (false === $theme_version) {
$status['error'] = 'not_found';
return $status;
}
$status['oldVersion'] = $theme_version;
if (!current_user_can('update_themes')) {
$status['error'] = 'updates_permission_denied';
return $status;
}
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
wp_update_themes();
// WP < 3.7
if (!class_exists('Automatic_Upgrader_Skin')) {
require_once UPDRAFTPLUS_DIR . '/central/classes/class-automatic-upgrader-skin.php';
}
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Theme_Upgrader($skin);
$upgrader->init();
$result = $upgrader->bulk_upgrade(array($theme));
if (is_array($result) && empty($result[$theme]) && is_wp_error($skin->result)) {
$result = $skin->result;
}
$status['messages'] = $upgrader->skin->get_upgrade_messages();
if (is_array($result) && !empty($result[$theme])) {
$theme_update_data = current($result);
/*
* If the `update_themes` site transient is empty (e.g. when you update
* two plugins in quick succession before the transient repopulates),
* this may be the return.
*
* Preferably something can be done to ensure `update_themes` isn't empty.
* For now, surface some sort of error here.
*/
if ($theme_update_data === true) {
$status['error'] = 'update_failed';
return $status;
}
$new_theme_version = $this->get_theme_version($theme);
if (false === $new_theme_version) {
$status['error'] = 'update_failed';
return $status;
}
$status['newVersion'] = $new_theme_version;
return $status;
} else {
if (is_wp_error($result)) {
$status['error'] = $result->get_error_code();
$status['error_message'] = $result->get_error_message();
return $status;
} else {
if (is_bool($result) && !$result) {
$status['error'] = 'unable_to_connect_to_filesystem';
// Pass through the error from WP_Filesystem if one was raised
if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
$status['error'] = $wp_filesystem->errors->get_error_code();
$status['error_message'] = $wp_filesystem->errors->get_error_message();
}
return $status;
} else {
// An unhandled error occured
$status['error'] = 'update_failed';
return $status;
}
}
}
}
开发者ID:aaronfrey,项目名称:PepperLillie-Cambridge,代码行数:75,代码来源:updates.php
示例16: do_bulk_upgrade
private function do_bulk_upgrade($packages, $type)
{
if (!in_array($type, array('plugin', 'theme'))) {
return new WP_Error('unrecognized-bulk-upgrade-type', "An unrecognized type ({$type}) was passed to do_bulk_upgrade().");
}
Ithemes_Sync_Functions::set_time_limit(300);
$original_versions = array();
foreach ($packages as $package) {
if ('plugin' === $type) {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_PLUGIN_DIR . "/{$package}");
} else {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_CONTENT_DIR . "/themes/{$package}/style.css");
}
$original_versions[$package] = $file_data['version'];
}
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/misc.php';
if ('plugin' === $type) {
$upgrader = new Plugin_Upgrader($this->skin);
$result = $upgrader->bulk_upgrade($packages);
Ithemes_Sync_Functions::refresh_plugin_updates();
} else {
$upgrader = new Theme_Upgrader($this->skin);
$result = $upgrader->bulk_upgrade($packages);
Ithemes_Sync_Functions::refresh_theme_updates();
}
if (is_wp_error($result)) {
return array('errors' => array($result->get_error_code() => $result->get_error_message()));
} else {
if (false === $result) {
if ('plugin' === $type) {
$result = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR));
} else {
$result = $upgrader->fs_connect(array(WP_CONTENT_DIR));
}
if (is_wp_error($result)) {
return array('errors' => array($result->get_error_code() => $result->get_error_message()));
} else {
return array('errors' => array('non-connected-filesystem' => 'Unable to update due to a non-connected filesystem.'));
}
}
}
$update_details = Ithemes_Sync_Functions::get_update_details(array('verbose' => true));
$response = array();
$update_index = "{$type}s";
foreach ($result as $package => $info) {
if (false === $info) {
$response[$package]['errors']['non-connected-filesystem'] = 'Unable to update due to a non-connected filesystem.';
} else {
if (is_wp_error($info)) {
$response[$package]['errors'][$info->get_error_code()] = $info->get_error_message();
} else {
$response[$package]['wordpress_response'] = $info;
if ('plugin' === $type) {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_PLUGIN_DIR . "/{$package}");
} else {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_CONTENT_DIR . "/themes/{$package}/style.css");
}
$response[$package]['current_version'] = $file_data['version'];
if (isset($original_versions[$package])) {
$response[$package]['original_version'] = $original_versions[$package];
}
if (isset($update_details[$update_index][$package])) {
if ('plugin' === $type && isset($update_details[$update_index][$package]->new_version)) {
$response[$package]['current_update_version'] = $update_details[$update_index][$package]->new_version;
} else {
if ('theme' === $type && isset($update_details[$update_index][$package]['new_version'])) {
$response[$package]['current_update_version'] = $update_details[$update_index][$package]['new_version'];
}
}
}
if (isset($this->original_update_details[$update_index][$package])) {
if ('plugin' === $type && isset($this->original_update_details[$update_index][$package]->new_version)) {
$response[$package]['original_update_version'] = $this->original_update_details[$update_index][$package]->new_version;
} else {
if ('theme' === $type && isset($this->original_update_details[$update_index][$package]['new_version'])) {
$response[$package]['original_update_version'] = $this->original_update_details[$update_index][$package]['new_version'];
}
}
}
if ('plugin' === $type) {
$removed_old_update_data = $GLOBALS['ithemes_sync_request_handler']->remove_old_update_plugins_data($package);
if (!is_null($removed_old_update_data)) {
$response[$package]['removed_old_update_data'] = $removed_old_update_data;
}
}
if (!isset($response[$package]['original_update_version'])) {
$response[$package]['errors']['no-update'] = 'No update was available.';
} else {
if (version_compare($response[$package]['current_version'], $response[$package]['original_update_version'], '>=')) {
$response[$package]['success'] = 1;
if (isset($response[$package]['current_update_version'])) {
if (version_compare($response[$package]['current_version'], $response[$package]['current_update_version'], '>=')) {
$response[$package]['errors']['old-update-remains-available'] = 'The original update is still listed despite the update working properly.';
} else {
$response[$package]['errors']['new-update-available'] = 'An update is available.';
}
}
} else {
//.........这里部分代码省略.........
开发者ID:jimlongo56,项目名称:rdiv,代码行数:101,代码来源:do-update.php
示例17: 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');
}
}
开发者ID:Trideon,项目名称:gigolo,代码行数:45,代码来源:installer.class.php
示例18: wp_install_themes
function wp_install_themes($array)
{
require_once $this->data['dir'] . '/wp-admin/includes/class-wp-upgrader.php';
global $WPQI_Installer_Skin;
$WPQI_Installer_Skin();
$first = true;
foreach ($array as $name) {
if (!$name) {
|
请发表评论