wp/wp-admin/includes/class-bulk-upgrader-skin.php
changeset 19 3d72ae0968f4
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    47 		$this->upgrader->strings['skin_update_successful'] = __( '%s updated successfully.' );
    47 		$this->upgrader->strings['skin_update_successful'] = __( '%s updated successfully.' );
    48 		$this->upgrader->strings['skin_upgrade_end']       = __( 'All updates have been completed.' );
    48 		$this->upgrader->strings['skin_upgrade_end']       = __( 'All updates have been completed.' );
    49 	}
    49 	}
    50 
    50 
    51 	/**
    51 	/**
    52 	 * @param string $string
    52 	 * @since 5.9.0 Renamed `$string` (a PHP reserved keyword) to `$feedback` for PHP 8 named parameter support.
    53 	 * @param mixed  ...$args Optional text replacements.
    53 	 *
       
    54 	 * @param string $feedback Message data.
       
    55 	 * @param mixed  ...$args  Optional text replacements.
    54 	 */
    56 	 */
    55 	public function feedback( $string, ...$args ) {
    57 	public function feedback( $feedback, ...$args ) {
    56 		if ( isset( $this->upgrader->strings[ $string ] ) ) {
    58 		if ( isset( $this->upgrader->strings[ $feedback ] ) ) {
    57 			$string = $this->upgrader->strings[ $string ];
    59 			$feedback = $this->upgrader->strings[ $feedback ];
    58 		}
    60 		}
    59 
    61 
    60 		if ( strpos( $string, '%' ) !== false ) {
    62 		if ( strpos( $feedback, '%' ) !== false ) {
    61 			if ( $args ) {
    63 			if ( $args ) {
    62 				$args   = array_map( 'strip_tags', $args );
    64 				$args     = array_map( 'strip_tags', $args );
    63 				$args   = array_map( 'esc_html', $args );
    65 				$args     = array_map( 'esc_html', $args );
    64 				$string = vsprintf( $string, $args );
    66 				$feedback = vsprintf( $feedback, $args );
    65 			}
    67 			}
    66 		}
    68 		}
    67 		if ( empty( $string ) ) {
    69 		if ( empty( $feedback ) ) {
    68 			return;
    70 			return;
    69 		}
    71 		}
    70 		if ( $this->in_loop ) {
    72 		if ( $this->in_loop ) {
    71 			echo "$string<br />\n";
    73 			echo "$feedback<br />\n";
    72 		} else {
    74 		} else {
    73 			echo "<p>$string</p>\n";
    75 			echo "<p>$feedback</p>\n";
    74 		}
    76 		}
    75 	}
    77 	}
    76 
    78 
    77 	/**
    79 	/**
    78 	 */
    80 	 */
    85 	public function footer() {
    87 	public function footer() {
    86 		// Nothing, This will be displayed within a iframe.
    88 		// Nothing, This will be displayed within a iframe.
    87 	}
    89 	}
    88 
    90 
    89 	/**
    91 	/**
    90 	 * @param string|WP_Error $error
    92 	 * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
       
    93 	 *
       
    94 	 * @param string|WP_Error $errors Errors.
    91 	 */
    95 	 */
    92 	public function error( $error ) {
    96 	public function error( $errors ) {
    93 		if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
    97 		if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
    94 			$this->error = $this->upgrader->strings[ $error ];
    98 			$this->error = $this->upgrader->strings[ $errors ];
    95 		}
    99 		}
    96 
   100 
    97 		if ( is_wp_error( $error ) ) {
   101 		if ( is_wp_error( $errors ) ) {
    98 			$messages = array();
   102 			$messages = array();
    99 			foreach ( $error->get_error_messages() as $emessage ) {
   103 			foreach ( $errors->get_error_messages() as $emessage ) {
   100 				if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) {
   104 				if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
   101 					$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
   105 					$messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
   102 				} else {
   106 				} else {
   103 					$messages[] = $emessage;
   107 					$messages[] = $emessage;
   104 				}
   108 				}
   105 			}
   109 			}
   106 			$this->error = implode( ', ', $messages );
   110 			$this->error = implode( ', ', $messages );