| 1 |
<?php |
| 2 |
/** |
| 3 |
* Register All Blocks |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace GutSliders\RegisterBlocks; |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
class RegisterBlocks { |
| 14 |
|
| 15 |
/** |
| 16 |
* Constructor |
| 17 |
*/ |
| 18 |
public function __construct() { |
| 19 |
add_action( 'init', [ $this, 'register_blocks' ] ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Register Blocks |
| 24 |
*/ |
| 25 |
public function register_blocks() { |
| 26 |
$blocksList = [ |
| 27 |
[ |
| 28 |
'name' => 'content-slider', |
| 29 |
] |
| 30 |
]; |
| 31 |
|
| 32 |
// register blocks |
| 33 |
if( ! empty( $blocksList ) ) { |
| 34 |
foreach( $blocksList as $block ) { |
| 35 |
register_block_type( |
| 36 |
GUTSLIDERS_PATH . '/build/blocks/' . $block['name'], |
| 37 |
isset( $block['render_callback'] ) ? |
| 38 |
[ |
| 39 |
'render_callback' => $block['render_callback'] |
| 40 |
] : [] |
| 41 |
); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
} |