Ticket #20877: 20877.4.diff

File 20877.4.diff, 4.2 KB (added by nacin, 11 months ago)
Line 
1Index: wp-includes/admin-bar.php
2===================================================================
3--- wp-includes/admin-bar.php   (revision 21027)
4+++ wp-includes/admin-bar.php   (working copy)
5@@ -576,11 +576,12 @@
6        if ( ! current_user_can( 'edit_theme_options' ) )
7                return;
8 
9+       $current_url = is_ssl() ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
10        $wp_admin_bar->add_menu( array(
11                'parent' => 'appearance',
12                'id'     => 'customize',
13                'title'  => __('Customize'),
14-               'href'   => wp_customize_url(),
15+               'href'   => add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ),
16                'meta'   => array(
17                        'class' => 'hide-if-no-customize',
18                ),
19Index: wp-includes/js/customize-base.dev.js
20===================================================================
21--- wp-includes/js/customize-base.dev.js        (revision 21027)
22+++ wp-includes/js/customize-base.dev.js        (working copy)
23@@ -498,7 +498,7 @@
24                        $.extend( this, options || {} );
25 
26                        this.add( 'channel', params.channel );
27-                       this.add( 'url', params.url );
28+                       this.add( 'url', params.url || '' );
29                        this.add( 'targetWindow', params.targetWindow || defaultTarget );
30                        this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
31                                return to.replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
32Index: wp-admin/customize.php
33===================================================================
34--- wp-admin/customize.php      (revision 21027)
35+++ wp-admin/customize.php      (working copy)
36@@ -11,6 +11,14 @@
37 if ( ! current_user_can( 'edit_theme_options' ) )
38        wp_die( __( 'Cheatin’ uh?' ) );
39 
40+wp_reset_vars( array( 'url', 'return' ) );
41+$url = urldecode( $url );
42+$url = wp_validate_redirect( $url, home_url( '/' ) );
43+if ( $return )
44+       $return = wp_validate_redirect( urldecode( $return ) );
45+if ( ! $return )
46+       $return = $url;
47+
48 global $wp_scripts, $wp_customize;
49 
50 $registered = $wp_scripts->registered;
51@@ -64,7 +72,7 @@
52                                submit_button( $save_text, 'primary', 'save', false );
53                        ?>
54                        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
55-                       <a class="back button" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
56+                       <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
57                                <?php _e( 'Cancel' ); ?>
58                        </a>
59                </div>
60@@ -146,13 +154,14 @@
61                        'active'     => $wp_customize->is_theme_active(),
62                ),
63                'url'      => array(
64-                       'preview'       => esc_url( home_url( '/' ) ),
65+                       'preview'       => esc_url( $url ? $url : home_url( '/' ) ),
66                        'parent'        => esc_url( admin_url() ),
67                        'activated'     => esc_url( admin_url( 'themes.php?activated=true' ) ),
68                        'ajax'          => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
69                        'allowed'       => array_map( 'esc_url', $allowed_urls ),
70                        'isCrossDomain' => $cross_domain,
71                        'fallback'      => $fallback_url,
72+                       'home'          => esc_url( home_url( '/' ) ),
73                ),
74                'browser'  => array(
75                        'mobile' => wp_is_mobile(),
76Index: wp-admin/js/customize-controls.dev.js
77===================================================================
78--- wp-admin/js/customize-controls.dev.js       (revision 21027)
79+++ wp-admin/js/customize-controls.dev.js       (working copy)
80@@ -403,7 +403,8 @@
81                 */
82                initialize: function( params, options ) {
83                        var self = this,
84-                               rscheme = /^https?/;
85+                               rscheme = /^https?/,
86+                               url;
87 
88                        $.extend( this, options || {} );
89 
90@@ -444,6 +445,9 @@
91                        this.container   = api.ensure( params.container );
92                        this.allowedUrls = params.allowedUrls;
93 
94+                       url = params.url;
95+                       delete params.url;
96+
97                        api.Messenger.prototype.initialize.call( this, params );
98 
99                        // We're dynamically generating the iframe, so the origin is set
100@@ -488,7 +492,10 @@
101                                return result ? result : null;
102                        });
103 
104-                       // Refresh the preview when the URL is changed.
105+                       // Set the url.
106+                       this.url( url );
107+
108+                       // Refresh the preview when the URL is changed (but not yet).
109                        this.url.bind( this.refresh );
110 
111                        this.scroll = 0;
112@@ -635,8 +642,11 @@
113                        } ) );
114                });
115 
116-               // Load the preview frame.
117-               previewer.refresh();
118+               // Check if preview url is valid and load the preview frame.
119+               if ( previewer.url() )
120+                       previewer.refresh();
121+               else
122+                       previewer.url( api.settings.url.home );
123 
124                // Save and activated states
125                (function() {