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