Changeset 42631 for trunk/src/wp-admin/includes/plugin-install.php
- Timestamp:
- 02/01/2018 05:16:15 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/plugin-install.php
r42459 r42631 100 100 */ 101 101 function plugins_api( $action, $args = array() ) { 102 // include an unmodified $wp_version 103 include( ABSPATH . WPINC . '/version.php' ); 102 104 103 105 if ( is_array( $args ) ) { … … 105 107 } 106 108 107 if ( ! isset( $args->per_page ) ) { 108 $args->per_page = 24; 109 if ( 'query_plugins' == $action ) { 110 if ( ! isset( $args->per_page ) ) { 111 $args->per_page = 24; 112 } 109 113 } 110 114 111 115 if ( ! isset( $args->locale ) ) { 112 116 $args->locale = get_user_locale(); 117 } 118 119 if ( ! isset( $args->wp_version ) ) { 120 $args->wp_version = substr( $wp_version, 0, 3 ); // X.y 113 121 } 114 122 … … 142 150 143 151 if ( false === $res ) { 144 // include an unmodified $wp_version 145 include( ABSPATH . WPINC . '/version.php' ); 146 147 $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; 152 153 $url = 'http://api.wordpress.org/plugins/info/1.2/'; 154 $url = add_query_arg( 155 array( 156 'action' => $action, 157 'request' => $args, 158 ), 159 $url 160 ); 161 162 $http_url = $url; 148 163 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { 149 164 $url = set_url_scheme( $url, 'https' ); … … 153 168 'timeout' => 15, 154 169 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), 155 'body' => array(156 'action' => $action,157 'request' => serialize( $args ),158 ),159 170 ); 160 $request = wp_remote_ post( $url, $http_args );171 $request = wp_remote_get( $url, $http_args ); 161 172 162 173 if ( $ssl && is_wp_error( $request ) ) { … … 169 180 headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE 170 181 ); 171 $request = wp_remote_ post( $http_url, $http_args );182 $request = wp_remote_get( $http_url, $http_args ); 172 183 } 173 184 … … 183 194 ); 184 195 } else { 185 $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); 186 if ( ! is_object( $res ) && ! is_array( $res ) ) { 196 $res = json_decode( wp_remote_retrieve_body( $request ), true ); 197 if ( is_array( $res ) ) { 198 // Object casting is required in order to match the info/1.0 format. 199 $res = (object) $res; 200 } elseif ( null === $res ) { 187 201 $res = new WP_Error( 188 202 'plugins_api_failed', … … 194 208 wp_remote_retrieve_body( $request ) 195 209 ); 210 } 211 212 if ( isset( $res->error ) ) { 213 $res = new WP_Error( 'plugins_api_failed', $res->error ); 196 214 } 197 215 } … … 486 504 'plugin_information', array( 487 505 'slug' => wp_unslash( $_REQUEST['plugin'] ), 488 'is_ssl' => is_ssl(),489 'fields' => array(490 'banners' => true,491 'reviews' => true,492 'downloaded' => false,493 'active_installs' => true,494 ),495 506 ) 496 507 ); … … 708 719 <ul class="contributors"> 709 720 <?php 710 foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) { 711 if ( empty( $contrib_username ) && empty( $contrib_profile ) ) { 712 continue; 721 foreach ( (array) $api->contributors as $contrib_username => $contrib_details ) { 722 $contrib_name = $contrib_details['display_name']; 723 if ( ! $contrib_name ) { 724 $contrin_name = $contrib_username; 713 725 } 714 if ( empty( $contrib_username ) ) { 715 $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile ); 716 } 717 $contrib_username = sanitize_user( $contrib_username ); 718 if ( empty( $contrib_profile ) ) { 719 echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' alt='' />{$contrib_username}</li>"; 720 } else { 721 echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' alt='' />{$contrib_username}</a></li>"; 722 } 726 $contrib_name = esc_html( $contrib_name ); 727 728 $contrib_profile = esc_url( $contrib_details['profile'] ); 729 $contrib_avatar = esc_url( add_query_arg( 's', '36', $contrib_details['avatar'] ) ); 730 731 echo "<li><a href='{$contrib_profile}' target='_blank'><img src='{$contrib_avatar}' width='18' height='18' alt='' />{$contrib_name}</a></li>"; 723 732 } 724 733 ?>
Note: See TracChangeset
for help on using the changeset viewer.