class-ecs-json-poweredit-module.php
54 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Module: JSON PowerEdit |
| 4 | * |
| 5 | * Adds an "Edit JSON" button to Elementor repeater controls in the editor panel. |
| 6 | * Allows viewing, editing and replacing the repeater's data as raw JSON. |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | class ECS_JSON_PowerEdit_Module extends ECS_Module_Base { |
| 14 | |
| 15 | // ── Identity ────────────────────────────────────────────────────────────── |
| 16 | |
| 17 | public function get_id(): string { |
| 18 | return 'json_poweredit'; |
| 19 | } |
| 20 | |
| 21 | public function get_title(): string { |
| 22 | return __( 'JSON PowerEdit', 'ele-custom-skin' ); |
| 23 | } |
| 24 | |
| 25 | public function get_description(): string { |
| 26 | return __( 'Adds an "Edit JSON" button to every Elementor repeater control. View, edit and bulk-replace repeater data as raw JSON directly in the editor.', 'ele-custom-skin' ); |
| 27 | } |
| 28 | |
| 29 | // ── Boot ────────────────────────────────────────────────────────────────── |
| 30 | |
| 31 | public function boot(): void { |
| 32 | // Nothing to hook server-side; all functionality is JS-only (editor). |
| 33 | } |
| 34 | |
| 35 | // ── Assets ──────────────────────────────────────────────────────────────── |
| 36 | |
| 37 | public function enqueue_editor_assets(): void { |
| 38 | wp_enqueue_style( |
| 39 | 'ecs-json-poweredit-editor', |
| 40 | ECS_URL . 'modules/json-poweredit/assets/css/ecs-json-poweredit-editor.css', |
| 41 | [], |
| 42 | ECS_VERSION |
| 43 | ); |
| 44 | |
| 45 | wp_enqueue_script( |
| 46 | 'ecs-json-poweredit-editor', |
| 47 | ECS_URL . 'modules/json-poweredit/assets/js/ecs-json-poweredit-editor.js', |
| 48 | [ 'jquery', 'elementor-editor' ], |
| 49 | ECS_VERSION, |
| 50 | true |
| 51 | ); |
| 52 | } |
| 53 | } |
| 54 |