- return $source;
- }
-
- function current_before($return, $theme) {
-
- if ( is_wp_error($return) )
- return $return;
-
- $theme = isset($theme['theme']) ? $theme['theme'] : '';
-
- if ( $theme != get_stylesheet() ) //If not current
- return $return;
- //Change to maintenance mode now.
- if ( ! $this->bulk )
- $this->maintenance_mode(true);
-
- return $return;
- }
-
- function current_after($return, $theme) {
- if ( is_wp_error($return) )
- return $return;
-
- $theme = isset($theme['theme']) ? $theme['theme'] : '';
-
- if ( $theme != get_stylesheet() ) // If not current
- return $return;
-
- // Ensure stylesheet name hasnt changed after the upgrade:
- // @TODO: Note, This doesn't handle the Template changing, or the Template name changing.
- if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
- $theme_info = $this->theme_info();
- $stylesheet = $this->result['destination_name'];
- $template = $theme_info->get_template();
- switch_theme($template, $stylesheet, true);
- }
-
- //Time to remove maintenance mode
- if ( ! $this->bulk )
- $this->maintenance_mode(false);
- return $return;
- }
-
- function delete_old_theme($removed, $local_destination, $remote_destination, $theme) {
- global $wp_filesystem;
-
- $theme = isset($theme['theme']) ? $theme['theme'] : '';
-
- if ( is_wp_error($removed) || empty($theme) )
- return $removed; //Pass errors through.
-
- $themes_dir = $wp_filesystem->wp_themes_dir();
- if ( $wp_filesystem->exists( trailingslashit($themes_dir) . $theme ) )
- if ( ! $wp_filesystem->delete( trailingslashit($themes_dir) . $theme, true ) )
- return false;
- return true;
- }
-
- function theme_info($theme = null) {
-
- if ( empty($theme) ) {
- if ( !empty($this->result['destination_name']) )
- $theme = $this->result['destination_name'];
- else
- return false;
- }
- return wp_get_theme( $theme, WP_CONTENT_DIR . '/themes/' );
- }
-
-}
-
-/**
- * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combination with the wp-admin/includes/update-core.php file
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class Core_Upgrader extends WP_Upgrader {
-
- function upgrade_strings() {
- $this->strings['up_to_date'] = __('WordPress is at the latest version.');
- $this->strings['no_package'] = __('Update package not available.');
- $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…');
- $this->strings['unpack_package'] = __('Unpacking the update…');
- $this->strings['copy_failed'] = __('Could not copy files.');
- $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.' );
- }
-
- function upgrade($current) {
- global $wp_filesystem, $wp_version;
-
- $this->init();
- $this->upgrade_strings();
-
- if ( !empty($feedback) )
- add_filter('update_feedback', $feedback);
-
- // Is an update available?
- if ( !isset( $current->response ) || $current->response == 'latest' )
- return new WP_Error('up_to_date', $this->strings['up_to_date']);
-
- $res = $this->fs_connect( array(ABSPATH, WP_CONTENT_DIR) );
- if ( is_wp_error($res) )
- return $res;
-
- $wp_dir = trailingslashit($wp_filesystem->abspath());
-
- // If partial update is returned from the API, use that, unless we're doing a reinstall.
- // If we cross the new_bundled version number, then use the new_bundled zip.
- // Don't though if the constant is set to skip bundled items.
- // If the API returns a no_content zip, go with it. Finally, default to the full zip.
- if ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version )
- $to_download = 'partial';
- elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
- && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) )
- $to_download = 'new_bundled';
- elseif ( $current->packages->no_content )
- $to_download = 'no_content';
- else
- $to_download = 'full';
-
- $download = $this->download_package( $current->packages->$to_download );
- if ( is_wp_error($download) )
- return $download;
-
- $working_dir = $this->unpack_package( $download );
- if ( is_wp_error($working_dir) )
- return $working_dir;
-
- // Copy update-core.php from the new version into place.
- if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
- $wp_filesystem->delete($working_dir, true);
- return new WP_Error('copy_failed', $this->strings['copy_failed']);
- }
- $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
-
- require(ABSPATH . 'wp-admin/includes/update-core.php');
-
- if ( ! function_exists( 'update_core' ) )
- return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] );
-
- return update_core($working_dir, $wp_dir);
- }
-
-}
-
-/**
- * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class WP_Upgrader_Skin {
-
- var $upgrader;
- var $done_header = false;
- var $result = false;
-
- function __construct($args = array()) {
- $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
- $this->options = wp_parse_args($args, $defaults);
- }
-
- function set_upgrader(&$upgrader) {
- if ( is_object($upgrader) )
- $this->upgrader =& $upgrader;
- $this->add_strings();
- }
-
- function add_strings() {
- }
-
- function set_result($result) {
- $this->result = $result;
- }
-
- function request_filesystem_credentials($error = false) {
- $url = $this->options['url'];
- $context = $this->options['context'];
- if ( !empty($this->options['nonce']) )
- $url = wp_nonce_url($url, $this->options['nonce']);
- return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
- }
-
- function header() {
- if ( $this->done_header )
- return;
- $this->done_header = true;
- echo '<div class="wrap">';
- echo screen_icon();
- echo '<h2>' . $this->options['title'] . '</h2>';
- }
- function footer() {
- echo '</div>';
- }
-
- function error($errors) {
- if ( ! $this->done_header )
- $this->header();
- if ( is_string($errors) ) {
- $this->feedback($errors);
- } elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
- foreach ( $errors->get_error_messages() as $message ) {
- if ( $errors->get_error_data() )
- $this->feedback($message . ' ' . $errors->get_error_data() );
- else
- $this->feedback($message);
- }
- }
- }
-
- function feedback($string) {
- if ( isset( $this->upgrader->strings[$string] ) )
- $string = $this->upgrader->strings[$string];
-
- if ( strpos($string, '%') !== false ) {
- $args = func_get_args();
- $args = array_splice($args, 1);
- if ( !empty($args) )
- $string = vsprintf($string, $args);
- }
- if ( empty($string) )
- return;
- show_message($string);
- }
- function before() {}
- function after() {}
-
-}
-
-/**
- * Plugin Upgrader Skin for WordPress Plugin Upgrades.
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
- var $plugin = '';
- var $plugin_active = false;
- var $plugin_network_active = false;
-
- function __construct($args = array()) {
- $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
- $args = wp_parse_args($args, $defaults);
-
- $this->plugin = $args['plugin'];
-
- $this->plugin_active = is_plugin_active( $this->plugin );
- $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
-
- parent::__construct($args);
- }
-
- function after() {
- $this->plugin = $this->upgrader->plugin_info();
- if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
- echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
- }
-
- $update_actions = array(
- 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
- 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
- );
- if ( $this->plugin_active )
- unset( $update_actions['activate_plugin'] );
- if ( ! $this->result || is_wp_error($this->result) )
- unset( $update_actions['activate_plugin'] );
-
- $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin);
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
- }
-
- function before() {
- if ( $this->upgrader->show_before ) {
- echo $this->upgrader->show_before;
- $this->upgrader->show_before = '';
- }
- }
-}
-
-/**
- * Plugin Upgrader Skin for WordPress Plugin Upgrades.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 3.0.0
- */
-class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
- var $in_loop = false;
- var $error = false;
-
- function __construct($args = array()) {
- $defaults = array( 'url' => '', 'nonce' => '' );
- $args = wp_parse_args($args, $defaults);
-
- parent::__construct($args);
- }
-
- function add_strings() {
- $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
- $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>.');
- $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
- $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span>.</a>';
- $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
- }
-
- function feedback($string) {
- if ( isset( $this->upgrader->strings[$string] ) )
- $string = $this->upgrader->strings[$string];
-
- if ( strpos($string, '%') !== false ) {
- $args = func_get_args();
- $args = array_splice($args, 1);
- if ( !empty($args) )
- $string = vsprintf($string, $args);
- }
- if ( empty($string) )
- return;
- if ( $this->in_loop )
- echo "$string<br />\n";
- else
- echo "<p>$string</p>\n";
- }
-
- function header() {
- // Nothing, This will be displayed within a iframe.
- }
-
- function footer() {
- // Nothing, This will be displayed within a iframe.
- }
- function error($error) {
- if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
- $this->error = $this->upgrader->strings[$error];
-
- if ( is_wp_error($error) ) {
- foreach ( $error->get_error_messages() as $emessage ) {
- if ( $error->get_error_data() )
- $messages[] = $emessage . ' ' . $error->get_error_data();
- else
- $messages[] = $emessage;
- }
- $this->error = implode(', ', $messages);
- }
- echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
- }
-
- function bulk_header() {
- $this->feedback('skin_upgrade_start');
- }
-
- function bulk_footer() {
- $this->feedback('skin_upgrade_end');
- }
-
- function before($title = '') {
- $this->in_loop = true;
- printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <img alt="" src="' . admin_url( 'images/wpspin_light.gif' ) . '" class="hidden waiting-' . $this->upgrader->update_current . '" style="vertical-align:middle;" /></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count);
- echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
- echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
- $this->flush_output();
- }
-
- function after($title = '') {
- echo '</p></div>';
- if ( $this->error || ! $this->result ) {
- if ( $this->error )
- echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
- else
- echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
-
- echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
- }
- if ( !empty($this->result) && !is_wp_error($this->result) ) {
- echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>';
- echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
- }
-
- $this->reset();
- $this->flush_output();
- }
-
- function reset() {
- $this->in_loop = false;
- $this->error = false;
- }
-
- function flush_output() {
- wp_ob_end_flush_all();
- flush();
- }
-}
-
-class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
- var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
-
- function __construct($args = array()) {
- parent::__construct($args);
- }
-
- function add_strings() {
- parent::add_strings();
- $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
- }
-
- function before() {
- parent::before($this->plugin_info['Title']);
- }
-
- function after() {
- parent::after($this->plugin_info['Title']);
- }
- function bulk_footer() {
- parent::bulk_footer();
- $update_actions = array(
- 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
- 'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
- );
-
- $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
- }
-}
-
-class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
- var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
-
- function __construct($args = array()) {
- parent::__construct($args);
- }
-
- function add_strings() {
- parent::add_strings();
- $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
- }
-
- function before() {
- parent::before( $this->theme_info->display('Name') );
- }
-
- function after() {
- parent::after( $this->theme_info->display('Name') );
- }
-
- function bulk_footer() {
- parent::bulk_footer();
- $update_actions = array(
- 'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
- 'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
- );
-
- $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
- }
-}
-
-/**
- * Plugin Installer Skin for WordPress Plugin Installer.
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class Plugin_Installer_Skin extends WP_Upgrader_Skin {
- var $api;
- var $type;
-
- function __construct($args = array()) {
- $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
- $args = wp_parse_args($args, $defaults);
-
- $this->type = $args['type'];
- $this->api = isset($args['api']) ? $args['api'] : array();
-
- parent::__construct($args);
- }
-
- function before() {
- if ( !empty($this->api) )
- $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
- }
-
- function after() {
-
- $plugin_file = $this->upgrader->plugin_info();
-
- $install_actions = array();
-
- $from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins';
-
- if ( 'import' == $from )
- $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin & Run Importer') . '</a>';
- else
- $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
-
- if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
- $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
- unset( $install_actions['activate_plugin'] );
- }
-
- if ( 'import' == $from )
- $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
- else if ( $this->type == 'web' )
- $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
- else
- $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>';
-
- if ( ! $this->result || is_wp_error($this->result) ) {
- unset( $install_actions['activate_plugin'] );
- unset( $install_actions['network_activate'] );
- }
- $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
- if ( ! empty($install_actions) )
- $this->feedback(implode(' | ', (array)$install_actions));
- }
-}
-
-/**
- * Theme Installer Skin for the WordPress Theme Installer.
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class Theme_Installer_Skin extends WP_Upgrader_Skin {
- var $api;
- var $type;
-
- function __construct($args = array()) {
- $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
- $args = wp_parse_args($args, $defaults);
-
- $this->type = $args['type'];
- $this->api = isset($args['api']) ? $args['api'] : array();
-
- parent::__construct($args);
- }
-
- function before() {
- if ( !empty($this->api) )
- $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
- }
-
- function after() {
- if ( empty($this->upgrader->result['destination_name']) )
- return;
-
- $theme_info = $this->upgrader->theme_info();
- if ( empty( $theme_info ) )
- return;
-
- $name = $theme_info->display('Name');
- $stylesheet = $this->upgrader->result['destination_name'];
- $template = $theme_info->get_template();
-
- $preview_link = add_query_arg( array(
- 'preview' => 1,
- 'template' => $template,
- 'stylesheet' => $stylesheet,
- ), trailingslashit( get_home_url() ) );
-
- $activate_link = add_query_arg( array(
- 'action' => 'activate',
- 'template' => $template,
- 'stylesheet' => $stylesheet,
- ), admin_url('themes.php') );
- $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
-
- $install_actions = array();
- $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
- $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
- $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
-
- if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
- $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
-
- if ( $this->type == 'web' )
- $install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
- else
- $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
-
- if ( ! $this->result || is_wp_error($this->result) || is_network_admin() )
- unset( $install_actions['activate'], $install_actions['preview'] );
-
- $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
- if ( ! empty($install_actions) )
- $this->feedback(implode(' | ', (array)$install_actions));
- }
-}
-
-/**
- * Theme Upgrader Skin for WordPress Theme Upgrades.
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
- var $theme = '';
-
- function __construct($args = array()) {
- $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
- $args = wp_parse_args($args, $defaults);
-
- $this->theme = $args['theme'];
-
- parent::__construct($args);
- }
-
- function after() {
-
- $update_actions = array();
- if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
- $name = $theme_info->display('Name');
- $stylesheet = $this->upgrader->result['destination_name'];
- $template = $theme_info->get_template();
-
- $preview_link = add_query_arg( array(
- 'preview' => 1,
- 'template' => $template,
- 'stylesheet' => $stylesheet,
- ), trailingslashit( get_home_url() ) );
-
- $activate_link = add_query_arg( array(
- 'action' => 'activate',
- 'template' => $template,
- 'stylesheet' => $stylesheet,
- ), admin_url('themes.php') );
- $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
-
- if ( get_stylesheet() == $stylesheet ) {
- $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>';
- } else {
- $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
- $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
- $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
- }
-
- if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
- unset( $update_actions['preview'], $update_actions['activate'] );
- }
-
- $update_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
-
- $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
- }
-}
-
-/**
- * Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if its a local file to the Upgrade/Installer functions.
- *
- * @TODO More Detailed docs, for methods as well.
- *
- * @package WordPress
- * @subpackage Upgrader
- * @since 2.8.0
- */
-class File_Upload_Upgrader {
- var $package;
- var $filename;
- var $id = 0;
-
- function __construct($form, $urlholder) {
-
- if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
- wp_die(__('Please select a file'));
-
- //Handle a newly uploaded file, Else assume its already been uploaded
- if ( ! empty($_FILES) ) {
- $overrides = array( 'test_form' => false, 'test_type' => false );
- $file = wp_handle_upload( $_FILES[$form], $overrides );
-
- if ( isset( $file['error'] ) )
- wp_die( $file['error'] );
-
- $this->filename = $_FILES[$form]['name'];
- $this->package = $file['file'];
-
- // Construct the object array
- $object = array(
- 'post_title' => $this->filename,
- 'post_content' => $file['url'],
- 'post_mime_type' => $file['type'],
- 'guid' => $file['url'],
- 'context' => 'upgrader',
- 'post_status' => 'private'
- );
-
- // Save the data
- $this->id = wp_insert_attachment( $object, $file['file'] );
-
- // schedule a cleanup for 2 hours from now in case of failed install
- wp_schedule_single_event( time() + 7200, 'upgrader_scheduled_cleanup', array( $this->id ) );
-
- } elseif ( is_numeric( $_GET[$urlholder] ) ) {
- // Numeric Package = previously uploaded file, see above.
- $this->id = (int) $_GET[$urlholder];
- $attachment = get_post( $this->id );
- if ( empty($attachment) )
- wp_die(__('Please select a file'));
-
- $this->filename = $attachment->post_title;
- $this->package = get_attached_file( $attachment->ID );
- } else {
- // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
- if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
- wp_die( $uploads['error'] );
-
- $this->filename = $_GET[$urlholder];
- $this->package = $uploads['basedir'] . '/' . $this->filename;
- }
- }
-
- function cleanup() {
- if ( $this->id )
- wp_delete_attachment( $this->id );
-
- elseif ( file_exists( $this->package ) )
- return @unlink( $this->package );
-
- return true;
- }
-}
\ No newline at end of file