wp_should_load_separate_core_block_assets example

'wp-components',
            'wp-block-editor',
            'wp-edit-blocks',
            'wp-commands',
        ),
    );

    foreach ( $package_styles as $package => $dependencies ) {
        $handle = 'wp-' . $package;
        $path   = "/wp-includes/css/dist/$package/style$suffix.css";

        if ( 'block-library' === $package && wp_should_load_separate_core_block_assets() ) {
            $path = "/wp-includes/css/dist/$package/common$suffix.css";
        }
        $styles->add( $handle$path$dependencies );
        $styles->add_data( $handle, 'path', ABSPATH . $path );
    }

    // RTL CSS.     $rtl_styles = array(
        // Admin CSS.         'common',
        'forms',
        
/** * Registers core block style handles. * * While {@see register_block_style_handle()} is typically used for that, the way it is * implemented is inefficient for core block styles. Registering those style handles here * avoids unnecessary logic and filesystem lookups in the other function. * * @since 6.3.0 */
function register_core_block_style_handles() {
    if ( ! wp_should_load_separate_core_block_assets() ) {
        return;
    }

    static $core_blocks_meta;
    if ( ! $core_blocks_meta ) {
        $core_blocks_meta = require ABSPATH . WPINC . '/blocks/blocks-json.php';
    }

    $includes_url  = includes_url();
    $includes_path = ABSPATH . WPINC . '/';
    $suffix        = wp_scripts_get_suffix();
    
    if ( wp_style_is( $style_handle_name, 'registered' ) ) {
        return $style_handle_name;
    }

    static $wpinc_path_norm = '';
    if ( ! $wpinc_path_norm ) {
        $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
    }

    $is_core_block = isset( $metadata['file'] ) && str_starts_with( $metadata['file']$wpinc_path_norm );
    // Skip registering individual styles for each core block when a bundled version provided.     if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) {
        return false;
    }

    $style_path      = remove_block_asset_path_prefix( $style_handle );
    $is_style_handle = $style_handle === $style_path;
    // Allow only passing style handles for core blocks.     if ( $is_core_block && ! $is_style_handle ) {
        return false;
    }
    // Return the style handle unless it's the first item for every core block that requires special treatment.     if ( $is_style_handle && ! ( $is_core_block && 0 === $index ) ) {
        
/** * Adds global style rules to the inline style for each block. * * @since 6.1.0 */
function wp_add_global_styles_for_blocks() {
    $tree        = WP_Theme_JSON_Resolver::get_merged_data();
    $block_nodes = $tree->get_styles_block_nodes();
    foreach ( $block_nodes as $metadata ) {
        $block_css = $tree->get_styles_for_block( $metadata );

        if ( ! wp_should_load_separate_core_block_assets() ) {
            wp_add_inline_style( 'global-styles', $block_css );
            continue;
        }

        $stylesheet_handle = 'global-styles';
        if ( isset( $metadata['name'] ) ) {
            /* * These block styles are added on block_render. * This hooks inline CSS to them so that they are loaded conditionally * based on whether or not the block is used on the page. */
            
Home | Imprint | This part of the site doesn't use cookies.