| 1 |
<?php |
| 2 |
|
| 3 |
namespace GutSliders; |
| 4 |
use GutSliders\Admin\Admin; |
| 5 |
use GutSliders\RegisterBlocks\RegisterBlocks; |
| 6 |
use GutSliders\EnqueueAssets\EnqueueAssets; |
| 7 |
use GutSliders\FontsLoader\FontsLoader; |
| 8 |
|
| 9 |
// Exit if accessed directly. |
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
class Loader { |
| 15 |
|
| 16 |
// Constructor |
| 17 |
public function __construct() { |
| 18 |
// register blocks category |
| 19 |
if( version_compare( $GLOBALS['wp_version'], '5.7', '<' ) ) { |
| 20 |
add_filter( 'block_categories', [ $this, 'register_block_category' ], 10, 2, 9999 ); |
| 21 |
} else { |
| 22 |
add_filter( 'block_categories_all', [ $this, 'register_block_category' ], 10, 2, 9999 ); |
| 23 |
} |
| 24 |
|
| 25 |
// init |
| 26 |
$this->init(); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Register Block Category |
| 31 |
*/ |
| 32 |
public function register_block_category( $categories, $post ) { |
| 33 |
return array_merge( |
| 34 |
array( |
| 35 |
array( |
| 36 |
'slug' => 'gutsliders', |
| 37 |
'title' => __( 'GutSlider Blocks', 'slider-blocks' ), |
| 38 |
), |
| 39 |
), |
| 40 |
$categories, |
| 41 |
); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Init |
| 46 |
*/ |
| 47 |
public function init() { |
| 48 |
// admin |
| 49 |
new Admin(); |
| 50 |
// register blocks |
| 51 |
new RegisterBlocks(); |
| 52 |
// enqueue assets |
| 53 |
new EnqueueAssets(); |
| 54 |
// fonts loader |
| 55 |
new FontsLoader(); |
| 56 |
} |
| 57 |
} |