Skip to content

Instantly share code, notes, and snippets.

@itsdavidmorgan
Last active January 8, 2018 21:42
Show Gist options
  • Save itsdavidmorgan/63ecdc4f16d1af50a1d74d78fcdf3951 to your computer and use it in GitHub Desktop.
Save itsdavidmorgan/63ecdc4f16d1af50a1d74d78fcdf3951 to your computer and use it in GitHub Desktop.
Enqueue Editor Assets For Custom Block
<?php
function organic_profile_block_editor_assets() {
// Scripts.
wp_enqueue_script(
'organic-profile-block', // Handle.
plugins_url( 'block.js', __FILE__ ), // Block.js: We register the block here.
array( 'wp-blocks', 'wp-i18n', 'wp-element' ), // Dependencies, defined above.
filemtime( plugin_dir_path( __FILE__ ) . 'block.js' ) // filemtime — Gets file modification time.
);
// Styles.
wp_enqueue_style(
'organic-profile-block-editor', // Handle.
plugins_url( 'editor.css', __FILE__ ), // Block editor CSS.
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' ) // filemtime — Gets file modification time.
);
} // End function organic_profile_block_editor_assets().
// Hook: Editor assets.
add_action( 'enqueue_block_editor_assets', 'organic_profile_block_editor_assets' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment