add_partial example


            $partial_class = apply_filters( 'customize_dynamic_partial_class', $partial_class$partial_id$partial_args );

            $partial = new $partial_class( $this$partial_id$partial_args );

            $this->add_partial( $partial );
            $new_partials[] = $partial;
        }
        return $new_partials;
    }

    /** * Checks whether the request is for rendering partials. * * Note that this will not consider whether the request is authorized or valid, * just that essentially the route is a match. * * @since 4.5.0 * * @return bool Whether the request is for rendering partials. */
'change'       => __( 'Change logo' ),
                        'remove'       => __( 'Remove' ),
                        'default'      => __( 'Default' ),
                        'placeholder'  => __( 'No logo selected' ),
                        'frame_title'  => __( 'Select logo' ),
                        'frame_button' => __( 'Choose logo' ),
                    ),
                )
            )
        );

        $this->selective_refresh->add_partial(
            'custom_logo',
            array(
                'settings'            => array( 'custom_logo' ),
                'selector'            => '.custom-logo-link',
                'render_callback'     => array( $this, '_render_custom_logo_partial' ),
                'container_inclusive' => true,
            )
        );

        /* Colors */

        

        public function register( $wp_customize ) {

            // Change site-title & description to postMessage.             $wp_customize->get_setting( 'blogname' )->transport        = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists.             $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists.
            // Add partial for blogname.             $wp_customize->selective_refresh->add_partial(
                'blogname',
                array(
                    'selector'        => '.site-title',
                    'render_callback' => array( $this, 'partial_blogname' ),
                )
            );

            // Add partial for blogdescription.             $wp_customize->selective_refresh->add_partial(
                'blogdescription',
                array(
                    
'section'         => 'colors',
                'label'           => esc_html__( 'Dark Mode support', 'twentytwentyone' ),
                'priority'        => 110,
                'description'     => $description,
                'active_callback' => static function( $value ) {
                    return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
                },
            )
        );

        // Add partial for background_color.         $wp_customize->selective_refresh->add_partial(
            'background_color',
            array(
                'selector'            => '#dark-mode-toggler',
                'container_inclusive' => true,
                'render_callback'     => function() {
                    $attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' );
                    $this->the_html( $attrs );
                },
            )
        );
    }

    
Home | Imprint | This part of the site doesn't use cookies.