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 var $done_header = false;
23 function __construct($args = array()) {
24 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
25 $this->options = wp_parse_args($args, $defaults);
28 function set_upgrader(&$upgrader) {
29 if ( is_object($upgrader) )
30 $this->upgrader =& $upgrader;
34 function add_strings() {
37 function set_result($result) {
38 $this->result = $result;
41 function request_filesystem_credentials($error = false) {
42 $url = $this->options['url'];
43 $context = $this->options['context'];
44 if ( !empty($this->options['nonce']) )
45 $url = wp_nonce_url($url, $this->options['nonce']);
46 return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
50 if ( $this->done_header )
52 $this->done_header = true;
53 echo '<div class="wrap">';
54 echo '<h2>' . $this->options['title'] . '</h2>';
60 function error($errors) {
61 if ( ! $this->done_header )
63 if ( is_string($errors) ) {
64 $this->feedback($errors);
65 } elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
66 foreach ( $errors->get_error_messages() as $message ) {
67 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
68 $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
70 $this->feedback($message);
75 function feedback($string) {
76 if ( isset( $this->upgrader->strings[$string] ) )
77 $string = $this->upgrader->strings[$string];
79 if ( strpos($string, '%') !== false ) {
80 $args = func_get_args();
81 $args = array_splice($args, 1);
83 $args = array_map( 'strip_tags', $args );
84 $args = array_map( 'esc_html', $args );
85 $string = vsprintf($string, $args);
90 show_message($string);
96 * Output JavaScript that calls function to decrement the update counts.
100 * @param string $type Type of update count to decrement. Likely values include 'plugin',
101 * 'theme', 'translation', etc.
103 protected function decrement_update_count( $type ) {
104 if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
107 echo '<script type="text/javascript">
109 if ( wp && wp.updates.decrementCount ) {
110 wp.updates.decrementCount( "' . $type . '" );
118 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
121 * @subpackage Upgrader
124 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
126 var $plugin_active = false;
127 var $plugin_network_active = false;
129 function __construct($args = array()) {
130 $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
131 $args = wp_parse_args($args, $defaults);
133 $this->plugin = $args['plugin'];
135 $this->plugin_active = is_plugin_active( $this->plugin );
136 $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
138 parent::__construct($args);
142 $this->plugin = $this->upgrader->plugin_info();
143 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
144 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>';
147 $this->decrement_update_count( 'plugin' );
149 $update_actions = array(
150 '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>',
151 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
153 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
154 unset( $update_actions['activate_plugin'] );
157 * Filter the list of action links available following a single plugin update.
161 * @param array $update_actions Array of plugin action links.
162 * @param string $plugin Path to the plugin file.
164 $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
166 if ( ! empty($update_actions) )
167 $this->feedback(implode(' | ', (array)$update_actions));
172 * Plugin Upgrader Skin for WordPress Plugin Upgrades.
175 * @subpackage Upgrader
178 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
179 var $in_loop = false;
182 function __construct($args = array()) {
183 $defaults = array( 'url' => '', 'nonce' => '' );
184 $args = wp_parse_args($args, $defaults);
186 parent::__construct($args);
189 function add_strings() {
190 $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
191 $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>');
192 $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
193 $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>';
194 $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
197 function feedback($string) {
198 if ( isset( $this->upgrader->strings[$string] ) )
199 $string = $this->upgrader->strings[$string];
201 if ( strpos($string, '%') !== false ) {
202 $args = func_get_args();
203 $args = array_splice($args, 1);
205 $args = array_map( 'strip_tags', $args );
206 $args = array_map( 'esc_html', $args );
207 $string = vsprintf($string, $args);
210 if ( empty($string) )
212 if ( $this->in_loop )
213 echo "$string<br />\n";
215 echo "<p>$string</p>\n";
219 // Nothing, This will be displayed within a iframe.
223 // Nothing, This will be displayed within a iframe.
225 function error($error) {
226 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
227 $this->error = $this->upgrader->strings[$error];
229 if ( is_wp_error($error) ) {
230 foreach ( $error->get_error_messages() as $emessage ) {
231 if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
232 $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
234 $messages[] = $emessage;
236 $this->error = implode(', ', $messages);
238 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
241 function bulk_header() {
242 $this->feedback('skin_upgrade_start');
245 function bulk_footer() {
246 $this->feedback('skin_upgrade_end');
249 function before($title = '') {
250 $this->in_loop = true;
251 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);
252 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
253 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
254 $this->flush_output();
257 function after($title = '') {
259 if ( $this->error || ! $this->result ) {
261 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
263 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
265 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
267 if ( $this->result && ! is_wp_error( $this->result ) ) {
268 if ( ! $this->error )
269 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>';
270 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
274 $this->flush_output();
278 $this->in_loop = false;
279 $this->error = false;
282 function flush_output() {
283 wp_ob_end_flush_all();
288 * Output JavaScript that sends message to parent window to decrement the update counts.
292 * @param string $type Type of update count to decrement. Likely values include 'plugin',
293 * 'theme', 'translation', etc.
295 protected function decrement_update_count( $type ) {
296 if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
299 echo '<script type="text/javascript">
300 if ( window.postMessage && JSON ) {
301 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
307 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
308 var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
310 function __construct($args = array()) {
311 parent::__construct($args);
314 function add_strings() {
315 parent::add_strings();
316 $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
319 function before($title = '') {
320 parent::before($this->plugin_info['Title']);
323 function after($title = '') {
324 parent::after($this->plugin_info['Title']);
325 $this->decrement_update_count( 'plugin' );
327 function bulk_footer() {
328 parent::bulk_footer();
329 $update_actions = array(
330 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
331 '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>'
333 if ( ! current_user_can( 'activate_plugins' ) )
334 unset( $update_actions['plugins_page'] );
337 * Filter the list of action links available following bulk plugin updates.
341 * @param array $update_actions Array of plugin action links.
342 * @param array $plugin_info Array of information for the last-updated plugin.
344 $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
346 if ( ! empty($update_actions) )
347 $this->feedback(implode(' | ', (array)$update_actions));
351 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
352 var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
354 function __construct($args = array()) {
355 parent::__construct($args);
358 function add_strings() {
359 parent::add_strings();
360 $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
363 function before($title = '') {
364 parent::before( $this->theme_info->display('Name') );
367 function after($title = '') {
368 parent::after( $this->theme_info->display('Name') );
369 $this->decrement_update_count( 'theme' );
372 function bulk_footer() {
373 parent::bulk_footer();
374 $update_actions = array(
375 'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
376 '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>'
378 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
379 unset( $update_actions['themes_page'] );
382 * Filter the list of action links available following bulk theme updates.
386 * @param array $update_actions Array of theme action links.
387 * @param array $theme_info Array of information for the last-updated theme.
389 $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
391 if ( ! empty($update_actions) )
392 $this->feedback(implode(' | ', (array)$update_actions));
397 * Plugin Installer Skin for WordPress Plugin Installer.
400 * @subpackage Upgrader
403 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
407 function __construct($args = array()) {
408 $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
409 $args = wp_parse_args($args, $defaults);
411 $this->type = $args['type'];
412 $this->api = isset($args['api']) ? $args['api'] : array();
414 parent::__construct($args);
418 if ( !empty($this->api) )
419 $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
424 $plugin_file = $this->upgrader->plugin_info();
426 $install_actions = array();
428 $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
430 if ( 'import' == $from )
431 $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>';
433 $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>';
435 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
436 $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>';
437 unset( $install_actions['activate_plugin'] );
440 if ( 'import' == $from )
441 $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
442 else if ( $this->type == 'web' )
443 $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>';
445 $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>';
447 if ( ! $this->result || is_wp_error($this->result) ) {
448 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
449 } elseif ( ! current_user_can( 'activate_plugins' ) ) {
450 unset( $install_actions['activate_plugin'] );
454 * Filter the list of action links available following a single plugin installation.
458 * @param array $install_actions Array of plugin action links.
459 * @param object $api Object containing WordPress.org API plugin data. Empty
460 * for non-API installs, such as when a plugin is installed
462 * @param string $plugin_file Path to the plugin file.
464 $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
466 if ( ! empty($install_actions) )
467 $this->feedback(implode(' | ', (array)$install_actions));
472 * Theme Installer Skin for the WordPress Theme Installer.
475 * @subpackage Upgrader
478 class Theme_Installer_Skin extends WP_Upgrader_Skin {
482 function __construct($args = array()) {
483 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
484 $args = wp_parse_args($args, $defaults);
486 $this->type = $args['type'];
487 $this->api = isset($args['api']) ? $args['api'] : array();
489 parent::__construct($args);
493 if ( !empty($this->api) )
494 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
498 if ( empty($this->upgrader->result['destination_name']) )
501 $theme_info = $this->upgrader->theme_info();
502 if ( empty( $theme_info ) )
505 $name = $theme_info->display('Name');
506 $stylesheet = $this->upgrader->result['destination_name'];
507 $template = $theme_info->get_template();
509 $preview_link = add_query_arg( array(
511 'template' => urlencode( $template ),
512 'stylesheet' => urlencode( $stylesheet ),
513 ), trailingslashit( home_url() ) );
515 $activate_link = add_query_arg( array(
516 'action' => 'activate',
517 'template' => urlencode( $template ),
518 'stylesheet' => urlencode( $stylesheet ),
519 ), admin_url('themes.php') );
520 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
522 $install_actions = array();
523 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
524 $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>';
525 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
527 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
528 $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>';
530 if ( $this->type == 'web' )
531 $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>';
532 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
533 $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
535 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
536 unset( $install_actions['activate'], $install_actions['preview'] );
539 * Filter the list of action links available following a single theme installation.
543 * @param array $install_actions Array of theme action links.
544 * @param object $api Object containing WordPress.org API theme data.
545 * @param string $stylesheet Theme directory name.
546 * @param WP_Theme $theme_info Theme object.
548 $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
549 if ( ! empty($install_actions) )
550 $this->feedback(implode(' | ', (array)$install_actions));
555 * Theme Upgrader Skin for WordPress Theme Upgrades.
558 * @subpackage Upgrader
561 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
564 function __construct($args = array()) {
565 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
566 $args = wp_parse_args($args, $defaults);
568 $this->theme = $args['theme'];
570 parent::__construct($args);
574 $this->decrement_update_count( 'theme' );
576 $update_actions = array();
577 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
578 $name = $theme_info->display('Name');
579 $stylesheet = $this->upgrader->result['destination_name'];
580 $template = $theme_info->get_template();
582 $preview_link = add_query_arg( array(
584 'template' => urlencode( $template ),
585 'stylesheet' => urlencode( $stylesheet ),
586 ), trailingslashit( home_url() ) );
588 $activate_link = add_query_arg( array(
589 'action' => 'activate',
590 'template' => urlencode( $template ),
591 'stylesheet' => urlencode( $stylesheet ),
592 ), admin_url('themes.php') );
593 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
595 if ( get_stylesheet() == $stylesheet ) {
596 if ( current_user_can( 'edit_theme_options' ) )
597 $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 $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>';
601 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
604 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
605 unset( $update_actions['preview'], $update_actions['activate'] );
608 $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>';
611 * Filter the list of action links available following a single theme update.
615 * @param array $update_actions Array of theme action links.
616 * @param string $theme Theme directory name.
618 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
620 if ( ! empty($update_actions) )
621 $this->feedback(implode(' | ', (array)$update_actions));
626 * Translation Upgrader Skin for WordPress Translation Upgrades.
629 * @subpackage Upgrader
632 class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
633 var $language_update = null;
634 var $done_header = false;
635 var $display_footer_actions = true;
637 function __construct( $args = array() ) {
638 $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
639 $args = wp_parse_args( $args, $defaults );
640 if ( $args['skip_header_footer'] ) {
641 $this->done_header = true;
642 $this->display_footer_actions = false;
644 parent::__construct( $args );
648 $name = $this->upgrader->get_name_for_update( $this->language_update );
650 echo '<div class="update-messages lp-show-latest">';
652 printf( '<h4>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h4>', $name, $this->language_update->language );
655 function error( $error ) {
656 echo '<div class="lp-error">';
657 parent::error( $error );
665 function bulk_footer() {
666 $this->decrement_update_count( 'translation' );
667 $update_actions = array();
668 $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>';
671 * Filter the list of action links available following a translations update.
675 * @param array $update_actions Array of translations update links.
677 $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
679 if ( $update_actions && $this->display_footer_actions )
680 $this->feedback( implode( ' | ', $update_actions ) );
687 * Upgrader Skin for Automatic WordPress Upgrades
689 * This skin is designed to be used when no output is intended, all output
690 * is captured and stored for the caller to process and log/email/discard.
693 * @subpackage Upgrader
696 class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
697 protected $messages = array();
699 function request_filesystem_credentials( $error = false, $context = '' ) {
701 $this->options['context'] = $context;
702 // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
703 // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
705 $result = parent::request_filesystem_credentials( $error );
710 function get_upgrade_messages() {
711 return $this->messages;
714 function feedback( $data ) {
715 if ( is_wp_error( $data ) )
716 $string = $data->get_error_message();
717 else if ( is_array( $data ) )
722 if ( ! empty( $this->upgrader->strings[ $string ] ) )
723 $string = $this->upgrader->strings[ $string ];
725 if ( strpos( $string, '%' ) !== false ) {
726 $args = func_get_args();
727 $args = array_splice( $args, 1 );
728 if ( ! empty( $args ) )
729 $string = vsprintf( $string, $args );
732 $string = trim( $string );
734 // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
735 $string = wp_kses( $string, array(
744 if ( empty( $string ) )
747 $this->messages[] = $string;
755 $output = ob_get_contents();
756 if ( ! empty( $output ) )
757 $this->feedback( $output );
761 function bulk_header() {}
762 function bulk_footer() {}