| 1 |
<?php |
| 2 |
|
| 3 |
if ( !defined( 'ABSPATH' ) ) { exit; } |
| 4 |
|
| 5 |
if( !class_exists( 'ChartBlock_Plugin' ) ){ |
| 6 |
class ChartBlock_Plugin { |
| 7 |
function __construct(){ |
| 8 |
add_action( 'init', [$this, 'chart_block_onInit'] ); |
| 9 |
add_action( 'enqueue_block_assets', [$this, 'chart_block_enqueueBlockAssets'] ); |
| 10 |
add_action( 'enqueue_block_editor_assets', [$this, 'chart_block_enqueueBlockEditorAssets'] ); |
| 11 |
} |
| 12 |
|
| 13 |
function chart_block_enqueueBlockAssets(){ |
| 14 |
wp_register_script( 'chartJS', CHART_BLOCK_DIR_URL . 'assets/js/chart.min.js', [], '3.5.1', true ); |
| 15 |
} |
| 16 |
function chart_block_enqueueBlockEditorAssets(){ |
| 17 |
wp_add_inline_script( 'wp-data', sprintf( |
| 18 |
'const chart_block_pricing_url = %s;', |
| 19 |
wp_json_encode( admin_url( 'edit.php?post_type=chart_block&page=block-dashboard#/pricing' ) ) |
| 20 |
), 'before' ); |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
function chart_block_onInit() { |
| 25 |
register_block_type( __DIR__ . '/build' ); |
| 26 |
} |
| 27 |
} |
| 28 |
new ChartBlock_Plugin(); |
| 29 |
} |