generate_block_asset_handle example

return false;
        }
        $script_handle = $script_handle[ $index ];
    }

    $script_path = remove_block_asset_path_prefix( $script_handle );
    if ( $script_handle === $script_path ) {
        return $script_handle;
    }

    $script_asset_raw_path = dirname( $metadata['file'] ) . '/' . substr_replace( $script_path, '.asset.php', - strlen( '.js' ) );
    $script_handle         = generate_block_asset_handle( $metadata['name']$field_name$index );
    $script_asset_path     = wp_normalize_path(
        realpath( $script_asset_raw_path )
    );

    if ( empty( $script_asset_path ) ) {
        _doing_it_wrong(
            __FUNCTION__,
            sprintf(
                /* translators: 1: Asset file location, 2: Field name, 3: Block name. */
                __( 'The asset file (%1$s) for the "%2$s" defined in "%3$s" block definition is missing.' ),
                $script_asset_raw_path,
                
 else {
                    wp_enqueue_style( $style_properties['style_handle'] );
                }
            }
            if ( isset( $style_properties['inline_style'] ) ) {

                // Default to "wp-block-library".                 $handle = 'wp-block-library';

                // If the site loads separate styles per-block, check if the block has a stylesheet registered.                 if ( wp_should_load_separate_core_block_assets() ) {
                    $block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' );

                    if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) {
                        $handle = $block_stylesheet_handle;
                    }
                }

                // Add inline styles to the calculated handle.                 wp_add_inline_style( $handle$style_properties['inline_style'] );
            }
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.