Ticket #27581: 27581.patch
| File 27581.patch, 5.2 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/admin-ajax.php
58 58 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 59 59 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 60 60 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 61 'save-user-color-scheme', 'update-widget', 61 'save-user-color-scheme', 'update-widget', 'query-themes' 62 62 ); 63 63 64 64 // Register core Ajax calls. -
src/wp-admin/includes/ajax-actions.php
2207 2207 update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); 2208 2208 wp_send_json_success(); 2209 2209 } 2210 2211 /** 2212 * Perform a query_themes lookup on api.wordpress.org. 2213 * 2214 * @since x.x.x 2215 */ 2216 function wp_ajax_query_themes() { 2217 $url = 'http://api.wordpress.org/themes/info/1.1/?action=query_themes'; 2218 2219 check_ajax_referer( 'query-themes', 'nonce' ); 2220 2221 $request = wp_remote_post( $url, array( 2222 'body' => wp_unslash( $_POST['api'] ), 2223 ) ); 2224 2225 if ( is_wp_error( $request ) ) { 2226 wp_send_json_error(); 2227 } 2228 if ( 200 != wp_remote_retrieve_response_code( $request ) ) { 2229 wp_send_json_error(); 2230 } 2231 2232 $json = json_decode( wp_remote_retrieve_body( $request ) ); 2233 2234 if ( !$json ) { 2235 wp_send_json_error(); 2236 } 2237 2238 if ( isset( $json->themes ) ) { 2239 foreach ( $json->themes as & $theme ) { 2240 $theme->num_ratings_text = sprintf( _n( 'Based on %s rating.', 'Based on %s ratings.', $theme->num_ratings ), number_format_i18n( $theme->num_ratings ) ); 2241 } 2242 } 2243 2244 wp_send_json_success( $json ); 2245 2246 } 2247 No newline at end of file -
src/wp-admin/js/theme.js
245 245 246 246 // Otherwise, send a new API call and add it to the cache. 247 247 if ( ! query ) { 248 query = this.apiCall( request ).done( function( data ) { 248 query = this.apiCall( request ).done( function( response ) { 249 if ( !response.success ) { 250 self.trigger( 'query:fail' ); 251 return; 252 } 253 data = response.data; 254 249 255 // Update the collection with the queried data. 250 256 self.reset( data.themes ); 251 257 count = data.info.results; … … 267 273 } else { 268 274 // If it's a paginated request we need to fetch more themes... 269 275 if ( isPaginated ) { 270 return this.apiCall( request, isPaginated ).done( function( data ) { 276 return this.apiCall( request, isPaginated ).done( function( response ) { 277 if ( !response.success ) { 278 self.trigger( 'query:fail' ); 279 return; 280 } 281 data = response.data; 282 271 283 // Add the new themes to the current collection 272 284 // @todo update counter 273 285 self.add( data.themes ); … … 311 323 312 324 // Ajax request to .org API 313 325 return $.ajax({ 314 url: 'https://api.wordpress.org/themes/info/1.1/?action=query_themes',326 url: ajaxurl, 315 327 316 328 // We want JSON data 317 329 dataType: 'json', 318 330 type: 'POST', 319 crossDomain: true,320 331 321 332 // Request data 322 333 data: { 323 action: 'query_themes', 324 request: _.extend({ 325 per_page: 72, 326 fields: { 327 description: true, 328 tested: true, 329 requires: true, 330 rating: true, 331 downloaded: true, 332 downloadLink: true, 333 last_updated: true, 334 homepage: true, 335 num_ratings: true 336 } 337 }, request) 334 action: 'query-themes', 335 nonce: themes.data.settings._nonceQuery, 336 api: { 337 action: 'query_themes', 338 request: _.extend({ 339 per_page: 72, 340 fields: { 341 description: true, 342 tested: true, 343 requires: true, 344 rating: true, 345 downloaded: true, 346 downloadLink: true, 347 last_updated: true, 348 homepage: true, 349 num_ratings: true 350 } 351 }, request) 352 } 338 353 }, 339 354 340 355 beforeSend: function() { -
src/wp-admin/theme-install.php
41 41 'installURI' => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null, 42 42 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), 43 43 'updateURI' => self_admin_url( 'update.php' ), 44 '_nonceInstall' => wp_create_nonce( 'install-theme' ) 44 '_nonceInstall' => wp_create_nonce( 'install-theme' ), 45 '_nonceQuery' => wp_create_nonce( 'query-themes' ), 45 46 ), 46 47 'l10n' => array( 47 48 'addNew' => __( 'Add New Theme' ), … … 205 206 <span class="three"></span> 206 207 <span class="four"></span> 207 208 <span class="five"></span> 208 <p class="votes"> <?php printf( __( 'Based on %s ratings.' ), '{{ data.num_ratings }}' ); ?></p>209 <p class="votes">{{ data.num_ratings_text }}</p> 209 210 </div> 210 211 <div class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></div> 211 212 <div class="theme-description">{{ data.description }}</div>