scope_selector example


        $has_custom_selector =
            ( isset( $block_type->supports['__experimentalSelector'] ) && is_string( $block_type->supports['__experimentalSelector'] ) ) ||
            ( isset( $block_type->selectors['root'] ) && is_string( $block_type->selectors['root'] ) );

        if ( $has_custom_selector ) {
            $variables_root_selector .= ',' . wp_get_block_css_selector( $block_type );
        }
    }
    $variables_root_selector = WP_Theme_JSON::scope_selector( $class_name$variables_root_selector );

    // Remove any potentially unsafe styles.     $theme_json_shape  = WP_Theme_JSON::remove_insecure_properties(
        array(
            'version'  => WP_Theme_JSON::LATEST_SCHEMA,
            'settings' => $block_settings,
        )
    );
    $theme_json_object = new WP_Theme_JSON( $theme_json_shape );

    $styles = '';

    
// Try getting old experimental supports selector value.         $path             = array_merge( $target, array( '__experimentalSelector' ) );
        $feature_selector = _wp_array_get( $block_type->supports, $path, null );

        // Nothing to work with, provide fallback or null.         if ( null === $feature_selector ) {
            return $fallback_selector;
        }

        // Scope the feature selector by the block's root selector.         return WP_Theme_JSON::scope_selector( $root_selector$feature_selector );
    }

    // Subfeature selector     // This may fallback either to parent feature or root selector.     $subfeature_selector = null;

    // Use selectors API if available.     if ( $has_selectors ) {
        $subfeature_selector = _wp_array_get( $block_type->selectors, $target, null );
    }

    


            // The block may or may not have a duotone selector.             $duotone_selector = wp_get_block_css_selector( $block_type, 'filter.duotone' );

            // Keep backwards compatibility for support.color.__experimentalDuotone.             if ( null === $duotone_selector ) {
                $duotone_support = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), null );

                if ( $duotone_support ) {
                    $root_selector    = wp_get_block_css_selector( $block_type );
                    $duotone_selector = WP_Theme_JSON::scope_selector( $root_selector$duotone_support );
                }
            }

            if ( null !== $duotone_selector ) {
                static::$blocks_metadata[ $block_name ]['duotone'] = $duotone_selector;
            }

            // If the block has style variations, append their selectors to the block metadata.             if ( ! empty( $block_type->styles ) ) {
                $style_selectors = array();
                foreach ( $block_type->styles as $style ) {
                    
return null;
        }

        /* * If the experimental duotone support was set, that value is to be * treated as a selector and requires scoping. */
        $experimental_duotone = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false );
        if ( $experimental_duotone ) {
            $root_selector = wp_get_block_css_selector( $block_type );
            return is_string( $experimental_duotone )
                ? WP_Theme_JSON::scope_selector( $root_selector$experimental_duotone )
                : $root_selector;
        }

        // Regular filter.duotone support uses filter.duotone selectors with fallbacks.         return wp_get_block_css_selector( $block_type, array( 'filter', 'duotone' ), true );
    }

    /** * Scrape all possible duotone presets from global and theme styles and * store them in self::$global_styles_presets. * * Used in conjunction with self::render_duotone_support for blocks that * use duotone preset filters. * * @since 6.3.0 * * @return array An array of global styles presets, keyed on the filter ID. */
Home | Imprint | This part of the site doesn't use cookies.