wp/wp-admin/includes/theme.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
   491  * @return object|array|WP_Error Response object or array on success, WP_Error on failure. See the
   491  * @return object|array|WP_Error Response object or array on success, WP_Error on failure. See the
   492  *         {@link https://developer.wordpress.org/reference/functions/themes_api/ function reference article}
   492  *         {@link https://developer.wordpress.org/reference/functions/themes_api/ function reference article}
   493  *         for more information on the make-up of possible return objects depending on the value of `$action`.
   493  *         for more information on the make-up of possible return objects depending on the value of `$action`.
   494  */
   494  */
   495 function themes_api( $action, $args = array() ) {
   495 function themes_api( $action, $args = array() ) {
   496 	// Include an unmodified $wp_version.
       
   497 	require ABSPATH . WPINC . '/version.php';
       
   498 
       
   499 	if ( is_array( $args ) ) {
   496 	if ( is_array( $args ) ) {
   500 		$args = (object) $args;
   497 		$args = (object) $args;
   501 	}
   498 	}
   502 
   499 
   503 	if ( 'query_themes' === $action ) {
   500 	if ( 'query_themes' === $action ) {
   509 	if ( ! isset( $args->locale ) ) {
   506 	if ( ! isset( $args->locale ) ) {
   510 		$args->locale = get_user_locale();
   507 		$args->locale = get_user_locale();
   511 	}
   508 	}
   512 
   509 
   513 	if ( ! isset( $args->wp_version ) ) {
   510 	if ( ! isset( $args->wp_version ) ) {
   514 		$args->wp_version = substr( $wp_version, 0, 3 ); // x.y
   511 		$args->wp_version = substr( wp_get_wp_version(), 0, 3 ); // x.y
   515 	}
   512 	}
   516 
   513 
   517 	/**
   514 	/**
   518 	 * Filters arguments used to query for installer pages from the WordPress.org Themes API.
   515 	 * Filters arguments used to query for installer pages from the WordPress.org Themes API.
   519 	 *
   516 	 *
   560 			$url = set_url_scheme( $url, 'https' );
   557 			$url = set_url_scheme( $url, 'https' );
   561 		}
   558 		}
   562 
   559 
   563 		$http_args = array(
   560 		$http_args = array(
   564 			'timeout'    => 15,
   561 			'timeout'    => 15,
   565 			'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
   562 			'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
   566 		);
   563 		);
   567 		$request   = wp_remote_get( $url, $http_args );
   564 		$request   = wp_remote_get( $url, $http_args );
   568 
   565 
   569 		if ( $ssl && is_wp_error( $request ) ) {
   566 		if ( $ssl && is_wp_error( $request ) ) {
   570 			if ( ! wp_doing_ajax() ) {
   567 			if ( ! wp_doing_ajax() ) {