PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 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 All 134 releases
← All changes | modules/macros-inserter/module.php +23 -14 3.6.0.1 → 3.6.6 View file →
@@ -20,8 +20,9 @@
20 20 Base_Module_Handle_It,
21 21 Base_Module_Dir_It {
22 22
23 23
24 +
24 25 use Base_Module_Handle_Trait;
25 26 use Base_Module_Url_Trait;
26 27 use Base_Module_Dir_Trait;
27 28
@@ -33,22 +34,24 @@
33 34 return true;
34 35 }
35 36
36 37 public function init_hooks() {
38 + add_action( 'init', array( $this, 'register_editor_assets' ), 0 );
37 39 add_action( 'init', array( $this, 'register_block_type' ) );
38 40
39 41 add_action(
40 42 'jet-form-builder/editor-assets/before',
41 - array( $this, 'register_editor_assets' )
43 + array( $this, 'enqueue_code_editor_assets' )
42 44 );
43 45 }
44 46
45 47 public function remove_hooks() {
48 + remove_action( 'init', array( $this, 'register_editor_assets' ), 0 );
46 49 remove_action( 'init', array( $this, 'register_block_type' ) );
47 50
48 51 remove_action(
49 52 'jet-form-builder/editor-assets/before',
50 - array( $this, 'register_editor_assets' )
53 + array( $this, 'enqueue_code_editor_assets' )
51 54 );
52 55 }
53 56
54 57 public function register_block_type() {
@@ -61,18 +64,8 @@
61 64 );
62 65 }
63 66
64 67 public function register_editor_assets() {
65 - // CodeMirror for wp.codeEditor.initialize(...)
66 - wp_enqueue_code_editor(
67 - array(
68 - 'type' => 'text/html',
69 - )
70 - );
71 -
72 - // Styles for CodeMirror in WP
73 - wp_enqueue_style( 'wp-codemirror' );
74 -
75 68 $asset_path = $this->get_dir( 'assets/build/editor.asset.php' );
76 69
77 70 $asset = file_exists( $asset_path )
78 71 ? require $asset_path
@@ -77,9 +70,9 @@
77 70 $asset = file_exists( $asset_path )
78 71 ? require $asset_path
79 72 : array(
80 73 'dependencies' => array(),
81 - 'version' => jet_form_builder()->get_version(),
74 + 'version' => jet_form_builder()->get_version(),
82 75 );
83 76
84 77 $deps = array_unique(
85 78 array_merge(
@@ -87,13 +80,29 @@
87 80 array( 'code-editor' )
88 81 )
89 82 );
90 83
91 - wp_enqueue_script(
84 + wp_register_script(
92 85 $this->get_handle( 'editor' ),
93 86 $this->get_url( 'assets/build/editor.js' ),
94 87 $deps,
95 88 $asset['version'] ?? jet_form_builder()->get_version(),
96 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 + )
97 106 );
98 107 }
99 108 }