safecss_filter_attr example

// Typography text-decoration is only applied to the label and button.     if ( ! empty( $attributes['style']['typography']['textDecoration'] ) ) {
        $text_decoration_value = sprintf( 'text-decoration: %s;', esc_attr( $attributes['style']['typography']['textDecoration'] ) );
        $button_styles[]       = $text_decoration_value;
        // Input opts out of text decoration.         if ( $show_label ) {
            $label_styles[] = $text_decoration_value;
        }
    }

    return array(
        'input'   => ! empty( $input_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $input_styles ) ) ) ) : '',
        'button'  => ! empty( $button_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $button_styles ) ) ) ) : '',
        'wrapper' => ! empty( $wrapper_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $wrapper_styles ) ) ) ) : '',
        'label'   => ! empty( $label_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $label_styles ) ) ) ) : '',
    );
}

/** * Returns typography classnames depending on whether there are named font sizes/families . * * @param array $attributes The block attributes. * * @return string The typography color classnames to be applied to the block elements. */
if ( ! empty( $extra_styles ) ) {
        $attr['style'] = empty( $attr['style'] ) ? $extra_styles : $attr['style'] . $extra_styles;
    }

    $featured_image = get_the_post_thumbnail( $post_ID$size_slug$attr );
    if ( ! $featured_image ) {
        return '';
    }
    if ( $is_link ) {
        $link_target    = $attributes['linkTarget'];
        $rel            = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
        $height         = ! empty( $attributes['height'] ) ? 'style="' . esc_attr( safecss_filter_attr( 'height:' . $attributes['height'] ) ) . '"' : '';
        $featured_image = sprintf(
            '<a href="%1$s" target="%2$s" %3$s %4$s>%5$s%6$s</a>',
            get_the_permalink( $post_ID ),
            esc_attr( $link_target ),
            $rel,
            $height,
            $featured_image,
            $overlay_markup
        );
    } else {
        $featured_image = $featured_image . $overlay_markup;
    }
/** * Checks that a declaration provided by the user is safe. * * @since 5.9.0 * * @param string $property_name Property name in a CSS declaration, i.e. the `color` in `color: red`. * @param string $property_value Value in a CSS declaration, i.e. the `red` in `color: red`. * @return bool */
    protected static function is_safe_css_declaration( $property_name$property_value ) {
        $style_to_validate = $property_name . ': ' . $property_value;
        $filtered          = esc_html( safecss_filter_attr( $style_to_validate ) );
        return ! empty( trim( $filtered ) );
    }

    /** * Removes indirect properties from the given input node and * sets in the given output node. * * @since 6.2.0 * * @param array $input Node to process. * @param array $output The processed node. Passed by reference. */

        }
    } elseif ( 'constrained' === $layout_type ) {
        $content_size    = isset( $layout['contentSize'] ) ? $layout['contentSize'] : '';
        $wide_size       = isset( $layout['wideSize'] ) ? $layout['wideSize'] : '';
        $justify_content = isset( $layout['justifyContent'] ) ? $layout['justifyContent'] : 'center';

        $all_max_width_value  = $content_size ? $content_size : $wide_size;
        $wide_max_width_value = $wide_size ? $wide_size : $content_size;

        // Make sure there is a single CSS rule, and all tags are stripped for security.         $all_max_width_value  = safecss_filter_attr( explode( ';', $all_max_width_value )[0] );
        $wide_max_width_value = safecss_filter_attr( explode( ';', $wide_max_width_value )[0] );

        $margin_left  = 'left' === $justify_content ? '0 !important' : 'auto !important';
        $margin_right = 'right' === $justify_content ? '0 !important' : 'auto !important';

        if ( $content_size || $wide_size ) {
            array_push(
                $layout_styles,
                array(
                    'selector'     => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
                    'declarations' => array(
                        

    protected static function filter_declaration( $property$value$spacer = '' ) {
        $filtered_value = wp_strip_all_tags( $value, true );
        if ( '' !== $filtered_value ) {
            return safecss_filter_attr( "{$property}:{$spacer}{$filtered_value});
        }
        return '';
    }

    /** * Filters and compiles the CSS declarations. * * @since 6.1.0 * * @param bool $should_prettify Optional. Whether to add spacing, new lines and indents. * Default false. * @param int $indent_count Optional. The number of tab indents to apply to the rule. * Applies if `prettify` is `true`. Default 0. * @return string The CSS declarations. */

        esc_attr( $modal_unique_id ),
        $inner_blocks_html,
        $toggle_aria_label_open,
        $toggle_aria_label_close,
        esc_attr( implode( ' ', $responsive_container_classes ) ),
        esc_attr( implode( ' ', $open_button_classes ) ),
        esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ),
        __( 'Menu' ),
        $toggle_button_content,
        $toggle_close_button_content,
        $open_button_directives,
        $responsive_container_directives,
        $responsive_dialog_directives,
        $close_button_directives
    );

    return sprintf(
        '<nav %1$s %3$s>%2$s</nav>',
        

            $allowed_attr[ $match[0] ] = $allowed_attr['data-*'];
        } else {
            $name  = '';
            $value = '';
            $whole = '';
            return false;
        }
    }

    if ( 'style' === $name_low ) {
        $new_value = safecss_filter_attr( $value );

        if ( empty( $new_value ) ) {
            $name  = '';
            $value = '';
            $whole = '';
            return false;
        }

        $whole = str_replace( $value$new_value$whole );
        $value = $new_value;
    }

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