| 1 |
<?php |
| 2 |
|
| 3 |
if ( !class_exists( 'OCBOffCanvas' ) ) { |
| 4 |
class OCBOffCanvas |
| 5 |
{ |
| 6 |
public function __construct() { |
| 7 |
add_action( 'init', [ $this, 'onInit' ] ); |
| 8 |
add_action( 'enqueue_block_editor_assets', [ $this, 'obEnqueueEditorAssets' ] ); |
| 9 |
add_action( 'wp_enqueue_scripts', [ $this, 'obEnqueueViewAssets' ] ); |
| 10 |
} |
| 11 |
|
| 12 |
public function onInit() |
| 13 |
{ |
| 14 |
register_block_type( __DIR__ . '/build' ); |
| 15 |
|
| 16 |
} |
| 17 |
|
| 18 |
public function obEnqueueEditorAssets() { |
| 19 |
wp_add_inline_script( |
| 20 |
'ocb-offcanvas-editor-script', |
| 21 |
'const obIsPipeChecker = ' . wp_json_encode( obIsPremium() ) . ';', |
| 22 |
'before' |
| 23 |
); |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
public function obEnqueueViewAssets() { |
| 28 |
wp_add_inline_script( |
| 29 |
'ocb-offcanvas-view-script', |
| 30 |
'const obIsPipeChecker = ' . wp_json_encode( obIsPremium() ) . ';', |
| 31 |
'before' |
| 32 |
); |
| 33 |
|
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
new OCBOffCanvas(); |
| 38 |
} |