Skip to content

Instantly share code, notes, and snippets.

@BenBroide
Last active January 25, 2021 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenBroide/a2bc5029a344ab0cd45a64426decb573 to your computer and use it in GitHub Desktop.
Save BenBroide/a2bc5029a344ab0cd45a64426decb573 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Gutenberg Easy Clone/Remove block buttons
*/
function create_block_custom_remove_duplicate_buttons_block_init() {
$dir = __DIR__;
$script_asset_path = "$dir/build/index.asset.php";
if ( ! file_exists( $script_asset_path ) ) {
throw new Error(
'You need to run `npm start` or `npm run build` for the "create-block/custom-remove-duplicate-buttons" block first.'
);
}
$index_js = 'build/index.js';
$script_asset = require( $script_asset_path );
wp_register_script(
'block-custom-remove-duplicate-buttons-block-editor',
plugins_url( $index_js, __FILE__ ),
$script_asset['dependencies'],
$script_asset['version']
);
wp_enqueue_script('block-custom-remove-duplicate-buttons-block-editor');
}
add_action( 'enqueue_block_editor_assets', 'create_block_custom_remove_duplicate_buttons_block_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment