wp/wp-admin/includes/class-automatic-upgrader-skin.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    28 	 * @since 3.7.0
    28 	 * @since 3.7.0
    29 	 * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string.
    29 	 * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string.
    30 	 *
    30 	 *
    31 	 * @see request_filesystem_credentials()
    31 	 * @see request_filesystem_credentials()
    32 	 *
    32 	 *
    33 	 * @param bool   $error                        Optional. Whether the current request has failed to connect.
    33 	 * @param bool|WP_Error $error                        Optional. Whether the current request has failed to connect,
    34 	 *                                             Default false.
    34 	 *                                                    or an error object. Default false.
    35 	 * @param string $context                      Optional. Full path to the directory that is tested
    35 	 * @param string        $context                      Optional. Full path to the directory that is tested
    36 	 *                                             for being writable. Default empty.
    36 	 *                                                    for being writable. Default empty.
    37 	 * @param bool   $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
    37 	 * @param bool          $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
    38 	 * @return bool True on success, false on failure.
    38 	 * @return bool True on success, false on failure.
    39 	 */
    39 	 */
    40 	public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
    40 	public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
    41 		if ( $context ) {
    41 		if ( $context ) {
    42 			$this->options['context'] = $context;
    42 			$this->options['context'] = $context;
    43 		}
    43 		}
    44 		// TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
    44 		/*
    45 		// This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
    45 		 * TODO: Fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version.
       
    46 		 * This will output a credentials form in event of failure. We don't want that, so just hide with a buffer.
       
    47 		 */
    46 		ob_start();
    48 		ob_start();
    47 		$result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
    49 		$result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
    48 		ob_end_clean();
    50 		ob_end_clean();
    49 		return $result;
    51 		return $result;
    50 	}
    52 	}
    56 		return $this->messages;
    58 		return $this->messages;
    57 	}
    59 	}
    58 
    60 
    59 	/**
    61 	/**
    60 	 * @param string|array|WP_Error $data
    62 	 * @param string|array|WP_Error $data
       
    63 	 * @param mixed                 ...$args Optional text replacements.
    61 	 */
    64 	 */
    62 	public function feedback( $data ) {
    65 	public function feedback( $data, ...$args ) {
    63 		if ( is_wp_error( $data ) ) {
    66 		if ( is_wp_error( $data ) ) {
    64 			$string = $data->get_error_message();
    67 			$string = $data->get_error_message();
    65 		} elseif ( is_array( $data ) ) {
    68 		} elseif ( is_array( $data ) ) {
    66 			return;
    69 			return;
    67 		} else {
    70 		} else {
    70 		if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
    73 		if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
    71 			$string = $this->upgrader->strings[ $string ];
    74 			$string = $this->upgrader->strings[ $string ];
    72 		}
    75 		}
    73 
    76 
    74 		if ( strpos( $string, '%' ) !== false ) {
    77 		if ( strpos( $string, '%' ) !== false ) {
    75 			$args = func_get_args();
       
    76 			$args = array_splice( $args, 1 );
       
    77 			if ( ! empty( $args ) ) {
    78 			if ( ! empty( $args ) ) {
    78 				$string = vsprintf( $string, $args );
    79 				$string = vsprintf( $string, $args );
    79 			}
    80 			}
    80 		}
    81 		}
    81 
    82