: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Bind to our global `wp.themes` object
// so that the router is available to sub-views.
themes.router = new themes.InstallerRouter();
// Handles `theme` route event.
// Queries the API for the passed theme slug.
themes.router.on( 'route:preview', function( slug ) {
// Remove existing handlers.
themes.preview.undelegateEvents();
// If the theme preview is active, set the current theme.
if ( self.view.view.theme && self.view.view.theme.preview ) {
self.view.view.theme.model = self.view.collection.findWhere( { 'slug': slug } );
self.view.view.theme.preview();
// Select the theme by slug.
self.view.collection.query( request );
self.view.collection.trigger( 'update' );
// Open the theme preview.
self.view.collection.once( 'query:success', function() {
$( 'div[data-slug="' + slug + '"]' ).trigger( 'click' );
* Handles sorting / browsing routes.
* Also handles the root URL triggering a sort request
* for `popular`, the default view.
themes.router.on( 'route:sort', function( sort ) {
themes.router.navigate( themes.router.baseUrl( '?browse=popular' ), { replace: true } );
// Close the preview if open.
// The `search` route event. The router populates the input field.
themes.router.on( 'route:search', function() {
$( '.wp-filter-search' ).trigger( 'focus' ).trigger( 'keyup' );
extraRoutes: function() {
if ( themes.isInstall ) {
themes.RunInstaller.init();
// Update the return param just in time.
$( document.body ).on( 'click', '.load-customize', function() {
var link = $( this ), urlParser = document.createElement( 'a' );
urlParser.href = link.prop( 'href' );
urlParser.search = $.param( _.extend(
wp.customize.utils.parseQueryString( urlParser.search.substr( 1 ) ),
'return': window.location.href
link.prop( 'href', urlParser.href );
$( '.broken-themes .delete-theme' ).on( 'click', function() {
return confirm( _wpThemeSettings.settings.confirmDelete );
// Align theme browser thickbox.
window.tb_position = function() {
var tbWindow = $('#TB_window'),
width = $(window).width(),
W = ( 1040 < width ) ? 1040 : width,
if ( $('#wpadminbar').length ) {
adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 );
if ( tbWindow.length >= 1 ) {
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
if ( typeof document.body.style.maxWidth !== 'undefined' ) {
tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
$(window).on( 'resize', function(){ tb_position(); });