Ticket #27055: 27055.diff
| File 27055.diff, 4.0 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 * Proxy requests for themes 2210 * 2211 * @since 3.8.0 2212 */ 2213 function wp_ajax_query_themes(){ 2214 2215 2216 check_ajax_referer( 'query-themes', 'nonce' ); 2217 2218 $base_url = 'http://api.wordpress.org/themes/info/1.1/?action=query_themes'; 2219 2220 $return = wp_remote_post( $base_url, array( 2221 'body' => array( 'request' => $_REQUEST['request'] ) 2222 )); 2223 2224 if ( is_wp_error( $return ) ) { 2225 wp_send_json_error(); 2226 } 2227 2228 wp_send_json_success( json_decode( $return['body'] ) ); 2229 2230 } -
src/wp-admin/js/theme.js
249 249 this.currentQuery.page = 1; 250 250 } 251 251 252 252 253 // Otherwise, send a new API call and add it to the cache. 253 254 if ( ! query && ! isPaginated ) { 254 255 query = this.apiCall( request ).done( function( data ) { 255 256 // Update the collection with the queried data. 257 data = data.data; 256 258 self.reset( data.themes ); 257 259 count = data.info.results; 258 260 … … 274 276 // If it's a paginated request we need to fetch more themes... 275 277 if ( isPaginated ) { 276 278 return this.apiCall( request, isPaginated ).done( function( data ) { 279 data = data.data; 277 280 // Add the new themes to the current collection 278 281 // @todo update counter 279 282 self.add( data.themes ); … … 287 290 }); 288 291 } 289 292 290 if ( query. themes.length === 0 ) {293 if ( query.data.themes.length === 0 ) { 291 294 self.trigger( 'query:empty' ); 292 295 } else { 293 296 $( 'body' ).removeClass( 'no-results' ); … … 295 298 296 299 // Only trigger an update event since we already have the themes 297 300 // on our cached object 298 if ( _.isNumber( query. total ) ) {299 this.count = query. total;301 if ( _.isNumber( query.data.total ) ) { 302 this.count = query.data.total; 300 303 } 301 304 302 if ( ! query. total ) {305 if ( ! query.data.total ) { 303 306 this.count = this.length; 304 307 } 305 308 306 this.reset( query. themes );309 this.reset( query.data.themes ); 307 310 this.trigger( 'update' ); 308 311 } 309 312 }, … … 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', 336 action: 'query-themes', 337 nonce: $('#query-theme-nonce').val(), 335 338 request: _.extend({ 336 339 per_page: 72, 337 340 fields: { … … 1553 1556 } 1554 1557 }; 1555 1558 1559 1556 1560 // Ready... 1557 1561 $( document ).ready(function() { 1558 1562 if ( themes.isInstall ) { -
src/wp-admin/theme-install.php
148 148 <a href="#"><?php _e( 'Edit' ); ?></a> 149 149 </div> 150 150 </div> 151 <?php wp_nonce_field( 'query-themes', 'query-theme-nonce' ); ?> 151 152 </div> 152 153 <div class="theme-browser"></div> 153 154 <div id="theme-installer" class="wp-full-overlay expanded"></div>