PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.1
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 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
jetformbuilder / modules / wysiwyg / module.php
module.php
119 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Wysiwyg;
5
6 use Jet_Form_Builder\Blocks\Module as BlocksModule;
7 use Jet_Form_Builder\Plugin;
8 use JFB_Components\Module\Base_Module_Dir_It;
9 use JFB_Components\Module\Base_Module_Dir_Trait;
10 use JFB_Components\Module\Base_Module_Handle_It;
11 use JFB_Components\Module\Base_Module_Handle_Trait;
12 use JFB_Components\Module\Base_Module_It;
13 use JFB_Components\Module\Base_Module_Url_It;
14 use JFB_Components\Module\Base_Module_Url_Trait;
15
16 // If this file is called directly, abort.
17 if ( ! defined( 'WPINC' ) ) {
18 die;
19 }
20
21 final class Module implements
22 Base_Module_It,
23 Base_Module_Url_It,
24 Base_Module_Handle_It,
25 Base_Module_Dir_It {
26
27 use Base_Module_Url_Trait;
28 use Base_Module_Dir_Trait;
29 use Base_Module_Handle_Trait;
30
31 public function rep_item_id() {
32 return 'wysiwyg';
33 }
34
35 public function condition(): bool {
36 return true;
37 }
38
39 public function init_hooks() {
40 add_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
41 add_action( 'init', array( $this, 'register_editor_styles' ) );
42 add_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
43 add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
44 add_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
45 }
46
47 public function remove_hooks() {
48 remove_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
49 remove_action( 'init', array( $this, 'register_editor_styles' ) );
50 remove_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
51 remove_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
52 remove_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
53 }
54
55 public function add_blocks_types( array $block_types ): array {
56 $block_types[] = new Blocks\Wysiwyg\Block_Type();
57
58 return $block_types;
59 }
60
61 public function register_editor_styles() {
62
63 $editor_asset = require $this->get_dir( 'assets/build/editor.asset.php' );
64 wp_register_style(
65 $this->get_handle( 'lightgray-skin' ),
66 includes_url( 'js/tinymce/skins/lightgray/skin.min.css' ),
67 array(),
68 $editor_asset['version']
69 );
70 wp_register_style(
71 $this->get_handle(),
72 $this->get_url( 'assets/build/wysiwyg.css' ),
73 array(
74 'editor-buttons',
75 ),
76 $editor_asset['version']
77 );
78 }
79
80 public function enqueue_admin_assets() {
81 $script_asset = require $this->get_dir( 'assets/build/editor.asset.php' );
82
83 wp_enqueue_script(
84 $this->get_handle(),
85 $this->get_url( 'assets/build/editor.js' ),
86 $script_asset['dependencies'],
87 $script_asset['version'],
88 true
89 );
90 }
91
92 public function register_frontend_scripts() {
93 $script_asset = require $this->get_dir( 'assets/build/wysiwyg.asset.php' );
94
95 if ( true === $script_asset ) {
96 return;
97 }
98
99 array_push(
100 $script_asset['dependencies'],
101 BlocksModule::MAIN_SCRIPT_HANDLE
102 );
103
104 wp_register_script(
105 $this->get_handle(),
106 $this->get_url( 'assets/build/wysiwyg.js' ),
107 $script_asset['dependencies'],
108 $script_asset['version'],
109 true
110 );
111 wp_register_style(
112 $this->get_handle(),
113 $this->get_url( 'assets/build/wysiwyg.css' ),
114 array(),
115 $script_asset['version']
116 );
117 }
118 }
119