- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-bulk-upgrader-skin.php
r41161 r42343 24 24 25 25 /** 26 *27 26 * @param array $args 28 27 */ 29 public function __construct($args = array()) { 30 $defaults = array( 'url' => '', 'nonce' => '' ); 31 $args = wp_parse_args($args, $defaults); 28 public function __construct( $args = array() ) { 29 $defaults = array( 30 'url' => '', 31 'nonce' => '', 32 ); 33 $args = wp_parse_args( $args, $defaults ); 32 34 33 parent::__construct( $args);35 parent::__construct( $args ); 34 36 } 35 37 … … 37 39 */ 38 40 public function add_strings() { 39 $this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.');41 $this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' ); 40 42 /* translators: 1: Title of an update, 2: Error message */ 41 $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s');43 $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' ); 42 44 /* translators: 1: Title of an update */ 43 $this->upgrader->strings['skin_update_failed'] = __( 'The update of %1$s failed.');45 $this->upgrader->strings['skin_update_failed'] = __( 'The update of %1$s failed.' ); 44 46 /* translators: 1: Title of an update */ 45 47 $this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' ); 46 $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');48 $this->upgrader->strings['skin_upgrade_end'] = __( 'All updates have been completed.' ); 47 49 } 48 50 49 51 /** 50 *51 52 * @param string $string 52 53 */ 53 public function feedback($string) { 54 if ( isset( $this->upgrader->strings[$string] ) ) 55 $string = $this->upgrader->strings[$string]; 54 public function feedback( $string ) { 55 if ( isset( $this->upgrader->strings[ $string ] ) ) { 56 $string = $this->upgrader->strings[ $string ]; 57 } 56 58 57 if ( strpos( $string, '%') !== false ) {59 if ( strpos( $string, '%' ) !== false ) { 58 60 $args = func_get_args(); 59 $args = array_splice( $args, 1);61 $args = array_splice( $args, 1 ); 60 62 if ( $args ) { 61 $args = array_map( 'strip_tags', $args );62 $args = array_map( 'esc_html', $args );63 $string = vsprintf( $string, $args);63 $args = array_map( 'strip_tags', $args ); 64 $args = array_map( 'esc_html', $args ); 65 $string = vsprintf( $string, $args ); 64 66 } 65 67 } 66 if ( empty( $string) )68 if ( empty( $string ) ) { 67 69 return; 68 if ( $this->in_loop ) 70 } 71 if ( $this->in_loop ) { 69 72 echo "$string<br />\n"; 70 else73 } else { 71 74 echo "<p>$string</p>\n"; 75 } 72 76 } 73 77 … … 85 89 86 90 /** 87 *88 91 * @param string|WP_Error $error 89 92 */ 90 public function error($error) { 91 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) 92 $this->error = $this->upgrader->strings[$error]; 93 public function error( $error ) { 94 if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) { 95 $this->error = $this->upgrader->strings[ $error ]; 96 } 93 97 94 if ( is_wp_error( $error) ) {98 if ( is_wp_error( $error ) ) { 95 99 $messages = array(); 96 100 foreach ( $error->get_error_messages() as $emessage ) { 97 if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) 101 if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) { 98 102 $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); 99 else103 } else { 100 104 $messages[] = $emessage; 105 } 101 106 } 102 $this->error = implode( ', ', $messages);107 $this->error = implode( ', ', $messages ); 103 108 } 104 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current) . '\').hide();</script>';109 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>'; 105 110 } 106 111 … … 108 113 */ 109 114 public function bulk_header() { 110 $this->feedback( 'skin_upgrade_start');115 $this->feedback( 'skin_upgrade_start' ); 111 116 } 112 117 … … 114 119 */ 115 120 public function bulk_footer() { 116 $this->feedback( 'skin_upgrade_end');121 $this->feedback( 'skin_upgrade_end' ); 117 122 } 118 123 119 124 /** 120 *121 125 * @param string $title 122 126 */ 123 public function before( $title = '') {127 public function before( $title = '' ) { 124 128 $this->in_loop = true; 125 129 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 ); 126 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current) . '\').css("display", "inline-block");</script>';130 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>'; 127 131 // This progress messages div gets moved via JavaScript when clicking on "Show details.". 128 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current) . '"><p>';132 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>'; 129 133 $this->flush_output(); 130 134 } 131 135 132 136 /** 133 *134 137 * @param string $title 135 138 */ 136 public function after( $title = '') {139 public function after( $title = '' ) { 137 140 echo '</p></div>'; 138 141 if ( $this->error || ! $this->result ) { 139 142 if ( $this->error ) { 140 echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';143 echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>'; 141 144 } else { 142 echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';145 echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>'; 143 146 } 144 147 145 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current) . '\').show();</script>';148 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>'; 146 149 } 147 150 if ( $this->result && ! is_wp_error( $this->result ) ) { … … 153 156 } 154 157 155 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current) . '\').hide();</script>';158 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>'; 156 159 } 157 160 … … 164 167 public function reset() { 165 168 $this->in_loop = false; 166 $this->error = false;169 $this->error = false; 167 170 } 168 171
Note: See TracChangeset
for help on using the changeset viewer.