get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'upstudy_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'upstudy_customize_partial_blogdescription', ) ); } } add_action( 'customize_register', 'upstudy_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function upstudy_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function upstudy_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function upstudy_customize_preview_js() { wp_enqueue_script( 'upstudy-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), UPSTUDY_THEME_VERSION, true ); } add_action( 'customize_preview_init', 'upstudy_customize_preview_js' ); ///Theme settings style root function upstudy_get_url_override_allowlist() { return [ 'blog_single_layout' => ['blog_layout_image_first', 'blog_layout_title_first', 'blog_layout_overlay'], 'tutor_single_page_layout' => ['1', '2', '3', '4', '5'], 'lp_single_page_layout' => ['1', '2', '3', '4', '5'], 'ld_single_page_layout' => ['1', '2', '3', '4', '5'], 'ms_single_page_layout' => ['1', '2', '3', '4', '5'], 'sen_course_archive_style' => ['1', '2', '3', '4', '5'], 'lif_single_page_layout' => ['1', '2', '3', '4', '5'], 'rtl_single_page_layout' => ['1', '2', '3', '4', '5'], ]; } add_action('after_setup_theme', function () { $allowlist = upstudy_get_url_override_allowlist(); foreach ($allowlist as $setting => $allowed_values) { // Each theme_mod_{setting} for separate filter add_filter("theme_mod_{$setting}", function ($value) use ($setting, $allowed_values) { if (isset($_GET[$setting])) { $new = sanitize_text_field(wp_unslash($_GET[$setting])); if (in_array($new, $allowed_values, true)) { return $new; } } return $value; }, 10, 1); } });