wp/wp-admin/includes/class-automatic-upgrader-skin.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    48 		ob_end_clean();
    48 		ob_end_clean();
    49 		return $result;
    49 		return $result;
    50 	}
    50 	}
    51 
    51 
    52 	/**
    52 	/**
    53 	 *
       
    54 	 * @return array
    53 	 * @return array
    55 	 */
    54 	 */
    56 	public function get_upgrade_messages() {
    55 	public function get_upgrade_messages() {
    57 		return $this->messages;
    56 		return $this->messages;
    58 	}
    57 	}
    59 
    58 
    60 	/**
    59 	/**
    61 	 *
       
    62 	 * @param string|array|WP_Error $data
    60 	 * @param string|array|WP_Error $data
    63 	 */
    61 	 */
    64 	public function feedback( $data ) {
    62 	public function feedback( $data ) {
    65 		if ( is_wp_error( $data ) ) {
    63 		if ( is_wp_error( $data ) ) {
    66 			$string = $data->get_error_message();
    64 			$string = $data->get_error_message();
    67 		} elseif ( is_array( $data ) ) {
    65 		} elseif ( is_array( $data ) ) {
    68 			return;
    66 			return;
    69 		} else {
    67 		} else {
    70 			$string = $data;
    68 			$string = $data;
    71 		}
    69 		}
    72 		if ( ! empty( $this->upgrader->strings[ $string ] ) )
    70 		if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
    73 			$string = $this->upgrader->strings[ $string ];
    71 			$string = $this->upgrader->strings[ $string ];
       
    72 		}
    74 
    73 
    75 		if ( strpos( $string, '%' ) !== false ) {
    74 		if ( strpos( $string, '%' ) !== false ) {
    76 			$args = func_get_args();
    75 			$args = func_get_args();
    77 			$args = array_splice( $args, 1 );
    76 			$args = array_splice( $args, 1 );
    78 			if ( ! empty( $args ) )
    77 			if ( ! empty( $args ) ) {
    79 				$string = vsprintf( $string, $args );
    78 				$string = vsprintf( $string, $args );
       
    79 			}
    80 		}
    80 		}
    81 
    81 
    82 		$string = trim( $string );
    82 		$string = trim( $string );
    83 
    83 
    84 		// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
    84 		// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
    85 		$string = wp_kses( $string, array(
    85 		$string = wp_kses(
    86 			'a' => array(
    86 			$string,
    87 				'href' => true
    87 			array(
    88 			),
    88 				'a'      => array(
    89 			'br' => true,
    89 					'href' => true,
    90 			'em' => true,
    90 				),
    91 			'strong' => true,
    91 				'br'     => true,
    92 		) );
    92 				'em'     => true,
       
    93 				'strong' => true,
       
    94 			)
       
    95 		);
    93 
    96 
    94 		if ( empty( $string ) )
    97 		if ( empty( $string ) ) {
    95 			return;
    98 			return;
       
    99 		}
    96 
   100 
    97 		$this->messages[] = $string;
   101 		$this->messages[] = $string;
    98 	}
   102 	}
    99 
   103 
   100 	/**
   104 	/**
   105 
   109 
   106 	/**
   110 	/**
   107 	 */
   111 	 */
   108 	public function footer() {
   112 	public function footer() {
   109 		$output = ob_get_clean();
   113 		$output = ob_get_clean();
   110 		if ( ! empty( $output ) )
   114 		if ( ! empty( $output ) ) {
   111 			$this->feedback( $output );
   115 			$this->feedback( $output );
       
   116 		}
   112 	}
   117 	}
   113 }
   118 }