| 1 |
<?php |
| 2 |
/** |
| 3 |
* Blocks Initializer |
| 4 |
* |
| 5 |
* Enqueue CSS/JS of all the blocks. |
| 6 |
* |
| 7 |
* @package carousel-block |
| 8 |
*/ |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Enqueue block editor JavaScript and CSS. |
| 17 |
*/ |
| 18 |
function animated_block_editor_assets() { |
| 19 |
// Block script. |
| 20 |
wp_enqueue_script( |
| 21 |
'ab-animated-block', |
| 22 |
plugins_url( '/dist/blocks.build.js', __FILE__ ), |
| 23 |
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' ], |
| 24 |
filemtime( AB_PLUGIN_DIR . '/dist/blocks.build.js' ), |
| 25 |
true |
| 26 |
); |
| 27 |
|
| 28 |
// Register block editor styles for backend. |
| 29 |
wp_enqueue_style( |
| 30 |
'ab-animated-block-editor', |
| 31 |
plugins_url( '/dist/blocks.editor.build.css', __FILE__ ), |
| 32 |
[ 'wp-edit-blocks' ], |
| 33 |
filemtime( AB_PLUGIN_DIR . '/dist/blocks.editor.build.css' ) |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
add_action( 'enqueue_block_editor_assets', 'animated_block_editor_assets' ); |
| 38 |
|
| 39 |
/** |
| 40 |
* Enqueue block styles for frontend and editor. |
| 41 |
*/ |
| 42 |
function animated_block_assets() { |
| 43 |
wp_enqueue_style( |
| 44 |
'ab-animate', |
| 45 |
plugins_url( '/dist/assets/css/animate.min.css', __FILE__ ), |
| 46 |
[], |
| 47 |
filemtime( AB_PLUGIN_DIR . '/dist/assets/css/animate.min.css' ), |
| 48 |
false |
| 49 |
); |
| 50 |
|
| 51 |
if ( ! is_admin() ) { |
| 52 |
wp_enqueue_style( |
| 53 |
'ab-animated-block', |
| 54 |
plugins_url( '/dist/blocks.style.build.css', __FILE__ ), |
| 55 |
[], |
| 56 |
filemtime( AB_PLUGIN_DIR . '/dist/blocks.style.build.css' ) |
| 57 |
); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
add_action( 'enqueue_block_assets', 'animated_block_assets' ); |
| 62 |
|