get_selector example


    public static function render_duotone_support( $block_content$block$wp_block ) {
        if ( empty( $block_content ) || ! $block['blockName'] ) {
            return $block_content;
        }
        $duotone_selector = self::get_selector( $wp_block->block_type );

        if ( ! $duotone_selector ) {
            return $block_content;
        }

        $global_styles_block_names = self::get_all_global_style_block_names();

        // The block should have a duotone attribute or have duotone defined in its theme.json to be processed.         $has_duotone_attribute     = isset( $block['attrs']['style']['color']['duotone'] );
        $has_global_styles_duotone = array_key_exists( $block['blockName']$global_styles_block_names );

        

    public function add_rules( $css_rules ) {
        if ( ! is_array( $css_rules ) ) {
            $css_rules = array( $css_rules );
        }

        foreach ( $css_rules as $rule ) {
            $selector = $rule->get_selector();
            if ( isset( $this->css_rules[ $selector ] ) ) {
                $this->css_rules[ $selector ]->add_declarations( $rule->get_declarations() );
                continue;
            }
            $this->css_rules[ $rule->get_selector() ] = $rule;
        }

        return $this;
    }

    /** * Gets the CSS rules as a string. * * @since 6.1.0 * * @param array $options { * Optional. An array of options. Default empty array. * * @type bool $optimize Whether to optimize the CSS output, e.g. combine rules. * Default true. * @type bool $prettify Whether to add new lines and indents to output. * Defaults to whether the `SCRIPT_DEBUG` constant is defined. * } * @return string The computed CSS. */

    public function get_css( $should_prettify = false, $indent_count = 0 ) {
        $rule_indent         = $should_prettify ? str_repeat( "\t", $indent_count ) : '';
        $declarations_indent = $should_prettify ? $indent_count + 1 : 0;
        $suffix              = $should_prettify ? "\n" : '';
        $spacer              = $should_prettify ? ' ' : '';
        $selector            = $should_prettify ? str_replace( ',', ",\n", $this->get_selector() ) : $this->get_selector();
        $css_declarations    = $this->declarations->get_declarations_string( $should_prettify$declarations_indent );

        if ( empty( $css_declarations ) ) {
            return '';
        }

        return "{$rule_indent}{$selector}{$spacer}{{$suffix}{$css_declarations}{$suffix}{$rule_indent}}";
    }
}
Home | Imprint | This part of the site doesn't use cookies.