Last active
March 5, 2018 13:45
Star
You must be signed in to star a gist
This file contains 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 | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
}//end if | |
/** | |
* Enqueue the block's assets for the editor. | |
* | |
* `wp-blocks`: Includes block type registration and related functions. | |
* `wp-element`: Includes the WordPress Element abstraction for describing the structure of your blocks. | |
* `wp-i18n`: To internationalize the block's text. | |
* | |
* @since 1.0.0 | |
*/ | |
function nelio_testimonial_block_editor_assets() { | |
wp_enqueue_script( | |
'nelio-testimonial-block', | |
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. | |
); | |
wp_enqueue_style( | |
'nelio-testimonial-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 nelio_testimonial_block_editor_assets() | |
add_action( 'enqueue_block_editor_assets', 'nelio_testimonial_block_editor_assets' ); | |
/** | |
* Enqueue the block's assets for the frontend. | |
* | |
* @since 1.0.0 | |
*/ | |
function nelio_testimonial_block_front_assets() { | |
wp_enqueue_style( | |
'nelio-testimonial-block-frontend', // Handle. | |
plugins_url( 'style.css', __FILE__ ), // Block frontend CSS. | |
array( 'wp-blocks' ), // Dependency to include the CSS after it. | |
filemtime( plugin_dir_path( __FILE__ ) . 'style.css' ) // filemtime — Gets file modification time. | |
); | |
}//end nelio_testimonial_block_front_assets() | |
add_action( 'enqueue_block_assets', 'nelio_testimonial_block_front_assets' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment