| 1 |
<?php |
| 2 |
/** |
| 3 |
* Gutenify block loader file. |
| 4 |
* |
| 5 |
* @package Gutenify |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
class Gutenify_Blocks_Loader{ |
| 14 |
public static function init() { |
| 15 |
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_assets' ) ); |
| 16 |
add_filter( 'block_categories', array( __CLASS__, 'add_block_categories' ) ); |
| 17 |
|
| 18 |
include_once 'blocks/count-down/frontend/style.php'; |
| 19 |
include 'blocks/count-down/block.php'; |
| 20 |
include 'blocks/google-maps/block.php'; |
| 21 |
} |
| 22 |
|
| 23 |
public static function add_block_categories( $categories ) { |
| 24 |
$category_slugs = wp_list_pluck( $categories, 'slug' ); |
| 25 |
return in_array( 'gutenify', $category_slugs, true ) ? $categories : array_merge( |
| 26 |
$categories, |
| 27 |
array( |
| 28 |
array( |
| 29 |
'slug' => 'gutenify', |
| 30 |
'title' => __( 'Gutenify', 'gutenify' ), |
| 31 |
'icon' => null, |
| 32 |
), |
| 33 |
) |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
public static function add_assets() { |
| 38 |
if( ! Gutenify_Helpers::is_gutenberg_page() ) { |
| 39 |
return false; |
| 40 |
} |
| 41 |
wp_register_style( |
| 42 |
'gutenify-main-style', |
| 43 |
plugins_url( 'assets/gutenify_main_css.css', GUTENIFY_PLUGIN_FILE ), |
| 44 |
array(), |
| 45 |
time() |
| 46 |
); |
| 47 |
} |
| 48 |
} |