Ticket #27639: 27581.patch
| File 27581.patch, 4.6 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
2204 2204 update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); 2205 2205 wp_send_json_success(); 2206 2206 } 2207 2208 /** 2209 * Perform a query_themes lookup on api.wordpress.org. 2210 * 2211 * @since x.x.x 2212 */ 2213 function wp_ajax_query_themes() { 2214 $url = 'http://api.wordpress.org/themes/info/1.1/?action=query_themes'; 2215 2216 check_ajax_referer( 'query-themes', 'nonce' ); 2217 2218 $query_themes_cache_key = md5( serialize( $_POST['api'] ) ); 2219 2220 if ( false === ( $json = get_transient( $query_themes_cache_key ) ) ) { 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 set_transient( $query_themes_cache_key, $json, 5 * MINUTE_IN_SECONDS ); 2239 } 2240 wp_send_json_success( $json ); 2241 2242 } 2243 No newline at end of file -
src/wp-admin/js/theme.js
251 251 252 252 // Otherwise, send a new API call and add it to the cache. 253 253 if ( ! query && ! isPaginated ) { 254 query = this.apiCall( request ).done( function( data ) { 254 query = this.apiCall( request ).done( function( response ) { 255 data = response.data; 255 256 // Update the collection with the queried data. 256 257 self.reset( data.themes ); 257 258 count = data.info.results; … … 273 274 } else { 274 275 // If it's a paginated request we need to fetch more themes... 275 276 if ( isPaginated ) { 276 return this.apiCall( request, isPaginated ).done( function( data ) { 277 return this.apiCall( request, isPaginated ).done( function( response ) { 278 data = response.data; 279 277 280 // Add the new themes to the current collection 278 281 // @todo update counter 279 282 self.add( data.themes ); … … 322 325 323 326 // Ajax request to .org API 324 327 return $.ajax({ 325 url: 'https://api.wordpress.org/themes/info/1.1/?action=query_themes',328 url: ajaxurl, 326 329 327 330 // We want JSON data 328 331 dataType: 'json', 329 332 type: 'POST', 330 crossDomain: true,331 333 332 334 // Request data 333 335 data: { 334 action: 'query_themes', 335 request: _.extend({ 336 per_page: 72, 337 fields: { 338 description: true, 339 tested: true, 340 requires: true, 341 rating: true, 342 downloaded: true, 343 downloadLink: true, 344 last_updated: true, 345 homepage: true, 346 num_ratings: true 347 } 348 }, request) 336 action: 'query-themes', 337 nonce: themes.data.settings._nonceQuery, 338 api: { 339 action: 'query_themes', 340 request: _.extend({ 341 per_page: 72, 342 fields: { 343 description: true, 344 tested: true, 345 requires: true, 346 rating: true, 347 downloaded: true, 348 downloadLink: true, 349 last_updated: true, 350 homepage: true, 351 num_ratings: true 352 } 353 }, request) 354 } 349 355 }, 350 356 351 357 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' ),