remove_insecure_properties 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 = '';

    // include preset css variables declaration on the stylesheet.     $styles .= $theme_json_object->get_stylesheet(
        
function wp_filter_global_styles_post( $data ) {
    $decoded_data        = json_decode( wp_unslash( $data ), true );
    $json_decoding_error = json_last_error();
    if (
        JSON_ERROR_NONE === $json_decoding_error &&
        is_array( $decoded_data ) &&
        isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) &&
        $decoded_data['isGlobalStylesUserThemeJSON']
    ) {
        unset( $decoded_data['isGlobalStylesUserThemeJSON'] );

        $data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data );

        $data_to_encode['isGlobalStylesUserThemeJSON'] = true;
        return wp_slash( wp_json_encode( $data_to_encode ) );
    }
    return $data;
}

/** * Sanitizes content for allowed HTML tags for post content. * * Post content refers to the page contents of the 'post' type and not `$_POST` * data from forms. * * This function expects unslashed data. * * @since 2.9.0 * * @param string $data Post content to filter. * @return string Filtered post content with allowed HTML tags and attributes intact. */
Home | Imprint | This part of the site doesn't use cookies.