<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[21028] trunk: Customizer: Redirect back to referrer.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21028">21028</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-06-08 18:45:12 +0000 (Fri, 08 Jun 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Customizer: Redirect back to referrer. If referrer is a front end page, load that page in the customizer preview. Props nacin, koopersmith. fixes <a href="http://core.trac.wordpress.org/ticket/20877">#20877</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustomizephp">trunk/wp-admin/customize.php</a></li>
<li><a href="#trunkwpadminjscustomizecontrolsdevjs">trunk/wp-admin/js/customize-controls.dev.js</a></li>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
<li><a href="#trunkwpincludesjscustomizebasedevjs">trunk/wp-includes/js/customize-base.dev.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustomizephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/customize.php (21027 => 21028)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/customize.php        2012-06-07 23:33:00 UTC (rev 21027)
+++ trunk/wp-admin/customize.php        2012-06-08 18:45:12 UTC (rev 21028)
</span><span class="lines">@@ -11,6 +11,14 @@
</span><span class="cx"> if ( ! current_user_can( 'edit_theme_options' ) )
</span><span class="cx">         wp_die( __( 'Cheatin&amp;#8217; uh?' ) );
</span><span class="cx"> 
</span><ins>+wp_reset_vars( array( 'url', 'return' ) );
+$url = urldecode( $url );
+$url = wp_validate_redirect( $url, home_url( '/' ) );
+if ( $return )
+        $return = wp_validate_redirect( urldecode( $return ) );
+if ( ! $return )
+        $return = $url;
+
</ins><span class="cx"> global $wp_scripts, $wp_customize;
</span><span class="cx"> 
</span><span class="cx"> $registered = $wp_scripts-&gt;registered;
</span><span class="lines">@@ -64,7 +72,7 @@
</span><span class="cx">                                 submit_button( $save_text, 'primary', 'save', false );
</span><span class="cx">                         ?&gt;
</span><span class="cx">                         &lt;img src=&quot;&lt;?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?&gt;&quot; /&gt;
</span><del>-                        &lt;a class=&quot;back button&quot; href=&quot;&lt;?php echo esc_url( admin_url( 'themes.php' ) ); ?&gt;&quot;&gt;
</del><ins>+                        &lt;a class=&quot;back button&quot; href=&quot;&lt;?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?&gt;&quot;&gt;
</ins><span class="cx">                                 &lt;?php _e( 'Cancel' ); ?&gt;
</span><span class="cx">                         &lt;/a&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="lines">@@ -146,13 +154,14 @@
</span><span class="cx">                         'active'     =&gt; $wp_customize-&gt;is_theme_active(),
</span><span class="cx">                 ),
</span><span class="cx">                 'url'      =&gt; array(
</span><del>-                        'preview'       =&gt; esc_url( home_url( '/' ) ),
</del><ins>+                        'preview'       =&gt; esc_url( $url ? $url : home_url( '/' ) ),
</ins><span class="cx">                         'parent'        =&gt; esc_url( admin_url() ),
</span><span class="cx">                         'activated'     =&gt; esc_url( admin_url( 'themes.php?activated=true' ) ),
</span><span class="cx">                         'ajax'          =&gt; esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
</span><span class="cx">                         'allowed'       =&gt; array_map( 'esc_url', $allowed_urls ),
</span><span class="cx">                         'isCrossDomain' =&gt; $cross_domain,
</span><span class="cx">                         'fallback'      =&gt; $fallback_url,
</span><ins>+                        'home'          =&gt; esc_url( home_url( '/' ) ),
</ins><span class="cx">                 ),
</span><span class="cx">                 'browser'  =&gt; array(
</span><span class="cx">                         'mobile' =&gt; wp_is_mobile(),
</span></span></pre></div>
<a id="trunkwpadminjscustomizecontrolsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/customize-controls.dev.js (21027 => 21028)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/customize-controls.dev.js        2012-06-07 23:33:00 UTC (rev 21027)
+++ trunk/wp-admin/js/customize-controls.dev.js        2012-06-08 18:45:12 UTC (rev 21028)
</span><span class="lines">@@ -403,7 +403,8 @@
</span><span class="cx">                  */
</span><span class="cx">                 initialize: function( params, options ) {
</span><span class="cx">                         var self = this,
</span><del>-                                rscheme = /^https?/;
</del><ins>+                                rscheme = /^https?/,
+                                url;
</ins><span class="cx"> 
</span><span class="cx">                         $.extend( this, options || {} );
</span><span class="cx"> 
</span><span class="lines">@@ -444,6 +445,9 @@
</span><span class="cx">                         this.container   = api.ensure( params.container );
</span><span class="cx">                         this.allowedUrls = params.allowedUrls;
</span><span class="cx"> 
</span><ins>+                        url = params.url;
+                        delete params.url;
+
</ins><span class="cx">                         api.Messenger.prototype.initialize.call( this, params );
</span><span class="cx"> 
</span><span class="cx">                         // We're dynamically generating the iframe, so the origin is set
</span><span class="lines">@@ -488,7 +492,10 @@
</span><span class="cx">                                 return result ? result : null;
</span><span class="cx">                         });
</span><span class="cx"> 
</span><del>-                        // Refresh the preview when the URL is changed.
</del><ins>+                        // Set the url.
+                        this.url( url );
+
+                        // Refresh the preview when the URL is changed (but not yet).
</ins><span class="cx">                         this.url.bind( this.refresh );
</span><span class="cx"> 
</span><span class="cx">                         this.scroll = 0;
</span><span class="lines">@@ -635,8 +642,11 @@
</span><span class="cx">                         } ) );
</span><span class="cx">                 });
</span><span class="cx"> 
</span><del>-                // Load the preview frame.
-                previewer.refresh();
</del><ins>+                // Check if preview url is valid and load the preview frame.
+                if ( previewer.url() )
+                        previewer.refresh();
+                else
+                        previewer.url( api.settings.url.home );
</ins><span class="cx"> 
</span><span class="cx">                 // Save and activated states
</span><span class="cx">                 (function() {
</span></span></pre></div>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (21027 => 21028)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php        2012-06-07 23:33:00 UTC (rev 21027)
+++ trunk/wp-includes/admin-bar.php        2012-06-08 18:45:12 UTC (rev 21028)
</span><span class="lines">@@ -576,11 +576,12 @@
</span><span class="cx">         if ( ! current_user_can( 'edit_theme_options' ) )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><ins>+        $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
</ins><span class="cx">         $wp_admin_bar-&gt;add_menu( array(
</span><span class="cx">                 'parent' =&gt; 'appearance',
</span><span class="cx">                 'id'     =&gt; 'customize',
</span><span class="cx">                 'title'  =&gt; __('Customize'),
</span><del>-                'href'   =&gt; wp_customize_url(),
</del><ins>+                'href'   =&gt; add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ),
</ins><span class="cx">                 'meta'   =&gt; array(
</span><span class="cx">                         'class' =&gt; 'hide-if-no-customize',
</span><span class="cx">                 ),
</span></span></pre></div>
<a id="trunkwpincludesjscustomizebasedevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-base.dev.js (21027 => 21028)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-base.dev.js        2012-06-07 23:33:00 UTC (rev 21027)
+++ trunk/wp-includes/js/customize-base.dev.js        2012-06-08 18:45:12 UTC (rev 21028)
</span><span class="lines">@@ -498,7 +498,7 @@
</span><span class="cx">                         $.extend( this, options || {} );
</span><span class="cx"> 
</span><span class="cx">                         this.add( 'channel', params.channel );
</span><del>-                        this.add( 'url', params.url );
</del><ins>+                        this.add( 'url', params.url || '' );
</ins><span class="cx">                         this.add( 'targetWindow', params.targetWindow || defaultTarget );
</span><span class="cx">                         this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
</span><span class="cx">                                 return to.replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
</span></span></pre>
</div>
</div>

</body>
</html>