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;
23 public $options = array();
29 public function __construct($args = array()) {
30 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
31 $this->options = wp_parse_args($args, $defaults);
35 * @param WP_Upgrader $upgrader
37 public function set_upgrader(&$upgrader) {
38 if ( is_object($upgrader) )
39 $this->upgrader =& $upgrader;
46 public function add_strings() {
51 * @param string|false|WP_Error $result
53 public function set_result($result) {
54 $this->result = $result;
60 * @param string $context
61 * @param bool $allow_relaxed_file_ownership
64 public function request_filesystem_credentials( $error = false, $context = false, $allow_relaxed_file_ownership = false ) {
65 $url = $this->options['url'];
67 $context = $this->options['context'];
69 if ( !empty($this->options['nonce']) ) {
70 $url = wp_nonce_url($url, $this->options['nonce']);
73 $extra_fields = array();
75 return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership );
81 public function header() {
82 if ( $this->done_header ) {
85 $this->done_header = true;
86 echo '<div class="wrap">';
87 echo '<h1>' . $this->options['title'] . '</h1>';
93 public function footer() {
94 if ( $this->done_footer ) {
97 $this->done_footer = true;
103 * @param string|WP_Error $errors
105 public function error($errors) {
106 if ( ! $this->done_header )
108 if ( is_string($errors) ) {
109 $this->feedback($errors);
110 } elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
111 foreach ( $errors->get_error_messages() as $message ) {
112 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
113 $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
115 $this->feedback($message);
122 * @param string $string
124 public function feedback($string) {
125 if ( isset( $this->upgrader->strings[$string] ) )
126 $string = $this->upgrader->strings[$string];
128 if ( strpos($string, '%') !== false ) {
129 $args = func_get_args();
130 $args = array_splice($args, 1);
132 $args = array_map( 'strip_tags', $args );
133 $args = array_map( 'esc_html', $args );
134 $string = vsprintf($string, $args);
137 if ( empty($string) )
139 show_message($string);
145 public function before() {}
150 public function after() {}
153 * Output JavaScript that calls function to decrement the update counts.
157 * @param string $type Type of update count to decrement. Likely values include 'plugin',
158 * 'theme', 'translation', etc.
160 protected function decrement_update_count( $type ) {
161 if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
165 if ( defined( 'IFRAME_REQUEST' ) ) {
166 echo '<script type="text/javascript">
167 if ( window.postMessage && JSON ) {
168 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
172 echo '<script type="text/javascript">
174 if ( wp && wp.updates.decrementCount ) {
175 wp.updates.decrementCount( "' . $type . '" );
185 public function bulk_header() {}
190 public function bulk_footer() {}
194 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
197 * @subpackage Upgrader
200 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
202 public $plugin_active = false;
203 public $plugin_network_active = false;
209 public function __construct( $args = array() ) {
210 $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
211 $args = wp_parse_args($args, $defaults);
213 $this->plugin = $args['plugin'];
215 $this->plugin_active = is_plugin_active( $this->plugin );
216 $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
218 parent::__construct($args);
224 public function after() {
225 $this->plugin = $this->upgrader->plugin_info();
226 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
227 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>';
230 $this->decrement_update_count( 'plugin' );
232 $update_actions = array(
233 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
234 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>'
236 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
237 unset( $update_actions['activate_plugin'] );
240 * Filter the list of action links available following a single plugin update.
244 * @param array $update_actions Array of plugin action links.
245 * @param string $plugin Path to the plugin file.
247 $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
249 if ( ! empty($update_actions) )
250 $this->feedback(implode(' | ', (array)$update_actions));
255 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
258 * @subpackage Upgrader
261 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
262 public $in_loop = false;
266 public $error = false;
272 public function __construct($args = array()) {
273 $defaults = array( 'url' => '', 'nonce' => '' );
274 $args = wp_parse_args($args, $defaults);
276 parent::__construct($args);
282 public function add_strings() {
283 $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
284 /* translators: 1: Title of an update, 2: Error message */
285 $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s');
286 /* translators: 1: Title of an update */
287 $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
288 /* translators: 1: Title of an update */
289 $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>';
290 $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
294 * @param string $string
296 public function feedback($string) {
297 if ( isset( $this->upgrader->strings[$string] ) )
298 $string = $this->upgrader->strings[$string];
300 if ( strpos($string, '%') !== false ) {
301 $args = func_get_args();
302 $args = array_splice($args, 1);
304 $args = array_map( 'strip_tags', $args );
305 $args = array_map( 'esc_html', $args );
306 $string = vsprintf($string, $args);
309 if ( empty($string) )
311 if ( $this->in_loop )
312 echo "$string<br />\n";
314 echo "<p>$string</p>\n";
320 public function header() {
321 // Nothing, This will be displayed within a iframe.
327 public function footer() {
328 // Nothing, This will be displayed within a iframe.
333 * @param string|WP_Error $error
335 public function error($error) {
336 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
337 $this->error = $this->upgrader->strings[$error];
339 if ( is_wp_error($error) ) {
341 foreach ( $error->get_error_messages() as $emessage ) {
342 if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
343 $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
345 $messages[] = $emessage;
347 $this->error = implode(', ', $messages);
349 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
355 public function bulk_header() {
356 $this->feedback('skin_upgrade_start');
362 public function bulk_footer() {
363 $this->feedback('skin_upgrade_end');
368 * @param string $title
370 public function before($title = '') {
371 $this->in_loop = true;
372 printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
373 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
374 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
375 $this->flush_output();
380 * @param string $title
382 public function after($title = '') {
384 if ( $this->error || ! $this->result ) {
385 if ( $this->error ) {
386 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
388 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
391 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
393 if ( $this->result && ! is_wp_error( $this->result ) ) {
394 if ( ! $this->error )
395 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>';
396 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
400 $this->flush_output();
406 public function reset() {
407 $this->in_loop = false;
408 $this->error = false;
414 public function flush_output() {
415 wp_ob_end_flush_all();
420 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
421 public $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
423 public function add_strings() {
424 parent::add_strings();
425 $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
430 * @param string $title
432 public function before($title = '') {
433 parent::before($this->plugin_info['Title']);
438 * @param string $title
440 public function after($title = '') {
441 parent::after($this->plugin_info['Title']);
442 $this->decrement_update_count( 'plugin' );
448 public function bulk_footer() {
449 parent::bulk_footer();
450 $update_actions = array(
451 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
452 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
454 if ( ! current_user_can( 'activate_plugins' ) )
455 unset( $update_actions['plugins_page'] );
458 * Filter the list of action links available following bulk plugin updates.
462 * @param array $update_actions Array of plugin action links.
463 * @param array $plugin_info Array of information for the last-updated plugin.
465 $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
467 if ( ! empty($update_actions) )
468 $this->feedback(implode(' | ', (array)$update_actions));
472 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
473 public $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
475 public function add_strings() {
476 parent::add_strings();
477 $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
482 * @param string $title
484 public function before($title = '') {
485 parent::before( $this->theme_info->display('Name') );
490 * @param string $title
492 public function after($title = '') {
493 parent::after( $this->theme_info->display('Name') );
494 $this->decrement_update_count( 'theme' );
500 public function bulk_footer() {
501 parent::bulk_footer();
502 $update_actions = array(
503 'themes_page' => '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>',
504 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
506 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
507 unset( $update_actions['themes_page'] );
510 * Filter the list of action links available following bulk theme updates.
514 * @param array $update_actions Array of theme action links.
515 * @param array $theme_info Array of information for the last-updated theme.
517 $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
519 if ( ! empty($update_actions) )
520 $this->feedback(implode(' | ', (array)$update_actions));
525 * Plugin Installer Skin for WordPress Plugin Installer.
528 * @subpackage Upgrader
531 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
539 public function __construct($args = array()) {
540 $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
541 $args = wp_parse_args($args, $defaults);
543 $this->type = $args['type'];
544 $this->api = isset($args['api']) ? $args['api'] : array();
546 parent::__construct($args);
552 public function before() {
553 if ( !empty($this->api) )
554 $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
560 public function after() {
561 $plugin_file = $this->upgrader->plugin_info();
563 $install_actions = array();
565 $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
567 if ( 'import' == $from )
568 $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin & Run Importer' ) . '</a>';
570 $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>';
572 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
573 $install_actions['network_activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&networkwide=1&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Network Activate' ) . '</a>';
574 unset( $install_actions['activate_plugin'] );
577 if ( 'import' == $from ) {
578 $install_actions['importers_page'] = '<a href="' . admin_url( 'import.php' ) . '" target="_parent">' . __( 'Return to Importers' ) . '</a>';
579 } elseif ( $this->type == 'web' ) {
580 $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugin-install.php' ) . '" target="_parent">' . __( 'Return to Plugin Installer' ) . '</a>';
582 $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>';
585 if ( ! $this->result || is_wp_error($this->result) ) {
586 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
587 } elseif ( ! current_user_can( 'activate_plugins' ) ) {
588 unset( $install_actions['activate_plugin'] );
592 * Filter the list of action links available following a single plugin installation.
596 * @param array $install_actions Array of plugin action links.
597 * @param object $api Object containing WordPress.org API plugin data. Empty
598 * for non-API installs, such as when a plugin is installed
600 * @param string $plugin_file Path to the plugin file.
602 $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
604 if ( ! empty($install_actions) )
605 $this->feedback(implode(' | ', (array)$install_actions));
610 * Theme Installer Skin for the WordPress Theme Installer.
613 * @subpackage Upgrader
616 class Theme_Installer_Skin extends WP_Upgrader_Skin {
624 public function __construct($args = array()) {
625 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
626 $args = wp_parse_args($args, $defaults);
628 $this->type = $args['type'];
629 $this->api = isset($args['api']) ? $args['api'] : array();
631 parent::__construct($args);
637 public function before() {
638 if ( !empty($this->api) )
639 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
645 public function after() {
646 if ( empty($this->upgrader->result['destination_name']) )
649 $theme_info = $this->upgrader->theme_info();
650 if ( empty( $theme_info ) )
653 $name = $theme_info->display('Name');
654 $stylesheet = $this->upgrader->result['destination_name'];
655 $template = $theme_info->get_template();
657 $activate_link = add_query_arg( array(
658 'action' => 'activate',
659 'template' => urlencode( $template ),
660 'stylesheet' => urlencode( $stylesheet ),
661 ), admin_url('themes.php') );
662 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
664 $install_actions = array();
666 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
667 $install_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>';
669 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>';
671 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
672 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
674 if ( $this->type == 'web' )
675 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>';
676 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
677 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
679 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
680 unset( $install_actions['activate'], $install_actions['preview'] );
683 * Filter the list of action links available following a single theme installation.
687 * @param array $install_actions Array of theme action links.
688 * @param object $api Object containing WordPress.org API theme data.
689 * @param string $stylesheet Theme directory name.
690 * @param WP_Theme $theme_info Theme object.
692 $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
693 if ( ! empty($install_actions) )
694 $this->feedback(implode(' | ', (array)$install_actions));
699 * Theme Upgrader Skin for WordPress Theme Upgrades.
702 * @subpackage Upgrader
705 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
712 public function __construct($args = array()) {
713 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
714 $args = wp_parse_args($args, $defaults);
716 $this->theme = $args['theme'];
718 parent::__construct($args);
724 public function after() {
725 $this->decrement_update_count( 'theme' );
727 $update_actions = array();
728 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
729 $name = $theme_info->display('Name');
730 $stylesheet = $this->upgrader->result['destination_name'];
731 $template = $theme_info->get_template();
733 $activate_link = add_query_arg( array(
734 'action' => 'activate',
735 'template' => urlencode( $template ),
736 'stylesheet' => urlencode( $stylesheet ),
737 ), admin_url('themes.php') );
738 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
740 if ( get_stylesheet() == $stylesheet ) {
741 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
742 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';
744 } elseif ( current_user_can( 'switch_themes' ) ) {
745 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
746 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>';
748 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>';
751 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
752 unset( $update_actions['preview'], $update_actions['activate'] );
755 $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
758 * Filter the list of action links available following a single theme update.
762 * @param array $update_actions Array of theme action links.
763 * @param string $theme Theme directory name.
765 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
767 if ( ! empty($update_actions) )
768 $this->feedback(implode(' | ', (array)$update_actions));
773 * Translation Upgrader Skin for WordPress Translation Upgrades.
776 * @subpackage Upgrader
779 class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
780 public $language_update = null;
781 public $done_header = false;
782 public $done_footer = false;
783 public $display_footer_actions = true;
789 public function __construct( $args = array() ) {
790 $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
791 $args = wp_parse_args( $args, $defaults );
792 if ( $args['skip_header_footer'] ) {
793 $this->done_header = true;
794 $this->done_footer = true;
795 $this->display_footer_actions = false;
797 parent::__construct( $args );
803 public function before() {
804 $name = $this->upgrader->get_name_for_update( $this->language_update );
806 echo '<div class="update-messages lp-show-latest">';
808 printf( '<h2>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h2>', $name, $this->language_update->language );
813 * @param string|WP_Error $error
815 public function error( $error ) {
816 echo '<div class="lp-error">';
817 parent::error( $error );
824 public function after() {
831 public function bulk_footer() {
832 $this->decrement_update_count( 'translation' );
833 $update_actions = array();
834 $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>';
837 * Filter the list of action links available following a translations update.
841 * @param array $update_actions Array of translations update links.
843 $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
845 if ( $update_actions && $this->display_footer_actions )
846 $this->feedback( implode( ' | ', $update_actions ) );
851 * Upgrader Skin for Automatic WordPress Upgrades
853 * This skin is designed to be used when no output is intended, all output
854 * is captured and stored for the caller to process and log/email/discard.
857 * @subpackage Upgrader
860 class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
861 protected $messages = array();
866 * @param string $context
867 * @param bool $allow_relaxed_file_ownership
870 public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
872 $this->options['context'] = $context;
874 // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
875 // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
877 $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
887 public function get_upgrade_messages() {
888 return $this->messages;
892 * @param string|array|WP_Error $data
894 public function feedback( $data ) {
895 if ( is_wp_error( $data ) ) {
896 $string = $data->get_error_message();
897 } elseif ( is_array( $data ) ) {
902 if ( ! empty( $this->upgrader->strings[ $string ] ) )
903 $string = $this->upgrader->strings[ $string ];
905 if ( strpos( $string, '%' ) !== false ) {
906 $args = func_get_args();
907 $args = array_splice( $args, 1 );
908 if ( ! empty( $args ) )
909 $string = vsprintf( $string, $args );
912 $string = trim( $string );
914 // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
915 $string = wp_kses( $string, array(
924 if ( empty( $string ) )
927 $this->messages[] = $string;
933 public function header() {
940 public function footer() {
941 $output = ob_get_clean();
942 if ( ! empty( $output ) )
943 $this->feedback( $output );