PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.4.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.4.1
3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / macros-inserter / module.php
jetformbuilder / modules / macros-inserter Last commit date
assets 4 weeks ago module.php 1 month ago webpack.config.js 3 months ago
module.php
109 lines
1 <?php
2
3 namespace JFB_Modules\Macros_Inserter;
4
5 use JFB_Components\Module\Base_Module_Dir_It;
6 use JFB_Components\Module\Base_Module_Dir_Trait;
7 use JFB_Components\Module\Base_Module_Handle_It;
8 use JFB_Components\Module\Base_Module_Handle_Trait;
9 use JFB_Components\Module\Base_Module_It;
10 use JFB_Components\Module\Base_Module_Url_It;
11 use JFB_Components\Module\Base_Module_Url_Trait;
12
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 class Module implements
18 Base_Module_It,
19 Base_Module_Url_It,
20 Base_Module_Handle_It,
21 Base_Module_Dir_It {
22
23
24
25 use Base_Module_Handle_Trait;
26 use Base_Module_Url_Trait;
27 use Base_Module_Dir_Trait;
28
29 public function rep_item_id() {
30 return 'macros-inserter';
31 }
32
33 public function condition(): bool {
34 return true;
35 }
36
37 public function init_hooks() {
38 add_action( 'init', array( $this, 'register_editor_assets' ), 0 );
39 add_action( 'init', array( $this, 'register_block_type' ) );
40
41 add_action(
42 'jet-form-builder/editor-assets/before',
43 array( $this, 'enqueue_code_editor_assets' )
44 );
45 }
46
47 public function remove_hooks() {
48 remove_action( 'init', array( $this, 'register_editor_assets' ), 0 );
49 remove_action( 'init', array( $this, 'register_block_type' ) );
50
51 remove_action(
52 'jet-form-builder/editor-assets/before',
53 array( $this, 'enqueue_code_editor_assets' )
54 );
55 }
56
57 public function register_block_type() {
58 if ( ! function_exists( 'register_block_type_from_metadata' ) ) {
59 return;
60 }
61
62 register_block_type_from_metadata(
63 $this->get_dir( 'assets/src/editor/blocks/macros-inserter' )
64 );
65 }
66
67 public function register_editor_assets() {
68 $asset_path = $this->get_dir( 'assets/build/editor.asset.php' );
69
70 $asset = file_exists( $asset_path )
71 ? require $asset_path
72 : array(
73 'dependencies' => array(),
74 'version' => jet_form_builder()->get_version(),
75 );
76
77 $deps = array_unique(
78 array_merge(
79 $asset['dependencies'] ?? array(),
80 array( 'code-editor' )
81 )
82 );
83
84 wp_register_script(
85 $this->get_handle( 'editor' ),
86 $this->get_url( 'assets/build/editor.js' ),
87 $deps,
88 $asset['version'] ?? jet_form_builder()->get_version(),
89 true
90 );
91
92 wp_register_style(
93 $this->get_handle( 'editor' ),
94 $this->get_url( 'assets/build/editor.css' ),
95 array( 'wp-codemirror' ),
96 $asset['version'] ?? jet_form_builder()->get_version()
97 );
98 }
99
100 public function enqueue_code_editor_assets() {
101 // Required for wp.codeEditor.initialize(...).
102 wp_enqueue_code_editor(
103 array(
104 'type' => 'text/html',
105 )
106 );
107 }
108 }
109