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