add shortcode support in customizer

Recently, I was not understand how to get the updated customizer contents in $UPDATED_CONTROL_CONTENTS variable within the selective_refresh.


I used type => option for the setting. So, It store the date in option name my-sample-text-option.

So, Using get_option() I’m able to get the update options from customizer.


Solution:

/**
 * Add partial refresh
 */
if ( isset( $wp_customize->selective_refresh ) ) {

    $wp_customize->selective_refresh->add_partial( 'my-sample-text-option', array(
        'selector'            => '.custom-html-section',
        'container_inclusive' => false,
        'render_callback'     => function() {

            // Get update data from option `my-sample-text-option` using funcition get_option()
            $options = get_option( `my-sample-text-option` );
            return do_shortcode( $options );

        },
    ) );
}