WP Customizer
-
Hi, write code
// Font Size $wp_customize->add_setting( 'live_chat_lazucrub_window_footer_font_size_setting', array( 'default' => 16, 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'live_chat_lazucrub_window_footer_font_size_control', array( 'label' => __( 'Font Size(px)', 'livechat' ), 'section' => 'live_chat_lazucrub_window_footer_section', 'settings' => 'live_chat_lazucrub_window_footer_font_size_setting', 'type' => 'number' ) ) ); // Height $wp_customize->add_setting( 'live_chat_lazucrub_window_footer_height_setting', array( 'default' => 60, 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'live_chat_lazucrub_window_footer_height_control', array( 'section' => 'live_chat_lazucrub_window_footer_section', 'settings' => 'live_chat_lazucrub_window_footer_height_setting', 'type' => 'hidden' ) ) );
and
// Message Font Size wp.customize( 'live_chat_lazucrub_window_footer_font_size_setting', function( value ) { value.bind( function( newval ) { root.style.setProperty('--livechat-footer-font-size', newval + 'px' );console.log(wp.customize.instance( 'live_chat_lazucrub_window_footer_font_size_setting').get()) blockHeight('.input-message', 'footer'); } ); }); function blockHeight( blockName, hiddenField ) { var height = $('#chat ' + blockName ).outerHeight(); root.style.setProperty('--livechat-' + hiddenField + '-height', height + 'px' );console.log(wp.customize.instance( 'live_chat_lazucrub_window_' + hiddenField + '_height_setting' ).get()) wp.customize.instance( 'live_chat_lazucrub_window_' + hiddenField + '_height_setting' ).set( height ); }
i need saved height but when saving, get old value with id ‘live_chat_lazucrub_window_footer_height_setting’. How to save new value?
- The topic ‘WP Customizer’ is closed to new replies.