wp/wp-admin/includes/class-wp-upgrader-skins.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 11:14:17 +0000
changeset 6 490d5cc509ed
parent 5 5e2f62d02dcd
child 7 cf61fcea0001
permissions -rw-r--r--
update portfolio
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * The User Interface "Skins" for the WordPress File Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
class WP_Upgrader_Skin {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
	public $upgrader;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
	public $done_header = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
	public $done_footer = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
	public $result = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
	public $options = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
	public function __construct($args = array()) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		$defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		$this->options = wp_parse_args($args, $defaults);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
	 * @param WP_Upgrader $upgrader
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
	public function set_upgrader(&$upgrader) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
		if ( is_object($upgrader) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
			$this->upgrader =& $upgrader;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
		$this->add_strings();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
	public function add_strings() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
	public function set_result($result) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
		$this->result = $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
	public function request_filesystem_credentials( $error = false, $context = false, $allow_relaxed_file_ownership = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
		$url = $this->options['url'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    48
		if ( ! $context ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    49
			$context = $this->options['context'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    50
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
		if ( !empty($this->options['nonce']) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
			$url = wp_nonce_url($url, $this->options['nonce']);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    55
		$extra_fields = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
		return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
	public function header() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
		if ( $this->done_header ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
			return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		$this->done_header = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
		echo '<div class="wrap">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
		echo '<h2>' . $this->options['title'] . '</h2>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
	public function footer() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
		if ( $this->done_footer ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
		$this->done_footer = true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    76
	public function error($errors) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		if ( ! $this->done_header )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			$this->header();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		if ( is_string($errors) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			$this->feedback($errors);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		} elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
			foreach ( $errors->get_error_messages() as $message ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
				if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    84
					$this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
					$this->feedback($message);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    91
	public function feedback($string) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
		if ( isset( $this->upgrader->strings[$string] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
			$string = $this->upgrader->strings[$string];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		if ( strpos($string, '%') !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
			$args = func_get_args();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			$args = array_splice($args, 1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
			if ( $args ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
				$args = array_map( 'strip_tags', $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
				$args = array_map( 'esc_html', $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
				$string = vsprintf($string, $args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
		if ( empty($string) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
		show_message($string);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
	public function before() {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
	public function after() {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   111
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
	 * Output JavaScript that calls function to decrement the update counts.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   114
	 * @since 3.9.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   115
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   116
	 * @param string $type Type of update count to decrement. Likely values include 'plugin',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   117
	 *                     'theme', 'translation', etc.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   119
	protected function decrement_update_count( $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   120
		if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   124
		if ( defined( 'IFRAME_REQUEST' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   125
			echo '<script type="text/javascript">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   126
					if ( window.postMessage && JSON ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   127
						window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   128
					}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   129
				</script>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   130
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
			echo '<script type="text/javascript">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
					(function( wp ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
						if ( wp && wp.updates.decrementCount ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
							wp.updates.decrementCount( "' . $type . '" );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
						}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
					})( window.wp );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
				</script>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   140
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   141
	public function bulk_header() {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   142
	public function bulk_footer() {}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
	public $plugin = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
	public $plugin_active = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
	public $plugin_network_active = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
	public function __construct($args = array()) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
		$defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
		$args = wp_parse_args($args, $defaults);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
		$this->plugin = $args['plugin'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		$this->plugin_active = is_plugin_active( $this->plugin );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
		$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		parent::__construct($args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
	public function after() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		$this->plugin = $this->upgrader->plugin_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
		if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
			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>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   175
		$this->decrement_update_count( 'plugin' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		$update_actions =  array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
			'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
			'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
			unset( $update_actions['activate_plugin'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   184
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
		 * Filter the list of action links available following a single plugin update.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   188
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   189
		 * @param array  $update_actions Array of plugin action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   190
		 * @param string $plugin         Path to the plugin file.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   191
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
		$update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   193
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
		if ( ! empty($update_actions) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
			$this->feedback(implode(' | ', (array)$update_actions));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
	public $in_loop = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
	 * @var string|false
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
	public $error = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
	public function __construct($args = array()) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
		$defaults = array( 'url' => '', 'nonce' => '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		$args = wp_parse_args($args, $defaults);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
		parent::__construct($args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   220
	public function add_strings() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		$this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		$this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
		$this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   224
		$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>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		$this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   229
	 * @param string $string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   231
	public function feedback($string) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
		if ( isset( $this->upgrader->strings[$string] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
			$string = $this->upgrader->strings[$string];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
		if ( strpos($string, '%') !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
			$args = func_get_args();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
			$args = array_splice($args, 1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
			if ( $args ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
				$args = array_map( 'strip_tags', $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
				$args = array_map( 'esc_html', $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
				$string = vsprintf($string, $args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
		if ( empty($string) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
		if ( $this->in_loop )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
			echo "$string<br />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
			echo "<p>$string</p>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
	public function header() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
		// Nothing, This will be displayed within a iframe.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
	public function footer() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
		// Nothing, This will be displayed within a iframe.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   259
	public function error($error) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
		if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
			$this->error = $this->upgrader->strings[$error];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
		if ( is_wp_error($error) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   264
			$messages = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
			foreach ( $error->get_error_messages() as $emessage ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
				if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   267
					$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
					$messages[] = $emessage;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
			$this->error = implode(', ', $messages);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   276
	public function bulk_header() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
		$this->feedback('skin_upgrade_start');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   280
	public function bulk_footer() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
		$this->feedback('skin_upgrade_end');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
	public function before($title = '') {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		$this->in_loop = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
		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);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
		echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
		$this->flush_output();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   292
	public function after($title = '') {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
		echo '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
		if ( $this->error || ! $this->result ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
			if ( $this->error )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
				echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
				echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
			echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
		if ( $this->result && ! is_wp_error( $this->result ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
			if ( ! $this->error )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
				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>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
			echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
		$this->reset();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
		$this->flush_output();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
	public function reset() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
		$this->in_loop = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
		$this->error = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
	public function flush_output() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
		wp_ob_end_flush_all();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
		flush();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   324
	public $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   326
	public function add_strings() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
		parent::add_strings();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
		$this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   331
	public function before($title = '') {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
		parent::before($this->plugin_info['Title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   335
	public function after($title = '') {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
		parent::after($this->plugin_info['Title']);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   337
		$this->decrement_update_count( 'plugin' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
	public function bulk_footer() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
		parent::bulk_footer();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
		$update_actions =  array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
			'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
			'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>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
		if ( ! current_user_can( 'activate_plugins' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
			unset( $update_actions['plugins_page'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
		 * Filter the list of action links available following bulk plugin updates.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   353
		 * @param array $update_actions Array of plugin action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
		 * @param array $plugin_info    Array of information for the last-updated plugin.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   355
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   356
		$update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
		if ( ! empty($update_actions) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
			$this->feedback(implode(' | ', (array)$update_actions));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
	public $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   366
	public function add_strings() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
		parent::add_strings();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
		$this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
	public function before($title = '') {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
		parent::before( $this->theme_info->display('Name') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   375
	public function after($title = '') {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
		parent::after( $this->theme_info->display('Name') );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   377
		$this->decrement_update_count( 'theme' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   380
	public function bulk_footer() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		parent::bulk_footer();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
		$update_actions =  array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
			'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
			'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>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
		if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
			unset( $update_actions['themes_page'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   390
		 * Filter the list of action links available following bulk theme updates.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   391
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   394
		 * @param array $update_actions Array of theme action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   395
		 * @param array $theme_info     Array of information for the last-updated theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   396
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
		$update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   398
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
		if ( ! empty($update_actions) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
			$this->feedback(implode(' | ', (array)$update_actions));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
 * Plugin Installer Skin for WordPress Plugin Installer.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
class Plugin_Installer_Skin extends WP_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
	public $api;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
	public $type;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
	public function __construct($args = array()) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
		$defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
		$args = wp_parse_args($args, $defaults);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
		$this->type = $args['type'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
		$this->api = isset($args['api']) ? $args['api'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
		parent::__construct($args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
	public function before() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
		if ( !empty($this->api) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
			$this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   430
	public function after() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
		$plugin_file = $this->upgrader->plugin_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
		$install_actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
		$from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
		if ( 'import' == $from )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
			$install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin &amp; Run Importer') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
			$install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
		if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
			$install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;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>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
			unset( $install_actions['activate_plugin'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   448
		if ( 'import' == $from ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
			$install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   450
		} elseif ( $this->type == 'web' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
			$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>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   452
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
			$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>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   454
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
		if ( ! $this->result || is_wp_error($this->result) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
			unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
		} elseif ( ! current_user_can( 'activate_plugins' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
			unset( $install_actions['activate_plugin'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   462
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   463
		 * Filter the list of action links available following a single plugin installation.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   464
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   465
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   466
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   467
		 * @param array  $install_actions Array of plugin action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   468
		 * @param object $api             Object containing WordPress.org API plugin data. Empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   469
		 *                                for non-API installs, such as when a plugin is installed
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
		 *                                via upload.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
		 * @param string $plugin_file     Path to the plugin file.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   472
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   473
		$install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   474
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
		if ( ! empty($install_actions) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
			$this->feedback(implode(' | ', (array)$install_actions));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
 * Theme Installer Skin for the WordPress Theme Installer.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
class Theme_Installer_Skin extends WP_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   488
	public $api;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   489
	public $type;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   491
	public function __construct($args = array()) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
		$defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
		$args = wp_parse_args($args, $defaults);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
		$this->type = $args['type'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
		$this->api = isset($args['api']) ? $args['api'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
		parent::__construct($args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
	public function before() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
		if ( !empty($this->api) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
			$this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   506
	public function after() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
		if ( empty($this->upgrader->result['destination_name']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
		$theme_info = $this->upgrader->theme_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
		if ( empty( $theme_info ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
		$name       = $theme_info->display('Name');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
		$stylesheet = $this->upgrader->result['destination_name'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
		$template   = $theme_info->get_template();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
		$preview_link = add_query_arg( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
			'preview'    => 1,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
			'template'   => urlencode( $template ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
			'stylesheet' => urlencode( $stylesheet ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
		), trailingslashit( home_url() ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
		$activate_link = add_query_arg( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
			'action'     => 'activate',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
			'template'   => urlencode( $template ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
			'stylesheet' => urlencode( $stylesheet ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
		), admin_url('themes.php') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
		$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
		$install_actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
		$install_actions['preview']  = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
		if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   534
			$install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Live Preview') . '</a>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   535
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
		$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
		if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
			$install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
		if ( $this->type == 'web' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
			$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>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
		elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
			$install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
			unset( $install_actions['activate'], $install_actions['preview'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   549
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   550
		 * Filter the list of action links available following a single theme installation.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   551
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   552
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   553
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   554
		 * @param array    $install_actions Array of theme action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   555
		 * @param object   $api             Object containing WordPress.org API theme data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   556
		 * @param string   $stylesheet      Theme directory name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   557
		 * @param WP_Theme $theme_info      Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   558
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   559
		$install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
		if ( ! empty($install_actions) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
			$this->feedback(implode(' | ', (array)$install_actions));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
 * Theme Upgrader Skin for WordPress Theme Upgrades.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   573
	public $theme = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   575
	public function __construct($args = array()) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
		$defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
		$args = wp_parse_args($args, $defaults);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
		$this->theme = $args['theme'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
		parent::__construct($args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
	public function after() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   585
		$this->decrement_update_count( 'theme' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
		$update_actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
		if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
			$name       = $theme_info->display('Name');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
			$stylesheet = $this->upgrader->result['destination_name'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
			$template   = $theme_info->get_template();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
			$preview_link = add_query_arg( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
				'preview'    => 1,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
				'template'   => urlencode( $template ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
				'stylesheet' => urlencode( $stylesheet ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
			), trailingslashit( home_url() ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
			$activate_link = add_query_arg( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
				'action'     => 'activate',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
				'template'   => urlencode( $template ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
				'stylesheet' => urlencode( $stylesheet ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
			), admin_url('themes.php') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
			$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
			if ( get_stylesheet() == $stylesheet ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
				if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
					$update_actions['preview']  = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize &#8220;%s&#8221;'), $name ) ) . '">' . __('Customize') . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   609
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
			} elseif ( current_user_can( 'switch_themes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
				$update_actions['preview']  = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   612
				if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
					$update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Live Preview') . '</a>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   614
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
				$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
			if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
				unset( $update_actions['preview'], $update_actions['activate'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
		$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>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   624
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   625
		 * Filter the list of action links available following a single theme update.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   626
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   627
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   628
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   629
		 * @param array  $update_actions Array of theme action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   630
		 * @param string $theme          Theme directory name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   631
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   632
		$update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
		if ( ! empty($update_actions) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
			$this->feedback(implode(' | ', (array)$update_actions));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
 * Translation Upgrader Skin for WordPress Translation Upgrades.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   647
	public $language_update = null;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   648
	public $done_header = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   649
	public $done_footer = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   650
	public $display_footer_actions = true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
	public function __construct( $args = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
		$defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
		$args = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
		if ( $args['skip_header_footer'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
			$this->done_header = true;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   657
			$this->done_footer = true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
			$this->display_footer_actions = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
		parent::__construct( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   663
	public function before() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
		$name = $this->upgrader->get_name_for_update( $this->language_update );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
		echo '<div class="update-messages lp-show-latest">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
		printf( '<h4>' . __( 'Updating translations for %1$s (%2$s)&#8230;' ) . '</h4>', $name, $this->language_update->language );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   671
	public function error( $error ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
		echo '<div class="lp-error">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
		parent::error( $error );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   677
	public function after() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   681
	public function bulk_footer() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   682
		$this->decrement_update_count( 'translation' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
		$update_actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
		$update_actions['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>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   685
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   686
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   687
		 * Filter the list of action links available following a translations update.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   688
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   689
		 * @since 3.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   690
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   691
		 * @param array $update_actions Array of translations update links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   692
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
		$update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
		if ( $update_actions && $this->display_footer_actions )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
			$this->feedback( implode( ' | ', $update_actions ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
 * Upgrader Skin for Automatic WordPress Upgrades
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
 * This skin is designed to be used when no output is intended, all output
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
 * is captured and stored for the caller to process and log/email/discard.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
 * @subpackage Upgrader
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
	protected $messages = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   713
	public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   714
		if ( $context ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
			$this->options['context'] = $context;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   716
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
		// TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
		// This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
		ob_start();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   720
		$result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
		ob_end_clean();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
		return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   725
	public function get_upgrade_messages() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
		return $this->messages;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   729
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   730
	 * @param string|array|WP_Error $data
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
	public function feedback( $data ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
		if ( is_wp_error( $data ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
			$string = $data->get_error_message();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
		} elseif ( is_array( $data ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
			return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
			$string = $data;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   739
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
		if ( ! empty( $this->upgrader->strings[ $string ] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
			$string = $this->upgrader->strings[ $string ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
		if ( strpos( $string, '%' ) !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
			$args = func_get_args();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
			$args = array_splice( $args, 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
			if ( ! empty( $args ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
				$string = vsprintf( $string, $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
		$string = trim( $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
		// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
		$string = wp_kses( $string, array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
			'a' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
				'href' => true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
			),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
			'br' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
			'em' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
			'strong' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
		if ( empty( $string ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
		$this->messages[] = $string;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   768
	public function header() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
		ob_start();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   772
	public function footer() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
		$output = ob_get_contents();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
		if ( ! empty( $output ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
			$this->feedback( $output );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
		ob_end_clean();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   779
	public function bulk_header() {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   780
	public function bulk_footer() {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   781
	public function before() {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   782
	public function after() {}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
}