Ticket #26543: 26543.diff
File 26543.diff, 4.5 KB (added by , 11 years ago) |
---|
-
wp-admin/js/theme.js
645 645 // Listens to [theme] and [search] params 646 646 themes.routes = Backbone.Router.extend({ 647 647 648 initialize: function() { 649 this.routes = _.object([ 650 ]); 648 routes: { 649 'themes.php?theme=:slug': 'theme', 650 'themes.php?search=:query': 'search', 651 'themes.php?s=:query': 'search' 651 652 }, 652 653 653 654 baseUrl: function( url ) { 654 return themes.data.settings.root + url; 655 return 'themes.php' + url; 656 }, 657 658 search: function( query ) { 659 $( '.theme-search' ).val( query ); 655 660 } 656 661 }); 657 662 … … 675 680 this.view.render(); 676 681 this.routes(); 677 682 678 // Set the initial theme 679 if ( 'undefined' !== typeof themes.data.settings.theme && '' !== themes.data.settings.theme ){ 680 this.view.view.theme.trigger( 'theme:expand', this.view.collection.findWhere( { id: themes.data.settings.theme } ) ); 681 } 682 683 // Set the initial search 684 if ( 'undefined' !== typeof themes.data.settings.search && '' !== themes.data.settings.search ){ 685 $( '.theme-search' ).val( themes.data.settings.search ); 686 this.themes.doSearch( themes.data.settings.search ); 687 } 688 689 // Start the router if browser supports History API 690 if ( window.history && window.history.pushState ) { 691 // Calls the routes functionality 692 Backbone.history.start({ pushState: true, silent: true }); 693 } 683 // Sets up Backbone.history 684 Backbone.history.start({ root: themes.data.settings.root.replace( 'themes.php', '' ), pushState: true, queryUri: true }); 694 685 }, 695 686 696 687 routes: function() { 688 var self = this; 697 689 // Bind to our global thx object 698 690 // so that the object is available to sub-views 699 691 themes.router = new themes.routes(); 692 693 // Handles theme details route event 694 themes.router.on( 'route:theme', function( slug ) { 695 self.view.view.expand( slug ); 696 }); 697 698 // Handles search route event 699 themes.router.on( 'route:search', function( query ) { 700 self.themes.doSearch( query ); 701 }); 700 702 } 701 703 }; 702 704 -
wp-admin/themes.php
100 100 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 101 101 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), 102 102 'root' => parse_url( admin_url( 'themes.php' ), PHP_URL_PATH ), 103 'theme' => esc_html( $theme ),104 'search' => esc_html( $search ),105 106 103 ), 107 104 'l10n' => array( 108 105 'addNew' => __( 'Add New Theme' ), -
wp-includes/js/wp-backbone.js
381 381 382 382 ready: function() {} 383 383 }); 384 385 // Backbone.History.prototype 386 // -------------------------- 387 // 388 // Extends Backbone.History to support urls with GET queries in WordPress 389 // Supports basic form ?param=value passing 'paramvalue' as the fragment 390 _.extend( Backbone.History.prototype, { 391 392 // Keep original fragment resolver available 393 originalFragment: Backbone.History.prototype.getFragment, 394 395 // ### Get the fragment 396 // 397 // If history constructor includes 'queryUri' param 398 // Use our own getFragment resolver to handle the location changes 399 // 400 // Appends 'location.search' to pathname in order to deal with 401 // query variables present in URI 402 // 403 // Returns fragment '?paramvalue' 404 getFragment: function( fragment, forcePushState ) { 405 var root; 406 407 // If queryUri is not set via Backbone.history.start 408 // return the original fragment handler 409 if ( ! Backbone.history.options.queryUri ) { 410 return this.originalFragment.apply( this, arguments ); 411 } 412 413 // If we got this far, parse this.location.search 414 // since we have a URL with query vars 415 if ( fragment == null ) { 416 if ( this._hasPushState || ! this._wantsHashChange || forcePushState ) { 417 418 // Constructs fragment attaching the query parameters 419 fragment = this.location.pathname + this.location.search; 420 root = this.root.replace( /\/$/, '' ); 421 422 if ( ! fragment.indexOf( root ) ) { 423 fragment = fragment.slice( root.length ); 424 } 425 426 } else { 427 fragment = this.getHash(); 428 } 429 } 430 431 return fragment.replace(/^\/+|\/+$/g, ''); 432 } 433 }); 434 384 435 }(jQuery));