| @@ -2,10 +2,8 @@ | ||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | namespace JFB_Modules\Html_Parser; |
| 5 | 5 | |
| 6 | -use JFB_Components\Module\Base_Module_Dir_It; | |
| 7 | -use JFB_Components\Module\Base_Module_Dir_Trait; | |
| 8 | 6 | use JFB_Components\Module\Base_Module_Handle_It; |
| 9 | 7 | use JFB_Components\Module\Base_Module_Handle_Trait; |
| 10 | 8 | use JFB_Components\Module\Base_Module_It; |
| 11 | 9 | use JFB_Components\Module\Base_Module_Url_It; |
| @@ -15,17 +13,12 @@ | ||
| 15 | 13 | if ( ! defined( 'WPINC' ) ) { |
| 16 | 14 | die; |
| 17 | 15 | } |
| 18 | 16 | |
| 19 | -class Module implements | |
| 20 | - Base_Module_It, | |
| 21 | - Base_Module_Handle_It, | |
| 22 | - Base_Module_Url_It, | |
| 23 | - Base_Module_Dir_It { | |
| 17 | +class Module implements Base_Module_It, Base_Module_Handle_It, Base_Module_Url_It { | |
| 24 | 18 | |
| 25 | 19 | use Base_Module_Url_Trait; |
| 26 | 20 | use Base_Module_Handle_Trait; |
| 27 | - use Base_Module_Dir_Trait; | |
| 28 | 21 | |
| 29 | 22 | public function rep_item_id() { |
| 30 | 23 | return 'html-parser'; |
| 31 | 24 | } |
| @@ -40,30 +33,20 @@ | ||
| 40 | 33 | public function remove_hooks() { |
| 41 | 34 | } |
| 42 | 35 | |
| 43 | 36 | public function register_scripts() { |
| 44 | - $script_asset = require_once $this->get_dir( 'assets/build/parser.asset.php' ); | |
| 45 | - | |
| 46 | - // script have already registered | |
| 47 | - if ( true === $script_asset ) { | |
| 48 | - return; | |
| 49 | - } | |
| 50 | - | |
| 51 | 37 | /** @var \JFB_Modules\Jet_Plugins\Module $jet_plugins */ |
| 52 | 38 | /** @noinspection PhpUnhandledExceptionInspection */ |
| 53 | 39 | $jet_plugins = jet_form_builder()->module( 'jet-plugins' ); |
| 54 | 40 | $jet_plugins->register_scripts(); |
| 55 | 41 | |
| 56 | - array_push( | |
| 57 | - $script_asset['dependencies'], | |
| 58 | - $jet_plugins::HANDLE | |
| 59 | - ); | |
| 60 | - | |
| 61 | 42 | wp_register_script( |
| 62 | 43 | $this->get_handle(), |
| 63 | - $this->get_url( 'assets/build/parser.js' ), | |
| 64 | - $script_asset['dependencies'], | |
| 65 | - $script_asset['version'], | |
| 44 | + $this->get_url( 'assets/build/js/parser.js' ), | |
| 45 | + array( | |
| 46 | + $jet_plugins::HANDLE, | |
| 47 | + ), | |
| 48 | + jet_form_builder()->get_version(), | |
| 66 | 49 | true |
| 67 | 50 | ); |
| 68 | 51 | |
| 69 | 52 | wp_localize_script( |
| @@ -72,26 +55,6 @@ | ||
| 72 | 55 | array( |
| 73 | 56 | 'mimes' => get_allowed_mime_types(), |
| 74 | 57 | ) |
| 75 | 58 | ); |
| 76 | - | |
| 77 | - $ui_asset = require $this->get_dir( 'assets/build/admin-ui.asset.php' ); | |
| 78 | - wp_register_script( | |
| 79 | - 'jfb-html-parser-admin-ui', | |
| 80 | - $this->get_url( 'assets/build/admin-ui.js' ), | |
| 81 | - $ui_asset['dependencies'], | |
| 82 | - $ui_asset['version'], | |
| 83 | - true | |
| 84 | - ); | |
| 85 | - | |
| 86 | - if ( | |
| 87 | - is_admin() | |
| 88 | - && isset( $_GET['post_type'] ) | |
| 89 | - && 'jet-form-builder' === $_GET['post_type'] | |
| 90 | - && isset( $_SERVER['REQUEST_URI'] ) | |
| 91 | - && false !== strpos( $_SERVER['REQUEST_URI'], 'edit.php' ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 92 | - ) { | |
| 93 | - wp_enqueue_script( $this->get_handle() ); | |
| 94 | - wp_enqueue_script( 'jfb-html-parser-admin-ui' ); | |
| 95 | - } | |
| 96 | 59 | } |
| 97 | 60 | } |