| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor editor assets for TableKit |
| 4 |
* |
| 5 |
* @package TableKit |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Enqueues TableKit's editor-only styles/scripts within the Elementor editor. |
| 14 |
*/ |
| 15 |
class TableKit_Elementor_Editor { |
| 16 |
|
| 17 |
/** |
| 18 |
* Hooks editor asset enqueueing into the Elementor editor lifecycle. |
| 19 |
* |
| 20 |
* @return void |
| 21 |
*/ |
| 22 |
public static function register(): void { |
| 23 |
add_action( 'elementor/editor/after_enqueue_styles', array( __CLASS__, 'enqueue_editor_styles' ) ); |
| 24 |
add_action( 'elementor/editor/after_enqueue_scripts', array( __CLASS__, 'enqueue_editor_scripts' ) ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Enqueues TableKit's stylesheet for the Elementor editor screen. |
| 29 |
* |
| 30 |
* @return void |
| 31 |
*/ |
| 32 |
public static function enqueue_editor_styles(): void { |
| 33 |
wp_enqueue_style( |
| 34 |
'tablekit-elementor-editor', |
| 35 |
TABLE_BUILDER_BLOCK_PLUGIN_URL . 'assets/css/elementor-editor.css', |
| 36 |
array(), |
| 37 |
TABLE_BUILDER_BLOCK_PLUGIN_VERSION |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Enqueues the Elementor-editor block-picker script and localizes its data. |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
public static function enqueue_editor_scripts(): void { |
| 47 |
wp_enqueue_script( |
| 48 |
'tablekit-editor-block-picker', |
| 49 |
TABLE_BUILDER_BLOCK_PLUGIN_URL . 'assets/js/elementor-editor-block-picker.js', |
| 50 |
array( 'elementor-editor', 'jquery' ), |
| 51 |
TABLE_BUILDER_BLOCK_PLUGIN_VERSION, |
| 52 |
true |
| 53 |
); |
| 54 |
|
| 55 |
wp_localize_script( |
| 56 |
'tablekit-editor-block-picker', |
| 57 |
'tablekitEditorData', |
| 58 |
array( |
| 59 |
'restUrl' => rest_url( 'tablekit/v1/table-blocks' ), |
| 60 |
'nonce' => wp_create_nonce( 'wp_rest' ), |
| 61 |
'allLabel' => __( '— All Blocks —', 'table-builder-block' ), |
| 62 |
'loading' => __( 'Loading blocks…', 'table-builder-block' ), |
| 63 |
) |
| 64 |
); |
| 65 |
} |
| 66 |
} |
| 67 |
|