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 $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>');
285 $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
286 $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>';
287 $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
291 * @param string $string
293 public function feedback($string) {
294 if ( isset( $this->upgrader->strings[$string] ) )
295 $string = $this->upgrader->strings[$string];
297 if ( strpos($string, '%') !== false ) {
298 $args = func_get_args();
299 $args = array_splice($args, 1);
301 $args = array_map( 'strip_tags', $args );
302 $args = array_map( 'esc_html', $args );
303 $string = vsprintf($string, $args);
306 if ( empty($string) )
308 if ( $this->in_loop )
309 echo "$string<br />\n";
311 echo "<p>$string</p>\n";
317 public function header() {
318 // Nothing, This will be displayed within a iframe.
324 public function footer() {
325 // Nothing, This will be displayed within a iframe.
330 * @param string|WP_Error $error
332 public function error($error) {
333 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
334 $this->error = $this->upgrader->strings[$error];
336 if ( is_wp_error($error) ) {
338 foreach ( $error->get_error_messages() as $emessage ) {
339 if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
340 $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
342 $messages[] = $emessage;
344 $this->error = implode(', ', $messages);
346 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
352 public function bulk_header() {
353 $this->feedback('skin_upgrade_start');
359 public function bulk_footer() {
360 $this->feedback('skin_upgrade_end');
365 * @param string $title
367 public function before($title = '') {
368 $this->in_loop = true;
369 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);
370 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
371 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
372 $this->flush_output();
377 * @param string $title
379 public function after($title = '') {
381 if ( $this->error || ! $this->result ) {
383 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
385 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
387 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
389 if ( $this->result && ! is_wp_error( $this->result ) ) {
390 if ( ! $this->error )
391 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>';
392 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
396 $this->flush_output();
402 public function reset() {
403 $this->in_loop = false;
404 $this->error = false;
410 public function flush_output() {
411 wp_ob_end_flush_all();
416 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
417 public $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
419 public function add_strings() {
420 parent::add_strings();
421 $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
426 * @param string $title
428 public function before($title = '') {
429 parent::before($this->plugin_info['Title']);
434 * @param string $title
436 public function after($title = '') {
437 parent::after($this->plugin_info['Title']);
438 $this->decrement_update_count( 'plugin' );
444 public function bulk_footer() {
445 parent::bulk_footer();
446 $update_actions = array(
447 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
448 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
450 if ( ! current_user_can( 'activate_plugins' ) )
451 unset( $update_actions['plugins_page'] );
454 * Filter the list of action links available following bulk plugin updates.
458 * @param array $update_actions Array of plugin action links.
459 * @param array $plugin_info Array of information for the last-updated plugin.
461 $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
463 if ( ! empty($update_actions) )
464 $this->feedback(implode(' | ', (array)$update_actions));
468 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
469 public $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
471 public function add_strings() {
472 parent::add_strings();
473 $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
478 * @param string $title
480 public function before($title = '') {
481 parent::before( $this->theme_info->display('Name') );
486 * @param string $title
488 public function after($title = '') {
489 parent::after( $this->theme_info->display('Name') );
490 $this->decrement_update_count( 'theme' );
496 public function bulk_footer() {
497 parent::bulk_footer();
498 $update_actions = array(
499 'themes_page' => '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>',
500 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
502 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
503 unset( $update_actions['themes_page'] );
506 * Filter the list of action links available following bulk theme updates.
510 * @param array $update_actions Array of theme action links.
511 * @param array $theme_info Array of information for the last-updated theme.
513 $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
515 if ( ! empty($update_actions) )
516 $this->feedback(implode(' | ', (array)$update_actions));
521 * Plugin Installer Skin for WordPress Plugin Installer.
524 * @subpackage Upgrader
527 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
535 public function __construct($args = array()) {
536 $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
537 $args = wp_parse_args($args, $defaults);
539 $this->type = $args['type'];
540 $this->api = isset($args['api']) ? $args['api'] : array();
542 parent::__construct($args);
548 public function before() {
549 if ( !empty($this->api) )
550 $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
556 public function after() {
557 $plugin_file = $this->upgrader->plugin_info();
559 $install_actions = array();
561 $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
563 if ( 'import' == $from )
564 $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>';
566 $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>';
568 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
569 $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>';
570 unset( $install_actions['activate_plugin'] );
573 if ( 'import' == $from ) {
574 $install_actions['importers_page'] = '<a href="' . admin_url( 'import.php' ) . '" target="_parent">' . __( 'Return to Importers' ) . '</a>';
575 } elseif ( $this->type == 'web' ) {
576 $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugin-install.php' ) . '" target="_parent">' . __( 'Return to Plugin Installer' ) . '</a>';
578 $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>';
581 if ( ! $this->result || is_wp_error($this->result) ) {
582 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
583 } elseif ( ! current_user_can( 'activate_plugins' ) ) {
584 unset( $install_actions['activate_plugin'] );
588 * Filter the list of action links available following a single plugin installation.
592 * @param array $install_actions Array of plugin action links.
593 * @param object $api Object containing WordPress.org API plugin data. Empty
594 * for non-API installs, such as when a plugin is installed
596 * @param string $plugin_file Path to the plugin file.
598 $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
600 if ( ! empty($install_actions) )
601 $this->feedback(implode(' | ', (array)$install_actions));
606 * Theme Installer Skin for the WordPress Theme Installer.
609 * @subpackage Upgrader
612 class Theme_Installer_Skin extends WP_Upgrader_Skin {
620 public function __construct($args = array()) {
621 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
622 $args = wp_parse_args($args, $defaults);
624 $this->type = $args['type'];
625 $this->api = isset($args['api']) ? $args['api'] : array();
627 parent::__construct($args);
633 public function before() {
634 if ( !empty($this->api) )
635 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
641 public function after() {
642 if ( empty($this->upgrader->result['destination_name']) )
645 $theme_info = $this->upgrader->theme_info();
646 if ( empty( $theme_info ) )
649 $name = $theme_info->display('Name');
650 $stylesheet = $this->upgrader->result['destination_name'];
651 $template = $theme_info->get_template();
653 $activate_link = add_query_arg( array(
654 'action' => 'activate',
655 'template' => urlencode( $template ),
656 'stylesheet' => urlencode( $stylesheet ),
657 ), admin_url('themes.php') );
658 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
660 $install_actions = array();
662 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
663 $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>';
665 $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>';
667 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
668 $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>';
670 if ( $this->type == 'web' )
671 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>';
672 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
673 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
675 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
676 unset( $install_actions['activate'], $install_actions['preview'] );
679 * Filter the list of action links available following a single theme installation.
683 * @param array $install_actions Array of theme action links.
684 * @param object $api Object containing WordPress.org API theme data.
685 * @param string $stylesheet Theme directory name.
686 * @param WP_Theme $theme_info Theme object.
688 $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
689 if ( ! empty($install_actions) )
690 $this->feedback(implode(' | ', (array)$install_actions));
695 * Theme Upgrader Skin for WordPress Theme Upgrades.
698 * @subpackage Upgrader
701 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
708 public function __construct($args = array()) {
709 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
710 $args = wp_parse_args($args, $defaults);
712 $this->theme = $args['theme'];
714 parent::__construct($args);
720 public function after() {
721 $this->decrement_update_count( 'theme' );
723 $update_actions = array();
724 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
725 $name = $theme_info->display('Name');
726 $stylesheet = $this->upgrader->result['destination_name'];
727 $template = $theme_info->get_template();
729 $activate_link = add_query_arg( array(
730 'action' => 'activate',
731 'template' => urlencode( $template ),
732 'stylesheet' => urlencode( $stylesheet ),
733 ), admin_url('themes.php') );
734 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
736 if ( get_stylesheet() == $stylesheet ) {
737 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
738 $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>';
740 } elseif ( current_user_can( 'switch_themes' ) ) {
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">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>';
744 $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>';
747 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
748 unset( $update_actions['preview'], $update_actions['activate'] );
751 $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
754 * Filter the list of action links available following a single theme update.
758 * @param array $update_actions Array of theme action links.
759 * @param string $theme Theme directory name.
761 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
763 if ( ! empty($update_actions) )
764 $this->feedback(implode(' | ', (array)$update_actions));
769 * Translation Upgrader Skin for WordPress Translation Upgrades.
772 * @subpackage Upgrader
775 class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
776 public $language_update = null;
777 public $done_header = false;
778 public $done_footer = false;
779 public $display_footer_actions = true;
785 public function __construct( $args = array() ) {
786 $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
787 $args = wp_parse_args( $args, $defaults );
788 if ( $args['skip_header_footer'] ) {
789 $this->done_header = true;
790 $this->done_footer = true;
791 $this->display_footer_actions = false;
793 parent::__construct( $args );
799 public function before() {
800 $name = $this->upgrader->get_name_for_update( $this->language_update );
802 echo '<div class="update-messages lp-show-latest">';
804 printf( '<h4>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h4>', $name, $this->language_update->language );
809 * @param string|WP_Error $error
811 public function error( $error ) {
812 echo '<div class="lp-error">';
813 parent::error( $error );
820 public function after() {
827 public function bulk_footer() {
828 $this->decrement_update_count( 'translation' );
829 $update_actions = array();
830 $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>';
833 * Filter the list of action links available following a translations update.
837 * @param array $update_actions Array of translations update links.
839 $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
841 if ( $update_actions && $this->display_footer_actions )
842 $this->feedback( implode( ' | ', $update_actions ) );
847 * Upgrader Skin for Automatic WordPress Upgrades
849 * This skin is designed to be used when no output is intended, all output
850 * is captured and stored for the caller to process and log/email/discard.
853 * @subpackage Upgrader
856 class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
857 protected $messages = array();
862 * @param string $context
863 * @param bool $allow_relaxed_file_ownership
866 public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
868 $this->options['context'] = $context;
870 // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
871 // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
873 $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
883 public function get_upgrade_messages() {
884 return $this->messages;
888 * @param string|array|WP_Error $data
890 public function feedback( $data ) {
891 if ( is_wp_error( $data ) ) {
892 $string = $data->get_error_message();
893 } elseif ( is_array( $data ) ) {
898 if ( ! empty( $this->upgrader->strings[ $string ] ) )
899 $string = $this->upgrader->strings[ $string ];
901 if ( strpos( $string, '%' ) !== false ) {
902 $args = func_get_args();
903 $args = array_splice( $args, 1 );
904 if ( ! empty( $args ) )
905 $string = vsprintf( $string, $args );
908 $string = trim( $string );
910 // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
911 $string = wp_kses( $string, array(
920 if ( empty( $string ) )
923 $this->messages[] = $string;
929 public function header() {
936 public function footer() {
937 $output = ob_get_clean();
938 if ( ! empty( $output ) )
939 $this->feedback( $output );