3 * The User Interface "Skins" for the WordPress File Upgrader
11 * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
14 * @subpackage Upgrader
17 class WP_Upgrader_Skin {
20 public $done_header = false;
21 public $done_footer = false;
22 public $result = false;
24 public function __construct($args = array()) {
25 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
26 $this->options = wp_parse_args($args, $defaults);
29 public function set_upgrader(&$upgrader) {
30 if ( is_object($upgrader) )
31 $this->upgrader =& $upgrader;
35 public function add_strings() {
38 public function set_result($result) {
39 $this->result = $result;
42 public function request_filesystem_credentials($error = false) {
43 $url = $this->options['url'];
44 $context = $this->options['context'];
45 if ( !empty($this->options['nonce']) )
46 $url = wp_nonce_url($url, $this->options['nonce']);
47 return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
50 public function header() {
51 if ( $this->done_header ) {
54 $this->done_header = true;
55 echo '<div class="wrap">';
56 echo '<h2>' . $this->options['title'] . '</h2>';
58 public function footer() {
59 if ( $this->done_footer ) {
62 $this->done_footer = true;
66 public function error($errors) {
67 if ( ! $this->done_header )
69 if ( is_string($errors) ) {
70 $this->feedback($errors);
71 } elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
72 foreach ( $errors->get_error_messages() as $message ) {
73 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
74 $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
76 $this->feedback($message);
81 public function feedback($string) {
82 if ( isset( $this->upgrader->strings[$string] ) )
83 $string = $this->upgrader->strings[$string];
85 if ( strpos($string, '%') !== false ) {
86 $args = func_get_args();
87 $args = array_splice($args, 1);
89 $args = array_map( 'strip_tags', $args );
90 $args = array_map( 'esc_html', $args );
91 $string = vsprintf($string, $args);
96 show_message($string);
98 public function before() {}
99 public function after() {}
102 * Output JavaScript that calls function to decrement the update counts.
106 * @param string $type Type of update count to decrement. Likely values include 'plugin',
107 * 'theme', 'translation', etc.
109 protected function decrement_update_count( $type ) {
110 if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
114 if ( defined( 'IFRAME_REQUEST' ) ) {
115 echo '<script type="text/javascript">
116 if ( window.postMessage && JSON ) {
117 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
121 echo '<script type="text/javascript">
123 if ( wp && wp.updates.decrementCount ) {
124 wp.updates.decrementCount( "' . $type . '" );
133 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
136 * @subpackage Upgrader
139 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
141 public $plugin_active = false;
142 public $plugin_network_active = false;
144 public function __construct($args = array()) {
145 $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
146 $args = wp_parse_args($args, $defaults);
148 $this->plugin = $args['plugin'];
150 $this->plugin_active = is_plugin_active( $this->plugin );
151 $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
153 parent::__construct($args);
156 public function after() {
157 $this->plugin = $this->upgrader->plugin_info();
158 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
159 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>';
162 $this->decrement_update_count( 'plugin' );
164 $update_actions = array(
165 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
166 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
168 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
169 unset( $update_actions['activate_plugin'] );
172 * Filter the list of action links available following a single plugin update.
176 * @param array $update_actions Array of plugin action links.
177 * @param string $plugin Path to the plugin file.
179 $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
181 if ( ! empty($update_actions) )
182 $this->feedback(implode(' | ', (array)$update_actions));
187 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
190 * @subpackage Upgrader
193 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
194 public $in_loop = false;
195 public $error = false;
197 public function __construct($args = array()) {
198 $defaults = array( 'url' => '', 'nonce' => '' );
199 $args = wp_parse_args($args, $defaults);
201 parent::__construct($args);
204 public function add_strings() {
205 $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
206 $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>');
207 $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
208 $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>';
209 $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
212 public function feedback($string) {
213 if ( isset( $this->upgrader->strings[$string] ) )
214 $string = $this->upgrader->strings[$string];
216 if ( strpos($string, '%') !== false ) {
217 $args = func_get_args();
218 $args = array_splice($args, 1);
220 $args = array_map( 'strip_tags', $args );
221 $args = array_map( 'esc_html', $args );
222 $string = vsprintf($string, $args);
225 if ( empty($string) )
227 if ( $this->in_loop )
228 echo "$string<br />\n";
230 echo "<p>$string</p>\n";
233 public function header() {
234 // Nothing, This will be displayed within a iframe.
237 public function footer() {
238 // Nothing, This will be displayed within a iframe.
240 public function error($error) {
241 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
242 $this->error = $this->upgrader->strings[$error];
244 if ( is_wp_error($error) ) {
246 foreach ( $error->get_error_messages() as $emessage ) {
247 if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
248 $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
250 $messages[] = $emessage;
252 $this->error = implode(', ', $messages);
254 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
257 public function bulk_header() {
258 $this->feedback('skin_upgrade_start');
261 public function bulk_footer() {
262 $this->feedback('skin_upgrade_end');
265 public function before($title = '') {
266 $this->in_loop = true;
267 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);
268 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
269 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
270 $this->flush_output();
273 public function after($title = '') {
275 if ( $this->error || ! $this->result ) {
277 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
279 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
281 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
283 if ( $this->result && ! is_wp_error( $this->result ) ) {
284 if ( ! $this->error )
285 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>';
286 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
290 $this->flush_output();
293 public function reset() {
294 $this->in_loop = false;
295 $this->error = false;
298 public function flush_output() {
299 wp_ob_end_flush_all();
304 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
305 public $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
307 public function __construct($args = array()) {
308 parent::__construct($args);
311 public function add_strings() {
312 parent::add_strings();
313 $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
316 public function before($title = '') {
317 parent::before($this->plugin_info['Title']);
320 public function after($title = '') {
321 parent::after($this->plugin_info['Title']);
322 $this->decrement_update_count( 'plugin' );
324 public function bulk_footer() {
325 parent::bulk_footer();
326 $update_actions = array(
327 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
328 '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>'
330 if ( ! current_user_can( 'activate_plugins' ) )
331 unset( $update_actions['plugins_page'] );
334 * Filter the list of action links available following bulk plugin updates.
338 * @param array $update_actions Array of plugin action links.
339 * @param array $plugin_info Array of information for the last-updated plugin.
341 $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
343 if ( ! empty($update_actions) )
344 $this->feedback(implode(' | ', (array)$update_actions));
348 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
349 public $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
351 public function __construct($args = array()) {
352 parent::__construct($args);
355 public function add_strings() {
356 parent::add_strings();
357 $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
360 public function before($title = '') {
361 parent::before( $this->theme_info->display('Name') );
364 public function after($title = '') {
365 parent::after( $this->theme_info->display('Name') );
366 $this->decrement_update_count( 'theme' );
369 public function bulk_footer() {
370 parent::bulk_footer();
371 $update_actions = array(
372 'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
373 '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>'
375 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
376 unset( $update_actions['themes_page'] );
379 * Filter the list of action links available following bulk theme updates.
383 * @param array $update_actions Array of theme action links.
384 * @param array $theme_info Array of information for the last-updated theme.
386 $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
388 if ( ! empty($update_actions) )
389 $this->feedback(implode(' | ', (array)$update_actions));
394 * Plugin Installer Skin for WordPress Plugin Installer.
397 * @subpackage Upgrader
400 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
404 public function __construct($args = array()) {
405 $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
406 $args = wp_parse_args($args, $defaults);
408 $this->type = $args['type'];
409 $this->api = isset($args['api']) ? $args['api'] : array();
411 parent::__construct($args);
414 public function before() {
415 if ( !empty($this->api) )
416 $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
419 public function after() {
421 $plugin_file = $this->upgrader->plugin_info();
423 $install_actions = array();
425 $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
427 if ( 'import' == $from )
428 $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin & Run Importer') . '</a>';
430 $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
432 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
433 $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
434 unset( $install_actions['activate_plugin'] );
437 if ( 'import' == $from )
438 $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
439 else if ( $this->type == 'web' )
440 $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>';
442 $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>';
444 if ( ! $this->result || is_wp_error($this->result) ) {
445 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
446 } elseif ( ! current_user_can( 'activate_plugins' ) ) {
447 unset( $install_actions['activate_plugin'] );
451 * Filter the list of action links available following a single plugin installation.
455 * @param array $install_actions Array of plugin action links.
456 * @param object $api Object containing WordPress.org API plugin data. Empty
457 * for non-API installs, such as when a plugin is installed
459 * @param string $plugin_file Path to the plugin file.
461 $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
463 if ( ! empty($install_actions) )
464 $this->feedback(implode(' | ', (array)$install_actions));
469 * Theme Installer Skin for the WordPress Theme Installer.
472 * @subpackage Upgrader
475 class Theme_Installer_Skin extends WP_Upgrader_Skin {
479 public function __construct($args = array()) {
480 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
481 $args = wp_parse_args($args, $defaults);
483 $this->type = $args['type'];
484 $this->api = isset($args['api']) ? $args['api'] : array();
486 parent::__construct($args);
489 public function before() {
490 if ( !empty($this->api) )
491 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
494 public function after() {
495 if ( empty($this->upgrader->result['destination_name']) )
498 $theme_info = $this->upgrader->theme_info();
499 if ( empty( $theme_info ) )
502 $name = $theme_info->display('Name');
503 $stylesheet = $this->upgrader->result['destination_name'];
504 $template = $theme_info->get_template();
506 $preview_link = add_query_arg( array(
508 'template' => urlencode( $template ),
509 'stylesheet' => urlencode( $stylesheet ),
510 ), trailingslashit( home_url() ) );
512 $activate_link = add_query_arg( array(
513 'action' => 'activate',
514 'template' => urlencode( $template ),
515 'stylesheet' => urlencode( $stylesheet ),
516 ), admin_url('themes.php') );
517 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
519 $install_actions = array();
520 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
521 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
522 $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
524 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
526 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
527 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
529 if ( $this->type == 'web' )
530 $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>';
531 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
532 $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
534 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
535 unset( $install_actions['activate'], $install_actions['preview'] );
538 * Filter the list of action links available following a single theme installation.
542 * @param array $install_actions Array of theme action links.
543 * @param object $api Object containing WordPress.org API theme data.
544 * @param string $stylesheet Theme directory name.
545 * @param WP_Theme $theme_info Theme object.
547 $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
548 if ( ! empty($install_actions) )
549 $this->feedback(implode(' | ', (array)$install_actions));
554 * Theme Upgrader Skin for WordPress Theme Upgrades.
557 * @subpackage Upgrader
560 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
563 public function __construct($args = array()) {
564 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
565 $args = wp_parse_args($args, $defaults);
567 $this->theme = $args['theme'];
569 parent::__construct($args);
572 public function after() {
573 $this->decrement_update_count( 'theme' );
575 $update_actions = array();
576 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
577 $name = $theme_info->display('Name');
578 $stylesheet = $this->upgrader->result['destination_name'];
579 $template = $theme_info->get_template();
581 $preview_link = add_query_arg( array(
583 'template' => urlencode( $template ),
584 'stylesheet' => urlencode( $stylesheet ),
585 ), trailingslashit( home_url() ) );
587 $activate_link = add_query_arg( array(
588 'action' => 'activate',
589 'template' => urlencode( $template ),
590 'stylesheet' => urlencode( $stylesheet ),
591 ), admin_url('themes.php') );
592 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
594 if ( get_stylesheet() == $stylesheet ) {
595 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
596 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>';
598 } elseif ( current_user_can( 'switch_themes' ) ) {
599 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
600 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
601 $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
603 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
606 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
607 unset( $update_actions['preview'], $update_actions['activate'] );
610 $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>';
613 * Filter the list of action links available following a single theme update.
617 * @param array $update_actions Array of theme action links.
618 * @param string $theme Theme directory name.
620 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
622 if ( ! empty($update_actions) )
623 $this->feedback(implode(' | ', (array)$update_actions));
628 * Translation Upgrader Skin for WordPress Translation Upgrades.
631 * @subpackage Upgrader
634 class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
635 public $language_update = null;
636 public $done_header = false;
637 public $done_footer = false;
638 public $display_footer_actions = true;
640 public function __construct( $args = array() ) {
641 $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
642 $args = wp_parse_args( $args, $defaults );
643 if ( $args['skip_header_footer'] ) {
644 $this->done_header = true;
645 $this->done_footer = true;
646 $this->display_footer_actions = false;
648 parent::__construct( $args );
651 public function before() {
652 $name = $this->upgrader->get_name_for_update( $this->language_update );
654 echo '<div class="update-messages lp-show-latest">';
656 printf( '<h4>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h4>', $name, $this->language_update->language );
659 public function error( $error ) {
660 echo '<div class="lp-error">';
661 parent::error( $error );
665 public function after() {
669 public function bulk_footer() {
670 $this->decrement_update_count( 'translation' );
671 $update_actions = array();
672 $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>';
675 * Filter the list of action links available following a translations update.
679 * @param array $update_actions Array of translations update links.
681 $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
683 if ( $update_actions && $this->display_footer_actions )
684 $this->feedback( implode( ' | ', $update_actions ) );
689 * Upgrader Skin for Automatic WordPress Upgrades
691 * This skin is designed to be used when no output is intended, all output
692 * is captured and stored for the caller to process and log/email/discard.
695 * @subpackage Upgrader
698 class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
699 protected $messages = array();
701 public function request_filesystem_credentials( $error = false, $context = '' ) {
703 $this->options['context'] = $context;
704 // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
705 // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
707 $result = parent::request_filesystem_credentials( $error );
712 public function get_upgrade_messages() {
713 return $this->messages;
716 public function feedback( $data ) {
717 if ( is_wp_error( $data ) )
718 $string = $data->get_error_message();
719 else if ( is_array( $data ) )
724 if ( ! empty( $this->upgrader->strings[ $string ] ) )
725 $string = $this->upgrader->strings[ $string ];
727 if ( strpos( $string, '%' ) !== false ) {
728 $args = func_get_args();
729 $args = array_splice( $args, 1 );
730 if ( ! empty( $args ) )
731 $string = vsprintf( $string, $args );
734 $string = trim( $string );
736 // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
737 $string = wp_kses( $string, array(
746 if ( empty( $string ) )
749 $this->messages[] = $string;
752 public function header() {
756 public function footer() {
757 $output = ob_get_contents();
758 if ( ! empty( $output ) )
759 $this->feedback( $output );
763 public function bulk_header() {}
764 public function bulk_footer() {}
765 public function before() {}
766 public function after() {}