Make WordPress Core


Ignore:
Timestamp:
04/30/2012 03:46:17 PM (13 years ago)
Author:
koopersmith
Message:

Theme Customizer: Migrate to an ajax-based solution for refreshing the preview and saving. see #20507, #19910.

  • Use ajax-based saving, add saving indicator.
  • Use ajax-based refreshing instead of form targets.
  • Instead of using hidden inputs with prefixed names to track the canonical data, use the values stored in wp.customize. Encode the values as JSON before sending to avoid bugs with ids that contain square brackets (PHP mangles POST values with nested brackets).
  • Use wp.customize.Previewer solely for the purpose of previewing; move the postMessage connection with the parent frame and other unrelated code snippets into the 'ready' handler.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/customize-controls.php

    r20585 r20645  
    4242</head>
    4343<body class="wp-full-overlay">
    44     <form id="customize-controls" method="post" class="wrap wp-full-overlay-sidebar" target="_parent" action="<?php echo esc_url( add_query_arg( 'save_customize_controls', '1', admin_url( 'themes.php' ) ) ); ?>">
     44    <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
    4545        <?php wp_nonce_field( 'customize_controls' ); ?>
    46         <input type="hidden" name="customize" value="on" />
    47         <input type="hidden" name="theme" value="<?php echo esc_attr( $this->get_stylesheet() ); ?>" />
    4846        <div id="customize-header-actions" class="customize-section wp-full-overlay-header">
    4947            <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
     
    8078            submit_button( $save_text, 'primary', 'save', false );
    8179            ?>
     80            <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
     81
    8282            <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
    8383                <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
     
    8686        </div>
    8787    </form>
    88     <div id="customize-preview" class="wp-full-overlay-main">
    89         <iframe name="customize-target"></iframe>
    90     </div>
     88    <div id="customize-preview" class="wp-full-overlay-main"></div>
    9189    <?php
    9290
     
    9694    $scheme = is_ssl() ? 'https' : 'http';
    9795    $settings = array(
     96        'theme'    => $this->get_stylesheet(),
    9897        'preview'  => esc_url( home_url( '/', $scheme ) ),
    9998        'settings' => array(),
    10099        'controls' => array(),
    101         'prefix'   => WP_Customize_Setting::name_prefix,
    102100        'parent'   => esc_url( admin_url() ),
     101        'ajax'     => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
    103102    );
    104103
Note: See TracChangeset for help on using the changeset viewer.