Make WordPress Core

Changeset 21028


Ignore:
Timestamp:
06/08/2012 06:45:12 PM (14 years ago)
Author:
ryan
Message:

Customizer: Redirect back to referrer. If referrer is a front end page, load that page in the customizer preview. Props nacin, koopersmith. fixes #20877

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/customize.php

    r21014 r21028  
    1111if ( ! current_user_can( 'edit_theme_options' ) )
    1212        wp_die( __( 'Cheatin’ uh?' ) );
     13
     14wp_reset_vars( array( 'url', 'return' ) );
     15$url = urldecode( $url );
     16$url = wp_validate_redirect( $url, home_url( '/' ) );
     17if ( $return )
     18        $return = wp_validate_redirect( urldecode( $return ) );
     19if ( ! $return )
     20        $return = $url;
    1321
    1422global $wp_scripts, $wp_customize;
     
    6573                        ?>
    6674                        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
    67                         <a class="back button" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
     75                        <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
    6876                                <?php _e( 'Cancel' ); ?>
    6977                        </a>
     
    147155                ),
    148156                'url'      => array(
    149                         'preview'       => esc_url( home_url( '/' ) ),
     157                        'preview'       => esc_url( $url ? $url : home_url( '/' ) ),
    150158                        'parent'        => esc_url( admin_url() ),
    151159                        'activated'     => esc_url( admin_url( 'themes.php?activated=true' ) ),
     
    154162                        'isCrossDomain' => $cross_domain,
    155163                        'fallback'      => $fallback_url,
     164                        'home'          => esc_url( home_url( '/' ) ),
    156165                ),
    157166                'browser'  => array(
  • trunk/wp-admin/js/customize-controls.dev.js

    r21024 r21028  
    404404                initialize: function( params, options ) {
    405405                        var self = this,
    406                                 rscheme = /^https?/;
     406                                rscheme = /^https?/,
     407                                url;
    407408
    408409                        $.extend( this, options || {} );
     
    445446                        this.allowedUrls = params.allowedUrls;
    446447
     448                        url = params.url;
     449                        delete params.url;
     450
    447451                        api.Messenger.prototype.initialize.call( this, params );
    448452
     
    489493                        });
    490494
    491                         // Refresh the preview when the URL is changed.
     495                        // Set the url.
     496                        this.url( url );
     497
     498                        // Refresh the preview when the URL is changed (but not yet).
    492499                        this.url.bind( this.refresh );
    493500
     
    636643                });
    637644
    638                 // Load the preview frame.
    639                 previewer.refresh();
     645                // Check if preview url is valid and load the preview frame.
     646                if ( previewer.url() )
     647                        previewer.refresh();
     648                else
     649                        previewer.url( api.settings.url.home );
    640650
    641651                // Save and activated states
  • trunk/wp-includes/admin-bar.php

    r20934 r21028  
    577577                return;
    578578
     579        $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    579580        $wp_admin_bar->add_menu( array(
    580581                'parent' => 'appearance',
    581582                'id'     => 'customize',
    582583                'title'  => __('Customize'),
    583                 'href'   => wp_customize_url(),
     584                'href'   => add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ),
    584585                'meta'   => array(
    585586                        'class' => 'hide-if-no-customize',
  • trunk/wp-includes/js/customize-base.dev.js

    r21024 r21028  
    499499
    500500                        this.add( 'channel', params.channel );
    501                         this.add( 'url', params.url );
     501                        this.add( 'url', params.url || '' );
    502502                        this.add( 'targetWindow', params.targetWindow || defaultTarget );
    503503                        this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
Note: See TracChangeset for help on using the changeset viewer.