Skip to content

Commit

Permalink
fix only enqueue editor assets in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiankaegy committed Aug 24, 2023
1 parent 5016b67 commit bb68e0d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions example/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
*/
function register_block() {

if ( file_exists( EXAMPLE_PLUGIN_BLOCK_DIST_DIR ) ) {
$block_json_files = glob( EXAMPLE_PLUGIN_BLOCK_DIST_DIR . '*/block.json' );
foreach ( $block_json_files as $filename ) {
$block_folder = dirname( $filename );
register_block_type( $block_folder );
};
};
};

add_action( 'enqueue_block_assets', __NAMESPACE__ . '\enqueue_block_editor_scripts' );
function enqueue_block_editor_scripts() {
$asset_file = include EXAMPLE_PLUGIN_DIST_PATH . 'index.asset.php';

wp_enqueue_script(
Expand All @@ -38,15 +49,7 @@ function register_block() {
$asset_file['version'],
true
);

if ( file_exists( EXAMPLE_PLUGIN_BLOCK_DIST_DIR ) ) {
$block_json_files = glob( EXAMPLE_PLUGIN_BLOCK_DIST_DIR . '*/block.json' );
foreach ( $block_json_files as $filename ) {
$block_folder = dirname( $filename );
register_block_type( $block_folder );
};
};
};
}

function register_book_custom_post_type() {
$labels = array(
Expand Down

0 comments on commit bb68e0d

Please sign in to comment.