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 // Currently used only when JS is off for a single plugin update?
228 echo '<iframe title="' . esc_attr__( 'Update progress' ) . '" style="border:0;overflow:hidden" width="100%" height="170" src="' . wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '"></iframe>';
231 $this->decrement_update_count( 'plugin' );
233 $update_actions = array(
234 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
235 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>'
237 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
238 unset( $update_actions['activate_plugin'] );
241 * Filter the list of action links available following a single plugin update.
245 * @param array $update_actions Array of plugin action links.
246 * @param string $plugin Path to the plugin file.
248 $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
250 if ( ! empty($update_actions) )
251 $this->feedback(implode(' | ', (array)$update_actions));
256 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
259 * @subpackage Upgrader
262 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
263 public $in_loop = false;
267 public $error = false;
273 public function __construct($args = array()) {
274 $defaults = array( 'url' => '', 'nonce' => '' );
275 $args = wp_parse_args($args, $defaults);
277 parent::__construct($args);
283 public function add_strings() {
284 $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
285 /* translators: 1: Title of an update, 2: Error message */
286 $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s');
287 /* translators: 1: Title of an update */
288 $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
289 /* translators: 1: Title of an update */
290 $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>';
291 $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
295 * @param string $string
297 public function feedback($string) {
298 if ( isset( $this->upgrader->strings[$string] ) )
299 $string = $this->upgrader->strings[$string];
301 if ( strpos($string, '%') !== false ) {
302 $args = func_get_args();
303 $args = array_splice($args, 1);
305 $args = array_map( 'strip_tags', $args );
306 $args = array_map( 'esc_html', $args );
307 $string = vsprintf($string, $args);
310 if ( empty($string) )
312 if ( $this->in_loop )
313 echo "$string<br />\n";
315 echo "<p>$string</p>\n";
321 public function header() {
322 // Nothing, This will be displayed within a iframe.
328 public function footer() {
329 // Nothing, This will be displayed within a iframe.
334 * @param string|WP_Error $error
336 public function error($error) {
337 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
338 $this->error = $this->upgrader->strings[$error];
340 if ( is_wp_error($error) ) {
342 foreach ( $error->get_error_messages() as $emessage ) {
343 if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
344 $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
346 $messages[] = $emessage;
348 $this->error = implode(', ', $messages);
350 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
356 public function bulk_header() {
357 $this->feedback('skin_upgrade_start');
363 public function bulk_footer() {
364 $this->feedback('skin_upgrade_end');
369 * @param string $title
371 public function before($title = '') {
372 $this->in_loop = true;
373 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 );
374 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
375 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
376 $this->flush_output();
381 * @param string $title
383 public function after($title = '') {
385 if ( $this->error || ! $this->result ) {
386 if ( $this->error ) {
387 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
389 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
392 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
394 if ( $this->result && ! is_wp_error( $this->result ) ) {
395 if ( ! $this->error )
396 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>';
397 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
401 $this->flush_output();
407 public function reset() {
408 $this->in_loop = false;
409 $this->error = false;
415 public function flush_output() {
416 wp_ob_end_flush_all();
421 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
422 public $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
424 public function add_strings() {
425 parent::add_strings();
426 $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
431 * @param string $title
433 public function before($title = '') {
434 parent::before($this->plugin_info['Title']);
439 * @param string $title
441 public function after($title = '') {
442 parent::after($this->plugin_info['Title']);
443 $this->decrement_update_count( 'plugin' );
449 public function bulk_footer() {
450 parent::bulk_footer();
451 $update_actions = array(
452 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
453 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
455 if ( ! current_user_can( 'activate_plugins' ) )
456 unset( $update_actions['plugins_page'] );
459 * Filter the list of action links available following bulk plugin updates.
463 * @param array $update_actions Array of plugin action links.
464 * @param array $plugin_info Array of information for the last-updated plugin.
466 $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
468 if ( ! empty($update_actions) )
469 $this->feedback(implode(' | ', (array)$update_actions));
473 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
474 public $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
476 public function add_strings() {
477 parent::add_strings();
478 $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
483 * @param string $title
485 public function before($title = '') {
486 parent::before( $this->theme_info->display('Name') );
491 * @param string $title
493 public function after($title = '') {
494 parent::after( $this->theme_info->display('Name') );
495 $this->decrement_update_count( 'theme' );
501 public function bulk_footer() {
502 parent::bulk_footer();
503 $update_actions = array(
504 'themes_page' => '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>',
505 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
507 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
508 unset( $update_actions['themes_page'] );
511 * Filter the list of action links available following bulk theme updates.
515 * @param array $update_actions Array of theme action links.
516 * @param array $theme_info Array of information for the last-updated theme.
518 $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
520 if ( ! empty($update_actions) )
521 $this->feedback(implode(' | ', (array)$update_actions));
526 * Plugin Installer Skin for WordPress Plugin Installer.
529 * @subpackage Upgrader
532 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
540 public function __construct($args = array()) {
541 $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
542 $args = wp_parse_args($args, $defaults);
544 $this->type = $args['type'];
545 $this->api = isset($args['api']) ? $args['api'] : array();
547 parent::__construct($args);
553 public function before() {
554 if ( !empty($this->api) )
555 $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
561 public function after() {
562 $plugin_file = $this->upgrader->plugin_info();
564 $install_actions = array();
566 $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
568 if ( 'import' == $from )
569 $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>';
571 $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>';
573 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
574 $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>';
575 unset( $install_actions['activate_plugin'] );
578 if ( 'import' == $from ) {
579 $install_actions['importers_page'] = '<a href="' . admin_url( 'import.php' ) . '" target="_parent">' . __( 'Return to Importers' ) . '</a>';
580 } elseif ( $this->type == 'web' ) {
581 $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugin-install.php' ) . '" target="_parent">' . __( 'Return to Plugin Installer' ) . '</a>';
583 $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>';
586 if ( ! $this->result || is_wp_error($this->result) ) {
587 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
588 } elseif ( ! current_user_can( 'activate_plugins' ) ) {
589 unset( $install_actions['activate_plugin'] );
593 * Filter the list of action links available following a single plugin installation.
597 * @param array $install_actions Array of plugin action links.
598 * @param object $api Object containing WordPress.org API plugin data. Empty
599 * for non-API installs, such as when a plugin is installed
601 * @param string $plugin_file Path to the plugin file.
603 $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
605 if ( ! empty($install_actions) )
606 $this->feedback(implode(' | ', (array)$install_actions));
611 * Theme Installer Skin for the WordPress Theme Installer.
614 * @subpackage Upgrader
617 class Theme_Installer_Skin extends WP_Upgrader_Skin {
625 public function __construct($args = array()) {
626 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
627 $args = wp_parse_args($args, $defaults);
629 $this->type = $args['type'];
630 $this->api = isset($args['api']) ? $args['api'] : array();
632 parent::__construct($args);
638 public function before() {
639 if ( !empty($this->api) )
640 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
646 public function after() {
647 if ( empty($this->upgrader->result['destination_name']) )
650 $theme_info = $this->upgrader->theme_info();
651 if ( empty( $theme_info ) )
654 $name = $theme_info->display('Name');
655 $stylesheet = $this->upgrader->result['destination_name'];
656 $template = $theme_info->get_template();
658 $activate_link = add_query_arg( array(
659 'action' => 'activate',
660 'template' => urlencode( $template ),
661 'stylesheet' => urlencode( $stylesheet ),
662 ), admin_url('themes.php') );
663 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
665 $install_actions = array();
667 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
668 $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>';
670 $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>';
672 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
673 $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>';
675 if ( $this->type == 'web' )
676 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>';
677 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
678 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
680 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
681 unset( $install_actions['activate'], $install_actions['preview'] );
684 * Filter the list of action links available following a single theme installation.
688 * @param array $install_actions Array of theme action links.
689 * @param object $api Object containing WordPress.org API theme data.
690 * @param string $stylesheet Theme directory name.
691 * @param WP_Theme $theme_info Theme object.
693 $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
694 if ( ! empty($install_actions) )
695 $this->feedback(implode(' | ', (array)$install_actions));
700 * Theme Upgrader Skin for WordPress Theme Upgrades.
703 * @subpackage Upgrader
706 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
713 public function __construct($args = array()) {
714 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
715 $args = wp_parse_args($args, $defaults);
717 $this->theme = $args['theme'];
719 parent::__construct($args);
725 public function after() {
726 $this->decrement_update_count( 'theme' );
728 $update_actions = array();
729 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
730 $name = $theme_info->display('Name');
731 $stylesheet = $this->upgrader->result['destination_name'];
732 $template = $theme_info->get_template();
734 $activate_link = add_query_arg( array(
735 'action' => 'activate',
736 'template' => urlencode( $template ),
737 'stylesheet' => urlencode( $stylesheet ),
738 ), admin_url('themes.php') );
739 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
741 if ( get_stylesheet() == $stylesheet ) {
742 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
743 $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>';
745 } elseif ( current_user_can( 'switch_themes' ) ) {
746 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
747 $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>';
749 $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>';
752 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
753 unset( $update_actions['preview'], $update_actions['activate'] );
756 $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
759 * Filter the list of action links available following a single theme update.
763 * @param array $update_actions Array of theme action links.
764 * @param string $theme Theme directory name.
766 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
768 if ( ! empty($update_actions) )
769 $this->feedback(implode(' | ', (array)$update_actions));
774 * Translation Upgrader Skin for WordPress Translation Upgrades.
777 * @subpackage Upgrader
780 class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
781 public $language_update = null;
782 public $done_header = false;
783 public $done_footer = false;
784 public $display_footer_actions = true;
790 public function __construct( $args = array() ) {
791 $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
792 $args = wp_parse_args( $args, $defaults );
793 if ( $args['skip_header_footer'] ) {
794 $this->done_header = true;
795 $this->done_footer = true;
796 $this->display_footer_actions = false;
798 parent::__construct( $args );
804 public function before() {
805 $name = $this->upgrader->get_name_for_update( $this->language_update );
807 echo '<div class="update-messages lp-show-latest">';
809 printf( '<h2>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h2>', $name, $this->language_update->language );
814 * @param string|WP_Error $error
816 public function error( $error ) {
817 echo '<div class="lp-error">';
818 parent::error( $error );
825 public function after() {
832 public function bulk_footer() {
833 $this->decrement_update_count( 'translation' );
834 $update_actions = array();
835 $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>';
838 * Filter the list of action links available following a translations update.
842 * @param array $update_actions Array of translations update links.
844 $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
846 if ( $update_actions && $this->display_footer_actions )
847 $this->feedback( implode( ' | ', $update_actions ) );
852 * Upgrader Skin for Automatic WordPress Upgrades
854 * This skin is designed to be used when no output is intended, all output
855 * is captured and stored for the caller to process and log/email/discard.
858 * @subpackage Upgrader
861 class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
862 protected $messages = array();
867 * @param string $context
868 * @param bool $allow_relaxed_file_ownership
871 public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
873 $this->options['context'] = $context;
875 // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
876 // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
878 $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
888 public function get_upgrade_messages() {
889 return $this->messages;
893 * @param string|array|WP_Error $data
895 public function feedback( $data ) {
896 if ( is_wp_error( $data ) ) {
897 $string = $data->get_error_message();
898 } elseif ( is_array( $data ) ) {
903 if ( ! empty( $this->upgrader->strings[ $string ] ) )
904 $string = $this->upgrader->strings[ $string ];
906 if ( strpos( $string, '%' ) !== false ) {
907 $args = func_get_args();
908 $args = array_splice( $args, 1 );
909 if ( ! empty( $args ) )
910 $string = vsprintf( $string, $args );
913 $string = trim( $string );
915 // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
916 $string = wp_kses( $string, array(
925 if ( empty( $string ) )
928 $this->messages[] = $string;
934 public function header() {
941 public function footer() {
942 $output = ob_get_clean();
943 if ( ! empty( $output ) )
944 $this->feedback( $output );