You've already forked wp-bootstrap
v0.2.0 - Design Editor: templates, patterns, header/footer variations
Full Design Editor compatibility with custom block categories, page templates, header/footer variations, and navigation styles. Both FSE (admin) and Twig (frontend) sides kept in sync. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -91,6 +91,60 @@ if ( ! function_exists( 'wp_bootstrap_enqueue_scripts' ) ) :
|
||||
endif;
|
||||
add_action( 'wp_enqueue_scripts', 'wp_bootstrap_enqueue_scripts' );
|
||||
|
||||
/**
|
||||
* Enqueue Bootstrap JS in the block editor for interactive previews.
|
||||
*
|
||||
* @since 0.2.0
|
||||
*/
|
||||
if ( ! function_exists( 'wp_bootstrap_enqueue_editor_assets' ) ) :
|
||||
function wp_bootstrap_enqueue_editor_assets() {
|
||||
$theme_version = wp_get_theme()->get( 'Version' );
|
||||
|
||||
wp_enqueue_script(
|
||||
'wp-bootstrap-editor-js',
|
||||
get_template_directory_uri() . '/assets/js/bootstrap.bundle.min.js',
|
||||
array(),
|
||||
$theme_version,
|
||||
true
|
||||
);
|
||||
}
|
||||
endif;
|
||||
add_action( 'enqueue_block_editor_assets', 'wp_bootstrap_enqueue_editor_assets' );
|
||||
|
||||
/**
|
||||
* Register custom block categories for Bootstrap components.
|
||||
*
|
||||
* @since 0.2.0
|
||||
*
|
||||
* @param array $categories Existing block categories.
|
||||
* @param WP_Block_Editor_Context $context Block editor context.
|
||||
* @return array Modified categories.
|
||||
*/
|
||||
if ( ! function_exists( 'wp_bootstrap_block_categories' ) ) :
|
||||
function wp_bootstrap_block_categories( array $categories, $context ): array {
|
||||
$bootstrap_categories = array(
|
||||
array(
|
||||
'slug' => 'wp-bootstrap-layout',
|
||||
'title' => __( 'Bootstrap Layout', 'wp-bootstrap' ),
|
||||
'icon' => 'layout',
|
||||
),
|
||||
array(
|
||||
'slug' => 'wp-bootstrap-components',
|
||||
'title' => __( 'Bootstrap Components', 'wp-bootstrap' ),
|
||||
'icon' => 'grid-view',
|
||||
),
|
||||
array(
|
||||
'slug' => 'wp-bootstrap-navigation',
|
||||
'title' => __( 'Bootstrap Navigation', 'wp-bootstrap' ),
|
||||
'icon' => 'menu',
|
||||
),
|
||||
);
|
||||
|
||||
return array_merge( $bootstrap_categories, $categories );
|
||||
}
|
||||
endif;
|
||||
add_filter( 'block_categories_all', 'wp_bootstrap_block_categories', 10, 2 );
|
||||
|
||||
/**
|
||||
* Register block pattern categories.
|
||||
*/
|
||||
@@ -159,6 +213,30 @@ if ( ! function_exists( 'wp_bootstrap_pattern_categories' ) ) :
|
||||
'description' => __( 'Text-focused content sections.', 'wp-bootstrap' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_block_pattern_category(
|
||||
'wp-bootstrap-layout',
|
||||
array(
|
||||
'label' => __( 'Layout', 'wp-bootstrap' ),
|
||||
'description' => __( 'Layout building blocks for page structure.', 'wp-bootstrap' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_block_pattern_category(
|
||||
'wp-bootstrap-components',
|
||||
array(
|
||||
'label' => __( 'Components', 'wp-bootstrap' ),
|
||||
'description' => __( 'Reusable Bootstrap component patterns.', 'wp-bootstrap' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_block_pattern_category(
|
||||
'wp-bootstrap-navigation',
|
||||
array(
|
||||
'label' => __( 'Navigation', 'wp-bootstrap' ),
|
||||
'description' => __( 'Navigation and header patterns.', 'wp-bootstrap' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
endif;
|
||||
add_action( 'init', 'wp_bootstrap_pattern_categories' );
|
||||
|
||||
Reference in New Issue
Block a user