X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f5fcdc7994bb67cce809bc4777944ae8b7fad4a4..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-admin/includes/class-wp-upgrader-skins.php?ds=sidebyside diff --git a/wp-admin/includes/class-wp-upgrader-skins.php b/wp-admin/includes/class-wp-upgrader-skins.php index 942542e0..3e9a5556 100644 --- a/wp-admin/includes/class-wp-upgrader-skins.php +++ b/wp-admin/includes/class-wp-upgrader-skins.php @@ -22,6 +22,10 @@ class WP_Upgrader_Skin { public $result = false; public $options = array(); + /** + * + * @param array $args + */ public function __construct($args = array()) { $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); $this->options = wp_parse_args($args, $defaults); @@ -36,13 +40,27 @@ class WP_Upgrader_Skin { $this->add_strings(); } + /** + * @access public + */ public function add_strings() { } + /** + * + * @param string|false|WP_Error $result + */ public function set_result($result) { $this->result = $result; } + /** + * + * @param bool $error + * @param string $context + * @param bool $allow_relaxed_file_ownership + * @return type + */ public function request_filesystem_credentials( $error = false, $context = false, $allow_relaxed_file_ownership = false ) { $url = $this->options['url']; if ( ! $context ) { @@ -57,14 +75,21 @@ class WP_Upgrader_Skin { return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership ); } + /** + * @access public + */ public function header() { if ( $this->done_header ) { return; } $this->done_header = true; echo '
'; - echo '

' . $this->options['title'] . '

'; + echo '

' . $this->options['title'] . '

'; } + + /** + * @access public + */ public function footer() { if ( $this->done_footer ) { return; @@ -73,6 +98,10 @@ class WP_Upgrader_Skin { echo '
'; } + /** + * + * @param string|WP_Error $errors + */ public function error($errors) { if ( ! $this->done_header ) $this->header(); @@ -88,6 +117,10 @@ class WP_Upgrader_Skin { } } + /** + * + * @param string $string + */ public function feedback($string) { if ( isset( $this->upgrader->strings[$string] ) ) $string = $this->upgrader->strings[$string]; @@ -105,7 +138,15 @@ class WP_Upgrader_Skin { return; show_message($string); } + + /** + * @access public + */ public function before() {} + + /** + * @access public + */ public function after() {} /** @@ -138,7 +179,14 @@ class WP_Upgrader_Skin { } } + /** + * @access public + */ public function bulk_header() {} + + /** + * @access public + */ public function bulk_footer() {} } @@ -154,7 +202,11 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { public $plugin_active = false; public $plugin_network_active = false; - public function __construct($args = array()) { + /** + * + * @param array $args + */ + public function __construct( $args = array() ) { $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); $args = wp_parse_args($args, $defaults); @@ -166,6 +218,9 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { parent::__construct($args); } + /** + * @access public + */ public function after() { $this->plugin = $this->upgrader->plugin_info(); if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ @@ -175,8 +230,8 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { $this->decrement_update_count( 'plugin' ); $update_actions = array( - 'activate_plugin' => '' . __('Activate Plugin') . '', - 'plugins_page' => '' . __('Return to Plugins page') . '' + 'activate_plugin' => '' . __( 'Activate Plugin' ) . '', + 'plugins_page' => '' . __( 'Return to Plugins page' ) . '' ); if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) unset( $update_actions['activate_plugin'] ); @@ -210,6 +265,10 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { */ public $error = false; + /** + * + * @param array $args + */ public function __construct($args = array()) { $defaults = array( 'url' => '', 'nonce' => '' ); $args = wp_parse_args($args, $defaults); @@ -217,6 +276,9 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { parent::__construct($args); } + /** + * @access public + */ public function add_strings() { $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.'); $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s'); @@ -249,13 +311,24 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { echo "

$string

\n"; } + /** + * @access public + */ public function header() { // Nothing, This will be displayed within a iframe. } + /** + * @access public + */ public function footer() { // Nothing, This will be displayed within a iframe. } + + /** + * + * @param string|WP_Error $error + */ public function error($error) { if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) $this->error = $this->upgrader->strings[$error]; @@ -273,14 +346,24 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { echo ''; } + /** + * @access public + */ public function bulk_header() { $this->feedback('skin_upgrade_start'); } + /** + * @access public + */ public function bulk_footer() { $this->feedback('skin_upgrade_end'); } + /** + * + * @param string $title + */ public function before($title = '') { $this->in_loop = true; printf( '

' . $this->upgrader->strings['skin_before_update_header'] . '

', $title, $this->upgrader->update_current, $this->upgrader->update_count); @@ -289,6 +372,10 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { $this->flush_output(); } + /** + * + * @param string $title + */ public function after($title = '') { echo '

'; if ( $this->error || ! $this->result ) { @@ -309,11 +396,17 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { $this->flush_output(); } + /** + * @access public + */ public function reset() { $this->in_loop = false; $this->error = false; } + /** + * @access public + */ public function flush_output() { wp_ob_end_flush_all(); flush(); @@ -328,19 +421,31 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)'); } + /** + * + * @param string $title + */ public function before($title = '') { parent::before($this->plugin_info['Title']); } + /** + * + * @param string $title + */ public function after($title = '') { parent::after($this->plugin_info['Title']); $this->decrement_update_count( 'plugin' ); } + + /** + * @access public + */ public function bulk_footer() { parent::bulk_footer(); $update_actions = array( - 'plugins_page' => '' . __('Return to Plugins page') . '', - 'updates_page' => '' . __('Return to WordPress Updates') . '' + 'plugins_page' => '' . __( 'Return to Plugins page' ) . '', + 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . '' ); if ( ! current_user_can( 'activate_plugins' ) ) unset( $update_actions['plugins_page'] ); @@ -368,20 +473,31 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)'); } + /** + * + * @param string $title + */ public function before($title = '') { parent::before( $this->theme_info->display('Name') ); } + /** + * + * @param string $title + */ public function after($title = '') { parent::after( $this->theme_info->display('Name') ); $this->decrement_update_count( 'theme' ); } + /** + * @access public + */ public function bulk_footer() { parent::bulk_footer(); $update_actions = array( - 'themes_page' => '' . __('Return to Themes page') . '', - 'updates_page' => '' . __('Return to WordPress Updates') . '' + 'themes_page' => '' . __( 'Return to Themes page' ) . '', + 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . '' ); if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) unset( $update_actions['themes_page'] ); @@ -412,6 +528,10 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { public $api; public $type; + /** + * + * @param array $args + */ public function __construct($args = array()) { $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' ); $args = wp_parse_args($args, $defaults); @@ -422,13 +542,18 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { parent::__construct($args); } + /** + * @access public + */ public function before() { if ( !empty($this->api) ) $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin %s %s.'), $this->api->name, $this->api->version); } + /** + * @access public + */ public function after() { - $plugin_file = $this->upgrader->plugin_info(); $install_actions = array(); @@ -436,21 +561,21 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins'; if ( 'import' == $from ) - $install_actions['activate_plugin'] = '' . __('Activate Plugin & Run Importer') . ''; + $install_actions['activate_plugin'] = '' . __( 'Activate Plugin & Run Importer' ) . ''; else - $install_actions['activate_plugin'] = '' . __('Activate Plugin') . ''; + $install_actions['activate_plugin'] = '' . __( 'Activate Plugin' ) . ''; if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { - $install_actions['network_activate'] = '' . __('Network Activate') . ''; + $install_actions['network_activate'] = '' . __( 'Network Activate' ) . ''; unset( $install_actions['activate_plugin'] ); } if ( 'import' == $from ) { - $install_actions['importers_page'] = '' . __('Return to Importers') . ''; + $install_actions['importers_page'] = '' . __( 'Return to Importers' ) . ''; } elseif ( $this->type == 'web' ) { - $install_actions['plugins_page'] = '' . __('Return to Plugin Installer') . ''; + $install_actions['plugins_page'] = '' . __( 'Return to Plugin Installer' ) . ''; } else { - $install_actions['plugins_page'] = '' . __('Return to Plugins page') . ''; + $install_actions['plugins_page'] = '' . __( 'Return to Plugins page' ) . ''; } if ( ! $this->result || is_wp_error($this->result) ) { @@ -488,6 +613,10 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { public $api; public $type; + /** + * + * @param array $args + */ public function __construct($args = array()) { $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); $args = wp_parse_args($args, $defaults); @@ -498,11 +627,17 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { parent::__construct($args); } + /** + * @access public + */ public function before() { if ( !empty($this->api) ) $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); } + /** + * @access public + */ public function after() { if ( empty($this->upgrader->result['destination_name']) ) return; @@ -515,12 +650,6 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { $stylesheet = $this->upgrader->result['destination_name']; $template = $theme_info->get_template(); - $preview_link = add_query_arg( array( - 'preview' => 1, - 'template' => urlencode( $template ), - 'stylesheet' => urlencode( $stylesheet ), - ), trailingslashit( home_url() ) ); - $activate_link = add_query_arg( array( 'action' => 'activate', 'template' => urlencode( $template ), @@ -529,19 +658,19 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); $install_actions = array(); - $install_actions['preview'] = '' . __('Preview') . ''; + if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { - $install_actions['preview'] .= '' . __('Live Preview') . ''; + $install_actions['preview'] = '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; } - $install_actions['activate'] = '' . __('Activate') . ''; + $install_actions['activate'] = '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) - $install_actions['network_enable'] = '' . __( 'Network Enable' ) . ''; + $install_actions['network_enable'] = '' . __( 'Network Enable' ) . ''; if ( $this->type == 'web' ) - $install_actions['themes_page'] = '' . __('Return to Theme Installer') . ''; + $install_actions['themes_page'] = '' . __( 'Return to Theme Installer' ) . ''; elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) - $install_actions['themes_page'] = '' . __('Return to Themes page') . ''; + $install_actions['themes_page'] = '' . __( 'Return to Themes page' ) . ''; if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) unset( $install_actions['activate'], $install_actions['preview'] ); @@ -572,6 +701,10 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { class Theme_Upgrader_Skin extends WP_Upgrader_Skin { public $theme = ''; + /** + * + * @param array $args + */ public function __construct($args = array()) { $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); $args = wp_parse_args($args, $defaults); @@ -581,6 +714,9 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { parent::__construct($args); } + /** + * @access public + */ public function after() { $this->decrement_update_count( 'theme' ); @@ -590,12 +726,6 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { $stylesheet = $this->upgrader->result['destination_name']; $template = $theme_info->get_template(); - $preview_link = add_query_arg( array( - 'preview' => 1, - 'template' => urlencode( $template ), - 'stylesheet' => urlencode( $stylesheet ), - ), trailingslashit( home_url() ) ); - $activate_link = add_query_arg( array( 'action' => 'activate', 'template' => urlencode( $template ), @@ -605,21 +735,20 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { if ( get_stylesheet() == $stylesheet ) { if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { - $update_actions['preview'] = '' . __('Customize') . ''; + $update_actions['preview'] = '' . sprintf( __( 'Customize “%s”' ), $name ) . ''; } } elseif ( current_user_can( 'switch_themes' ) ) { - $update_actions['preview'] = '' . __('Preview') . ''; if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { - $update_actions['preview'] .= '' . __('Live Preview') . ''; + $update_actions['preview'] .= '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; } - $update_actions['activate'] = '' . __('Activate') . ''; + $update_actions['activate'] = '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; } if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) unset( $update_actions['preview'], $update_actions['activate'] ); } - $update_actions['themes_page'] = '' . __('Return to Themes page') . ''; + $update_actions['themes_page'] = '' . __( 'Return to Themes page' ) . ''; /** * Filter the list of action links available following a single theme update. @@ -649,6 +778,10 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin { public $done_footer = false; public $display_footer_actions = true; + /** + * + * @param array $args + */ public function __construct( $args = array() ) { $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false ); $args = wp_parse_args( $args, $defaults ); @@ -660,6 +793,9 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin { parent::__construct( $args ); } + /** + * @access public + */ public function before() { $name = $this->upgrader->get_name_for_update( $this->language_update ); @@ -668,20 +804,30 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin { printf( '

' . __( 'Updating translations for %1$s (%2$s)…' ) . '

', $name, $this->language_update->language ); } + /** + * + * @param string|WP_Error $error + */ public function error( $error ) { echo '
'; parent::error( $error ); echo '
'; } + /** + * @access public + */ public function after() { echo ''; } + /** + * @access public + */ public function bulk_footer() { $this->decrement_update_count( 'translation' ); $update_actions = array(); - $update_actions['updates_page'] = '' . __( 'Return to WordPress Updates' ) . ''; + $update_actions['updates_page'] = '' . __( 'Return to WordPress Updates page' ) . ''; /** * Filter the list of action links available following a translations update. @@ -710,6 +856,13 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin { class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { protected $messages = array(); + /** + * + * @param bool $error + * @param string $context + * @param bool $allow_relaxed_file_ownership + * @return bool + */ public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { if ( $context ) { $this->options['context'] = $context; @@ -722,6 +875,11 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { return $result; } + /** + * @access public + * + * @return array + */ public function get_upgrade_messages() { return $this->messages; } @@ -765,19 +923,19 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { $this->messages[] = $string; } + /** + * @access public + */ public function header() { ob_start(); } + /** + * @access public + */ public function footer() { - $output = ob_get_contents(); + $output = ob_get_clean(); if ( ! empty( $output ) ) $this->feedback( $output ); - ob_end_clean(); } - - public function bulk_header() {} - public function bulk_footer() {} - public function before() {} - public function after() {} }