<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[25227] trunk/src/wp-admin/includes: Upgrader: Split the UI "skins" out from the main Upgrader file into a seperate file to reduce the length of the files.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/25227">25227</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2013-09-04 06:34:38 +0000 (Wed, 04 Sep 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Upgrader: Split the UI "skins" out from the main Upgrader file into a seperate file to reduce the length of the files. See <a href="http://core.trac.wordpress.org/ticket/22704">#22704</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpupgraderphp">trunk/src/wp-admin/includes/class-wp-upgrader.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpupgraderskinsphp">trunk/src/wp-admin/includes/class-wp-upgrader-skins.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpupgraderskinsphpfromrev25226trunksrcwpadminincludesclasswpupgraderphp"></a>
<div class="copfile"><h4>Copied: trunk/src/wp-admin/includes/class-wp-upgrader-skins.php (from rev 25226, trunk/src/wp-admin/includes/class-wp-upgrader.php) (0 => 25227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/class-wp-upgrader-skins.php (rev 0)
+++ trunk/src/wp-admin/includes/class-wp-upgrader-skins.php 2013-09-04 06:34:38 UTC (rev 25227)
</span><span class="lines">@@ -0,0 +1,529 @@
</span><ins>+<?php
+/**
+ * The User Interface "Skins" for the WordPress File Upgrader
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+
+/**
+ * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
+ *
+ * @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">';
+ 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 . ' ' . esc_html( $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 ( $args ) {
+ $args = array_map( 'strip_tags', $args );
+ $args = array_map( 'esc_html', $args );
+ $string = vsprintf($string, $args);
+ }
+ }
+ if ( empty($string) )
+ return;
+ show_message($string);
+ }
+ function before() {}
+ function after() {}
+
+}
+
+/**
+ * Plugin Upgrader Skin for WordPress Plugin Upgrades.
+ *
+ * @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=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>';
+ }
+
+ $update_actions = array(
+ 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $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 || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
+ 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 ( $args ) {
+ $args = array_map( 'strip_tags', $args );
+ $args = array_map( 'esc_html', $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 . ' ' . esc_html( $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'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count);
+ echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</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 ( $this->result && ! is_wp_error( $this->result ) ) {
+ if ( ! $this->error )
+ 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($title = '') {
+ parent::before($this->plugin_info['Title']);
+ }
+
+ function after($title = '') {
+ 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>'
+ );
+ if ( ! current_user_can( 'activate_plugins' ) )
+ unset( $update_actions['plugins_page'] );
+
+ $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($title = '') {
+ parent::before( $this->theme_info->display('Name') );
+ }
+
+ function after($title = '') {
+ 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>'
+ );
+ if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
+ unset( $update_actions['themes_page'] );
+
+ $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.
+ *
+ * @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']) ? wp_unslash( $_GET['from'] ) : 'plugins';
+
+ if ( 'import' == $from )
+ $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . urlencode( $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=' . urlencode( $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=' . urlencode( $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'], $install_actions['network_activate'] );
+ } elseif ( ! current_user_can( 'activate_plugins' ) ) {
+ unset( $install_actions['activate_plugin'] );
+ }
+
+ $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.
+ *
+ * @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' => urlencode( $template ),
+ 'stylesheet' => urlencode( $stylesheet ),
+ ), trailingslashit( home_url() ) );
+
+ $activate_link = add_query_arg( array(
+ 'action' => 'activate',
+ 'template' => urlencode( $template ),
+ 'stylesheet' => urlencode( $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=' . urlencode( $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>';
+ elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
+ $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() || ! current_user_can( 'switch_themes' ) )
+ 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.
+ *
+ * @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' => urlencode( $template ),
+ 'stylesheet' => urlencode( $stylesheet ),
+ ), trailingslashit( home_url() ) );
+
+ $activate_link = add_query_arg( array(
+ 'action' => 'activate',
+ 'template' => urlencode( $template ),
+ 'stylesheet' => urlencode( $stylesheet ),
+ ), admin_url('themes.php') );
+ $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
+
+ if ( get_stylesheet() == $stylesheet ) {
+ if ( current_user_can( 'edit_theme_options' ) )
+ $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>';
+ } elseif ( current_user_can( 'switch_themes' ) ) {
+ $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));
+ }
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/class-wp-upgrader.php (25226 => 25227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/class-wp-upgrader.php 2013-09-04 05:10:43 UTC (rev 25226)
+++ trunk/src/wp-admin/includes/class-wp-upgrader.php 2013-09-04 06:34:38 UTC (rev 25227)
</span><span class="lines">@@ -11,11 +11,11 @@
</span><span class="cx"> * @since 2.8.0
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+require ABSPATH . 'wp-admin/includes/class-wp-upgrader-skins.php';
+
</ins><span class="cx"> /**
</span><span class="cx"> * WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file.
</span><span class="cx"> *
</span><del>- * @TODO More Detailed docs, for methods as well.
- *
</del><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Upgrader
</span><span class="cx"> * @since 2.8.0
</span><span class="lines">@@ -367,8 +367,6 @@
</span><span class="cx"> /**
</span><span class="cx"> * Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file.
</span><span class="cx"> *
</span><del>- * @TODO More Detailed docs, for methods as well.
- *
</del><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Upgrader
</span><span class="cx"> * @since 2.8.0
</span><span class="lines">@@ -653,8 +651,6 @@
</span><span class="cx"> /**
</span><span class="cx"> * Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
</span><span class="cx"> *
</span><del>- * @TODO More Detailed docs, for methods as well.
- *
</del><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Upgrader
</span><span class="cx"> * @since 2.8.0
</span><span class="lines">@@ -1027,8 +1023,6 @@
</span><span class="cx"> /**
</span><span class="cx"> * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combination with the wp-admin/includes/update-core.php file
</span><span class="cx"> *
</span><del>- * @TODO More Detailed docs, for methods as well.
- *
</del><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Upgrader
</span><span class="cx"> * @since 2.8.0
</span><span class="lines">@@ -1102,541 +1096,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * 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">';
- 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 . ' ' . esc_html( $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 ( $args ) {
- $args = array_map( 'strip_tags', $args );
- $args = array_map( 'esc_html', $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=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>';
- }
-
- $update_actions = array(
- 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $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 || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
- 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 ( $args ) {
- $args = array_map( 'strip_tags', $args );
- $args = array_map( 'esc_html', $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 . ' ' . esc_html( $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'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count);
- echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</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 ( $this->result && ! is_wp_error( $this->result ) ) {
- if ( ! $this->error )
- 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($title = '') {
- parent::before($this->plugin_info['Title']);
- }
-
- function after($title = '') {
- 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>'
- );
- if ( ! current_user_can( 'activate_plugins' ) )
- unset( $update_actions['plugins_page'] );
-
- $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($title = '') {
- parent::before( $this->theme_info->display('Name') );
- }
-
- function after($title = '') {
- 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>'
- );
- if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
- unset( $update_actions['themes_page'] );
-
- $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']) ? wp_unslash( $_GET['from'] ) : 'plugins';
-
- if ( 'import' == $from )
- $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . urlencode( $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=' . urlencode( $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=' . urlencode( $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'], $install_actions['network_activate'] );
- } elseif ( ! current_user_can( 'activate_plugins' ) ) {
- unset( $install_actions['activate_plugin'] );
- }
-
- $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' => urlencode( $template ),
- 'stylesheet' => urlencode( $stylesheet ),
- ), trailingslashit( home_url() ) );
-
- $activate_link = add_query_arg( array(
- 'action' => 'activate',
- 'template' => urlencode( $template ),
- 'stylesheet' => urlencode( $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=' . urlencode( $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>';
- elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
- $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() || ! current_user_can( 'switch_themes' ) )
- 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' => urlencode( $template ),
- 'stylesheet' => urlencode( $stylesheet ),
- ), trailingslashit( home_url() ) );
-
- $activate_link = add_query_arg( array(
- 'action' => 'activate',
- 'template' => urlencode( $template ),
- 'stylesheet' => urlencode( $stylesheet ),
- ), admin_url('themes.php') );
- $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
-
- if ( get_stylesheet() == $stylesheet ) {
- if ( current_user_can( 'edit_theme_options' ) )
- $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>';
- } elseif ( current_user_can( 'switch_themes' ) ) {
- $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));
- }
-}
-
-/**
</del><span class="cx"> * Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if it's a local file to the Upgrade/Installer functions.
</span><span class="cx"> *
</span><del>- * @TODO More Detailed docs, for methods as well.
- *
</del><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Upgrader
</span><span class="cx"> * @since 2.8.0
</span></span></pre>
</div>
</div>
</body>
</html>