is_registered( $metadata['name'] ) ) { $registry->unregister( $metadata['name'] ); } $register_options = apply_filters( 'stackable.v2.register-blocks.options', // This automatically enqueues all our styles and scripts. array( 'style' => 'ugb-style-css-v2', // Frontend styles. 'script' => 'ugb-block-frontend-js-v2', // Frontend scripts. 'editor_script' => 'ugb-block-js-v2', // Editor scripts. 'editor_style' => 'ugb-block-editor-css-v2', // Editor styles. ), $metadata['name'], $metadata ); register_block_type_from_metadata( $block_json_file, $register_options ); } } /** * Checks whether we're editing a post in Gutenberg, then loads the v2 * scripts only when there are v2 blocks present in the content. * * @return void */ function stackable_load_editor_blocks_v2() { $current_screen = get_current_screen(); if ( $current_screen->base === 'post' && $current_screen->is_block_editor() ) { $content = get_the_content(); if ( stripos( $content, '