From b07b8d4fe84d9608f8a1ebe49fe801a6cecead5d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 7 Dec 2013 03:11:10 +0000 Subject: [PATCH] Make the Backbone routes pushSTate capable with ?theme=themename type urls instead of hashes. Same applies to search queries. Props adamsilverstein, nacin fixes #25963 Built from https://develop.svn.wordpress.org/trunk@26767 git-svn-id: http://core.svn.wordpress.org/trunk@26655 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/theme.js | 103 ++++++++++++++++++++------------------- wp-admin/js/theme.min.js | 2 +- wp-admin/themes.php | 8 ++- 3 files changed, 60 insertions(+), 53 deletions(-) diff --git a/wp-admin/js/theme.js b/wp-admin/js/theme.js index 8089128cf8..d3777b3e0c 100644 --- a/wp-admin/js/theme.js +++ b/wp-admin/js/theme.js @@ -293,7 +293,7 @@ themes.view.Details = wp.Backbone.View.extend({ scroll = document.body.scrollTop; // Clean the url structure - themes.router.navigate( '' ); + themes.router.navigate( themes.router.baseUrl( '' ), { replace: true } ); // Restore scroll position document.body.scrollTop = scroll; @@ -301,28 +301,8 @@ themes.view.Details = wp.Backbone.View.extend({ } }, - // Handles arrow keys navigation for the overlay - // Triggers theme:next and theme:previous events + // Handles .disabled classes for next/previous buttons navigation: function() { - var self = this; - - $( 'body' ).on( 'keyup', function( event ) { - - // Pressing the right arrow key fires a theme:next event - if ( event.keyCode === 39 ) { - self.trigger( 'theme:next', self.model.cid ); - } - - // Pressing the left arrow key fires a theme:previous event - if ( event.keyCode === 37 ) { - self.trigger( 'theme:previous', self.model.cid ); - } - - // Pressing the escape key closes the theme details panel - if ( event.keyCode === 27 ) { - self.collapse(); - } - }); // Disable Left/Right when at the start or end of the collection if ( this.model.cid === this.model.collection.at(0).cid ) { @@ -377,6 +357,7 @@ themes.view.Details = wp.Backbone.View.extend({ themes.view.Themes = wp.Backbone.View.extend({ className: 'themes', + $overlay: $( 'div.theme-overlay' ), // Number to keep track of scroll position // while in theme-overlay mode @@ -407,6 +388,24 @@ themes.view.Themes = wp.Backbone.View.extend({ this.listenTo( this.parent, 'theme:scroll', function() { self.renderThemes( self.parent.page ); }); + + // Bind keyboard events. + $('body').on( 'keyup', function( event ) { + // Pressing the right arrow key fires a theme:next event + if ( event.keyCode === 39 ) { + self.overlay.nextTheme(); + } + + // Pressing the left arrow key fires a theme:previous event + if ( event.keyCode === 37 ) { + self.overlay.previousTheme(); + } + + // Pressing the escape key fires a theme:collapse event + if ( event.keyCode === 27 ) { + self.overlay.collapse( event ); + } + }); }, // Manages rendering of theme pages @@ -508,7 +507,7 @@ themes.view.Themes = wp.Backbone.View.extend({ this.model = self.collection.get( id ); // Trigger a route update for the current model - themes.router.navigate( 'theme/' + this.model.id ); + themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.id ), { replace: true } ); // Sets this.view to 'detail' this.setView( 'detail' ); @@ -520,7 +519,7 @@ themes.view.Themes = wp.Backbone.View.extend({ }); this.overlay.render(); - this.$el.append( this.overlay.el ); + this.$overlay.html( this.overlay.el ); // Bind to theme:next and theme:previous // triggered by the arrow keys @@ -558,8 +557,8 @@ themes.view.Themes = wp.Backbone.View.extend({ this.overlay.closeOverlay(); // Trigger a route update for the current model - // that renders the new theme's overlay - themes.router.navigate( 'theme/' + nextModel.id, { trigger: true } ); + self.theme.trigger( 'theme:expand', nextModel.cid ); + } }, @@ -582,8 +581,8 @@ themes.view.Themes = wp.Backbone.View.extend({ this.overlay.closeOverlay(); // Trigger a route update for the current model - // that renders the new theme's overlay - themes.router.navigate( 'theme/' + previousModel.id, { trigger: true } ); + self.theme.trigger( 'theme:expand', previousModel.cid ); + } } }); @@ -617,9 +616,9 @@ themes.view.Search = wp.Backbone.View.extend({ // Update the URL hash if ( event.target.value ) { - themes.router.navigate( 'search/' + event.target.value, { replace: true } ); + themes.router.navigate( themes.router.baseUrl( '?search=' + event.target.value ), { replace: true } ); } else { - themes.router.navigate( '' ); + themes.router.navigate( themes.router.baseUrl( '' ), { replace: true } ); } } }); @@ -628,20 +627,22 @@ themes.view.Search = wp.Backbone.View.extend({ // Listens to [theme] and [search] params themes.routes = Backbone.Router.extend({ - routes: { - 'search/*query': 'search', - 'theme/*slug': 'theme' + initialize: function() { + this.routes = _.object([ + ]); + }, + + baseUrl: function( url ) { + return themes.data.settings.root + url; }, // Set the search input value based on url search: function( query ) { $( '.theme-search' ).val( query ); + self.themes.doSearch( query ); } }); -// Make routes easily extendable -_.extend( themes.routes, themes.data.settings.extraRoutes ); - // Execute and setup the application themes.Run = { init: function() { @@ -660,12 +661,24 @@ themes.Run = { render: function() { // Render results this.view.render(); - - // Calls the routes functionality this.routes(); - // Set ups history with pushState and our root - Backbone.history.start({ root: themes.data.settings.root }); + // Set the initial theme + if ( 'undefined' !== typeof themes.data.settings.theme && '' !== themes.data.settings.theme ){ + this.view.view.theme.trigger( 'theme:expand', this.view.collection.findWhere( { id: themes.data.settings.theme } ) ); + } + + // Set the initial search + if ( 'undefined' !== typeof themes.data.settings.search && '' !== themes.data.settings.search ){ + $( '.theme-search' ).val( themes.data.settings.search ); + this.themes.doSearch( themes.data.settings.search ); + } + + // Start the router if browser supports History API + if ( window.history && window.history.pushState ) { + // Calls the routes functionality + Backbone.history.start({ pushState: true, silent: true }); + } }, routes: function() { @@ -673,16 +686,6 @@ themes.Run = { // Bind to our global thx object // so that the object is available to sub-views themes.router = new themes.routes(); - - // Handles theme details route event - themes.router.on( 'route:theme', function( slug ) { - self.view.view.expand( slug ); - }); - - // Handles search route event - themes.router.on( 'route:search', function( query ) { - self.themes.doSearch( query ); - }); } }; diff --git a/wp-admin/js/theme.min.js b/wp-admin/js/theme.min.js index ffd19b16f5..cec301a09c 100644 --- a/wp-admin/js/theme.min.js +++ b/wp-admin/js/theme.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a){var b,c;b=wp.themes=wp.themes||{},b.data=_wpThemeSettings,c=b.data.l10n,_.extend(b,{model:{},view:{},routes:{},router:{},template:wp.template}),b.model=Backbone.Model.extend({}),b.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:a(window),page:0,initialize:function(){_.bindAll(this,"scroller"),this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new b.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered"),this.$el.append('
')},search:function(){var c,d=this;1!==b.data.themes.length&&(c=new b.view.Search({collection:d.collection}),c.render(),a("#wpbody h2:first").append(c.el))},scroller:function(){var a,b,c=this;a=this.window.scrollTop()+c.window.height(),b=c.$el.offset().top+c.$el.outerHeight(!1)-c.window.height(),b=Math.round(.9*b),a>b&&this.trigger("theme:scroll")}}),b.Collection=Backbone.Collection.extend({model:b.model,terms:"",doSearch:function(a){this.terms!==a&&(this.terms=a,this.terms.length>0&&this.search(this.terms),""===this.terms&&this.reset(b.data.themes),this.trigger("update"))},search:function(a){var c,d,e;this.reset(b.data.themes,{silent:!0}),a=a.replace(" ",")(?=.*"),c=new RegExp("^(?=.*"+a+").+","i"),d=this.filter(function(b){return e=_.union(b.get("name"),b.get("description"),b.get("author"),b.get("tags")),c.test(b.get("author"))&&a.length>2&&b.set("displayAuthor",!0),c.test(e)}),this.reset(d)},paginate:function(a){var b=this;return a=a||0,b=_(b.rest(15*a)),b=_(b.first(15))}}),b.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:b.template("theme"),events:{click:"expand"},render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeTheme(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeTheme:function(){this.model.get("active")&&(this.$el.addClass("active"),a(".theme-overlay").addClass("active"))},expand:function(b){var c=this;b=b||window.event,a(b.target).is(".theme-actions a")||this.trigger("theme:expand",c.model.cid)}}),b.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-theme":"deleteTheme","click .left":"previousTheme","click .right":"nextTheme"},html:b.template("theme-single"),render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeTheme(),this.navigation(),this.screenshotCheck(this.$el)},activeTheme:function(){this.$el.toggleClass("active",this.model.get("active"))},collapse:function(c){var d,e=this;c=c||window.event,1!==b.data.themes.length&&(a(c.target).is(".theme-backdrop")||a(c.target).is("div.close")||27===c.keyCode)&&(a("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){a("body").removeClass("theme-overlay-open closing-overlay"),e.closeOverlay(),d=document.body.scrollTop,b.router.navigate(""),document.body.scrollTop=d}))},navigation:function(){var b=this;a("body").on("keyup",function(a){39===a.keyCode&&b.trigger("theme:next",b.model.cid),37===a.keyCode&&b.trigger("theme:previous",b.model.cid),27===a.keyCode&&b.collapse()}),this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled"),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled")},closeOverlay:function(){this.remove(),this.unbind(),this.trigger("theme:collapse")},deleteTheme:function(){return confirm(b.data.settings.confirmDelete)},nextTheme:function(){var a=this;a.trigger("theme:next",a.model.cid)},previousTheme:function(){var a=this;a.trigger("theme:previous",a.model.cid)},screenshotCheck:function(a){var b,c;b=a.find(".screenshot img"),c=new Image,c.src=b.attr("src"),c.width&&c.width<=300&&a.addClass("small-screenshot")}}),b.view.Themes=wp.Backbone.View.extend({className:"themes",index:0,count:a(".theme-count"),initialize:function(a){var b=this;this.parent=a.parent,this.setView("grid"),b.currentTheme(),this.listenTo(b.collection,"update",function(){b.parent.page=0,b.currentTheme(),b.render(this)}),this.listenTo(this.parent,"theme:scroll",function(){b.renderThemes(b.parent.page)})},render:function(){this.$el.html(""),1===b.data.themes.length&&(this.singleTheme=new b.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),this.renderThemes(this.parent.page),this.count.text(this.collection.length)},renderThemes:function(d){var e=this;e.instance=e.collection.paginate(d),0!==e.instance.length&&(d>=1&&a(".add-new-theme").remove(),e.instance.each(function(a){e.theme=new b.view.Theme({model:a}),e.theme.render(),e.$el.append(e.theme.el),e.listenTo(e.theme,"theme:expand",e.expand,e)}),b.data.settings.canInstall&&this.$el.append('

'+c.addNew+"

"),this.parent.page++)},currentTheme:function(){var a,b=this;a=b.collection.findWhere({active:!0}),a&&(b.collection.remove(a),b.collection.add(a,{at:0}))},setView:function(a){return a},expand:function(c){var d=this;this.model=d.collection.get(c),b.router.navigate("theme/"+this.model.id),this.setView("detail"),a("body").addClass("theme-overlay-open"),this.overlay=new b.view.Details({model:d.model}),this.overlay.render(),this.$el.append(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){d.next([d.model.cid])}).listenTo(this.overlay,"theme:previous",function(){d.previous([d.model.cid])})},next:function(a){var c,d,e=this;c=e.collection.get(a[0]),d=e.collection.at(e.collection.indexOf(c)+1),void 0!==d&&(this.overlay.closeOverlay(),b.router.navigate("theme/"+d.id,{trigger:!0}))},previous:function(a){var c,d,e=this;c=e.collection.get(a[0]),d=e.collection.at(e.collection.indexOf(c)-1),void 0!==d&&(this.overlay.closeOverlay(),b.router.navigate("theme/"+d.id,{trigger:!0}))}}),b.view.Search=wp.Backbone.View.extend({tagName:"input",className:"theme-search",attributes:{placeholder:c.search,type:"search"},events:{input:"search",keyup:"search",change:"search",search:"search"},search:function(a){"keyup"===a.type&&27===a.which&&(a.target.value=""),this.collection.doSearch(a.target.value),a.target.value?b.router.navigate("search/"+a.target.value,{replace:!0}):b.router.navigate("")}}),b.routes=Backbone.Router.extend({routes:{"search/*query":"search","theme/*slug":"theme"},search:function(b){a(".theme-search").val(b)}}),_.extend(b.routes,b.data.settings.extraRoutes),b.Run={init:function(){this.themes=new b.Collection(b.data.themes),this.view=new b.view.Appearance({collection:this.themes}),this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:b.data.settings.root})},routes:function(){var a=this;b.router=new b.routes,b.router.on("route:theme",function(b){a.view.view.expand(b)}),b.router.on("route:search",function(b){a.themes.doSearch(b)})}},jQuery(document).ready(_.bind(b.Run.init,b.Run))}(jQuery);var tb_position;jQuery(document).ready(function(a){tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height(),e=c>1040?1040:c,f=0;a("body.admin-bar").length&&(f=parseInt(jQuery("#wpadminbar").css("height"),10)),b.size()&&(b.width(e-50).height(d-45-f),a("#TB_iframeContent").width(e-50).height(d-75-f),b.css({"margin-left":"-"+parseInt((e-50)/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:20+f+"px","margin-top":"0"}))},a(window).resize(function(){tb_position()})}); \ No newline at end of file +window.wp=window.wp||{},function(a){var b,c;b=wp.themes=wp.themes||{},b.data=_wpThemeSettings,c=b.data.l10n,_.extend(b,{model:{},view:{},routes:{},router:{},template:wp.template}),b.model=Backbone.Model.extend({}),b.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:a(window),page:0,initialize:function(){_.bindAll(this,"scroller"),this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new b.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered"),this.$el.append('
')},search:function(){var c,d=this;1!==b.data.themes.length&&(c=new b.view.Search({collection:d.collection}),c.render(),a("#wpbody h2:first").append(c.el))},scroller:function(){var a,b,c=this;a=this.window.scrollTop()+c.window.height(),b=c.$el.offset().top+c.$el.outerHeight(!1)-c.window.height(),b=Math.round(.9*b),a>b&&this.trigger("theme:scroll")}}),b.Collection=Backbone.Collection.extend({model:b.model,terms:"",doSearch:function(a){this.terms!==a&&(this.terms=a,this.terms.length>0&&this.search(this.terms),""===this.terms&&this.reset(b.data.themes),this.trigger("update"))},search:function(a){var c,d,e;this.reset(b.data.themes,{silent:!0}),a=a.replace(" ",")(?=.*"),c=new RegExp("^(?=.*"+a+").+","i"),d=this.filter(function(b){return e=_.union(b.get("name"),b.get("description"),b.get("author"),b.get("tags")),c.test(b.get("author"))&&a.length>2&&b.set("displayAuthor",!0),c.test(e)}),this.reset(d)},paginate:function(a){var b=this;return a=a||0,b=_(b.rest(15*a)),b=_(b.first(15))}}),b.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:b.template("theme"),events:{click:"expand"},render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeTheme(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeTheme:function(){this.model.get("active")&&(this.$el.addClass("active"),a(".theme-overlay").addClass("active"))},expand:function(b){var c=this;b=b||window.event,a(b.target).is(".theme-actions a")||this.trigger("theme:expand",c.model.cid)}}),b.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-theme":"deleteTheme","click .left":"previousTheme","click .right":"nextTheme"},html:b.template("theme-single"),render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeTheme(),this.navigation(),this.screenshotCheck(this.$el)},activeTheme:function(){this.$el.toggleClass("active",this.model.get("active"))},collapse:function(c){var d,e=this;c=c||window.event,1!==b.data.themes.length&&(a(c.target).is(".theme-backdrop")||a(c.target).is("div.close")||27===c.keyCode)&&(a("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){a("body").removeClass("theme-overlay-open closing-overlay"),e.closeOverlay(),d=document.body.scrollTop,b.router.navigate(b.router.baseUrl(""),{replace:!0}),document.body.scrollTop=d}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled"),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled")},closeOverlay:function(){this.remove(),this.unbind(),this.trigger("theme:collapse")},deleteTheme:function(){return confirm(b.data.settings.confirmDelete)},nextTheme:function(){var a=this;a.trigger("theme:next",a.model.cid)},previousTheme:function(){var a=this;a.trigger("theme:previous",a.model.cid)},screenshotCheck:function(a){var b,c;b=a.find(".screenshot img"),c=new Image,c.src=b.attr("src"),c.width&&c.width<=300&&a.addClass("small-screenshot")}}),b.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:a("div.theme-overlay"),index:0,count:a(".theme-count"),initialize:function(b){var c=this;this.parent=b.parent,this.setView("grid"),c.currentTheme(),this.listenTo(c.collection,"update",function(){c.parent.page=0,c.currentTheme(),c.render(this)}),this.listenTo(this.parent,"theme:scroll",function(){c.renderThemes(c.parent.page)}),a("body").on("keyup",function(a){39===a.keyCode&&c.overlay.nextTheme(),37===a.keyCode&&c.overlay.previousTheme(),27===a.keyCode&&c.overlay.collapse(a)})},render:function(){this.$el.html(""),1===b.data.themes.length&&(this.singleTheme=new b.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),this.renderThemes(this.parent.page),this.count.text(this.collection.length)},renderThemes:function(d){var e=this;e.instance=e.collection.paginate(d),0!==e.instance.length&&(d>=1&&a(".add-new-theme").remove(),e.instance.each(function(a){e.theme=new b.view.Theme({model:a}),e.theme.render(),e.$el.append(e.theme.el),e.listenTo(e.theme,"theme:expand",e.expand,e)}),b.data.settings.canInstall&&this.$el.append('

'+c.addNew+"

"),this.parent.page++)},currentTheme:function(){var a,b=this;a=b.collection.findWhere({active:!0}),a&&(b.collection.remove(a),b.collection.add(a,{at:0}))},setView:function(a){return a},expand:function(c){var d=this;this.model=d.collection.get(c),b.router.navigate(b.router.baseUrl("?theme="+this.model.id),{replace:!0}),this.setView("detail"),a("body").addClass("theme-overlay-open"),this.overlay=new b.view.Details({model:d.model}),this.overlay.render(),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){d.next([d.model.cid])}).listenTo(this.overlay,"theme:previous",function(){d.previous([d.model.cid])})},next:function(a){var b,c,d=this;b=d.collection.get(a[0]),c=d.collection.at(d.collection.indexOf(b)+1),void 0!==c&&(this.overlay.closeOverlay(),d.theme.trigger("theme:expand",c.cid))},previous:function(a){var b,c,d=this;b=d.collection.get(a[0]),c=d.collection.at(d.collection.indexOf(b)-1),void 0!==c&&(this.overlay.closeOverlay(),d.theme.trigger("theme:expand",c.cid))}}),b.view.Search=wp.Backbone.View.extend({tagName:"input",className:"theme-search",attributes:{placeholder:c.search,type:"search"},events:{input:"search",keyup:"search",change:"search",search:"search"},search:function(a){"keyup"===a.type&&27===a.which&&(a.target.value=""),this.collection.doSearch(a.target.value),a.target.value?b.router.navigate(b.router.baseUrl("?search="+a.target.value),{replace:!0}):b.router.navigate(b.router.baseUrl(""),{replace:!0})}}),b.routes=Backbone.Router.extend({initialize:function(){this.routes=_.object([])},baseUrl:function(a){return b.data.settings.root+a},search:function(b){a(".theme-search").val(b),self.themes.doSearch(b)}}),b.Run={init:function(){this.themes=new b.Collection(b.data.themes),this.view=new b.view.Appearance({collection:this.themes}),this.render()},render:function(){this.view.render(),this.routes(),"undefined"!=typeof b.data.settings.theme&&""!==b.data.settings.theme&&this.view.view.theme.trigger("theme:expand",this.view.collection.findWhere({id:b.data.settings.theme})),"undefined"!=typeof b.data.settings.search&&""!==b.data.settings.search&&(a(".theme-search").val(b.data.settings.search),this.themes.doSearch(b.data.settings.search)),window.history&&window.history.pushState&&Backbone.history.start({pushState:!0,silent:!0})},routes:function(){b.router=new b.routes}},jQuery(document).ready(_.bind(b.Run.init,b.Run))}(jQuery);var tb_position;jQuery(document).ready(function(a){tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height(),e=c>1040?1040:c,f=0;a("body.admin-bar").length&&(f=parseInt(jQuery("#wpadminbar").css("height"),10)),b.size()&&(b.width(e-50).height(d-45-f),a("#TB_iframeContent").width(e-50).height(d-75-f),b.css({"margin-left":"-"+parseInt((e-50)/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:20+f+"px","margin-top":"0"}))},a(window).resize(function(){tb_position()})}); \ No newline at end of file diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 0e5be5f2e7..bac6631b19 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -91,6 +91,7 @@ if ( current_user_can( 'switch_themes' ) ) { } else { $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) ); } +wp_reset_vars( array( 'theme', 'search' ) ); wp_localize_script( 'theme', '_wpThemeSettings', array( 'themes' => $themes, @@ -98,8 +99,10 @@ wp_localize_script( 'theme', '_wpThemeSettings', array( 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), - 'root' => admin_url( 'themes.php' ), - 'extraRoutes' => '', + 'root' => parse_url( admin_url( 'themes.php' ), PHP_URL_PATH ), + 'theme' => esc_html( $theme ), + 'search' => esc_html( $search ), + ), 'l10n' => array( 'addNew' => __( 'Add New Theme' ), @@ -227,6 +230,7 @@ foreach ( $themes as $theme ) : ?>
+