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' => 'zeitfresser_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'zeitfresser_customize_partial_blogdescription', ) ); } /** * Performance Tools section */ $wp_customize->add_section( 'ztfr_performance_tools', array( 'title' => 'Performance Tools Settings', 'priority' => 160, ) ); /** * Auto optimize uploaded images. */ $wp_customize->add_setting( 'ztfr_auto_optimize', array( 'default' => true, 'sanitize_callback' => 'wp_validate_boolean', ) ); $wp_customize->add_control( 'ztfr_auto_optimize', array( 'type' => 'checkbox', 'section' => 'ztfr_performance_tools', 'label' => 'Auto Optimize Pictures on Upload', 'description' => 'Automatically converts uploaded images to modern formats (AVIF/WebP) for improved performance.', ) ); /** * Auto delete originals after successful optimization. */ $wp_customize->add_setting( 'ztfr_auto_delete', array( 'default' => false, 'sanitize_callback' => 'wp_validate_boolean', ) ); $wp_customize->add_control( 'ztfr_auto_delete', array( 'type' => 'checkbox', 'section' => 'ztfr_performance_tools', 'label' => 'Auto Delete Original Pictures on Upload', 'description' => 'Automatically deletes original images after optimization.', ) ); } add_action( 'customize_register', 'zeitfresser_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function zeitfresser_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function zeitfresser_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Bind JS handlers to make Theme Customizer preview reload changes asynchronously. * * @return void */ function zeitfresser_customize_preview_js() { wp_enqueue_script( 'zeitfresser-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), ZEITFRESSER_VERSION, true ); } add_action( 'customize_preview_init', 'zeitfresser_customize_preview_js' ); /** * Add dependency logic and status box for Performance Tools settings. * * @return void */ function zeitfresser_customize_controls_dependency_js() { ?>