Changeset 42343 for trunk/src/wp-admin/includes/class-wp-upgrader-skin.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader-skin.php
r41161 r42343 26 26 * @var string|bool|WP_Error 27 27 */ 28 public $result = false;28 public $result = false; 29 29 public $options = array(); 30 30 31 31 /** 32 *33 32 * @param array $args 34 33 */ 35 public function __construct($args = array()) { 36 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); 37 $this->options = wp_parse_args($args, $defaults); 38 } 39 40 /** 41 * 34 public function __construct( $args = array() ) { 35 $defaults = array( 36 'url' => '', 37 'nonce' => '', 38 'title' => '', 39 'context' => false, 40 ); 41 $this->options = wp_parse_args( $args, $defaults ); 42 } 43 44 /** 42 45 * @param WP_Upgrader $upgrader 43 46 */ 44 public function set_upgrader( &$upgrader) {45 if ( is_object( $upgrader) )47 public function set_upgrader( &$upgrader ) { 48 if ( is_object( $upgrader ) ) { 46 49 $this->upgrader =& $upgrader; 50 } 47 51 $this->add_strings(); 48 52 } … … 85 89 $context = $this->options['context']; 86 90 } 87 if ( ! empty($this->options['nonce']) ) {88 $url = wp_nonce_url( $url, $this->options['nonce']);91 if ( ! empty( $this->options['nonce'] ) ) { 92 $url = wp_nonce_url( $url, $this->options['nonce'] ); 89 93 } 90 94 … … 116 120 117 121 /** 118 *119 122 * @param string|WP_Error $errors 120 123 */ 121 public function error( $errors) {122 if ( ! $this->done_header ) 124 public function error( $errors ) { 125 if ( ! $this->done_header ) { 123 126 $this->header(); 124 if ( is_string($errors) ) { 125 $this->feedback($errors); 126 } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { 127 } 128 if ( is_string( $errors ) ) { 129 $this->feedback( $errors ); 130 } elseif ( is_wp_error( $errors ) && $errors->get_error_code() ) { 127 131 foreach ( $errors->get_error_messages() as $message ) { 128 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) 129 $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); 130 else 131 $this->feedback($message); 132 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) { 133 $this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); 134 } else { 135 $this->feedback( $message ); 136 } 132 137 } 133 138 } … … 135 140 136 141 /** 137 *138 142 * @param string $string 139 143 */ 140 public function feedback($string) { 141 if ( isset( $this->upgrader->strings[$string] ) ) 142 $string = $this->upgrader->strings[$string]; 143 144 if ( strpos($string, '%') !== false ) { 144 public function feedback( $string ) { 145 if ( isset( $this->upgrader->strings[ $string ] ) ) { 146 $string = $this->upgrader->strings[ $string ]; 147 } 148 149 if ( strpos( $string, '%' ) !== false ) { 145 150 $args = func_get_args(); 146 $args = array_splice( $args, 1);151 $args = array_splice( $args, 1 ); 147 152 if ( $args ) { 148 $args = array_map( 'strip_tags', $args );149 $args = array_map( 'esc_html', $args );150 $string = vsprintf( $string, $args);153 $args = array_map( 'strip_tags', $args ); 154 $args = array_map( 'esc_html', $args ); 155 $string = vsprintf( $string, $args ); 151 156 } 152 157 } 153 if ( empty($string) ) 154 return; 155 show_message($string); 158 if ( empty( $string ) ) { 159 return; 160 } 161 show_message( $string ); 156 162 } 157 163
Note: See TracChangeset
for help on using the changeset viewer.