Last active
April 24, 2024 08:22
-
-
Save itsdavidmorgan/a24863526e046bb7ae46cafe2c411eea to your computer and use it in GitHub Desktop.
Register Scripts and Styles Gutenberg Block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function organic_profile_block() { | |
// Scripts. | |
wp_register_script( | |
'organic-profile-block-script', // Handle. | |
plugins_url( 'block.js', __FILE__ ), // Block.js: We register the block here. | |
array( 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-editor' ), // Dependencies, defined above. | |
filemtime( plugin_dir_path( __FILE__ ) . 'block.js' ), | |
true // Load script in footer. | |
); | |
// Styles. | |
wp_register_style( | |
'organic-profile-block-editor-style', // 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' ) | |
); | |
wp_register_style( | |
'organic-profile-block-frontend-style', // Handle. | |
plugins_url( 'style.css', __FILE__ ), // Block editor CSS. | |
array(), // Dependency to include the CSS after it. | |
filemtime( plugin_dir_path( __FILE__ ) . 'style.css' ) | |
); | |
} // End function organic_profile_block(). | |
add_action( 'init', 'organic_profile_block' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment