Skip to content

Instantly share code, notes, and snippets.

@itsdavidmorgan
Last active April 24, 2024 08:22
Show Gist options
  • Save itsdavidmorgan/a24863526e046bb7ae46cafe2c411eea to your computer and use it in GitHub Desktop.
Save itsdavidmorgan/a24863526e046bb7ae46cafe2c411eea to your computer and use it in GitHub Desktop.
Register Scripts and Styles Gutenberg Block
<?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