[wp-trac] [WordPress Trac] #34769: Function in register_sidebar do not change value in customizer

WordPress Trac noreply at wordpress.org
Mon Nov 23 15:15:03 UTC 2015


#34769: Function in register_sidebar do not change value in customizer
-----------------------------------------------+---------------------------
 Reporter:  rinkuyadav999                      |       Owner:
     Type:  defect (bug)                       |      Status:  new
 Priority:  normal                             |   Milestone:  Awaiting
Component:  Customize                          |  Review
 Severity:  normal                             |     Version:  4.3.1
 Keywords:  has-screenshots reporter-feedback  |  Resolution:
                                               |     Focuses:
-----------------------------------------------+---------------------------
Changes (by nullvariable):

 * keywords:   => has-screenshots reporter-feedback


Comment:

 Hi Rinku,

 Can you share the code that you're using to create your option(s)?

 There are two options for the `transport` setting, `postMessage` and
 `refresh`, if you're using `refresh` then your preview will not live
 update.

 Here's how it works in the twentyfifteen theme:
 {{{
 $wp_customize->add_setting( 'header_background_color', array(
                 'default'           => $color_scheme[1],
                 'sanitize_callback' => 'sanitize_hex_color',
                 'transport'         => 'postMessage',
         ) );
 }}}
 And the Javascript that makes it happen, from the `js/customize-
 preview.js` file:
 {{{
 api.bind( 'preview-ready', function() {
                 api.preview.bind( 'update-color-scheme-css', function( css
 ) {
                         $style.html( css );
                 } );
         } );
 }}}

 Here's some useful documentation about the `postMessage` option:
 https://developer.wordpress.org/themes/advanced-topics/customizer-api
 /#using-postmessage-for-improved-setting-previewing

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34769#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list