PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.0.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.0.1
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
jetformbuilder / modules / wysiwyg / module.php

module.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.0.1, at modules/wysiwyg/module.php

114 lines 3.0 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( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
42 add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
43 add_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
44 }
45
46 public function remove_hooks() {
47 remove_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
48 remove_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
49 remove_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
50 remove_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
51 }
52
53 public function add_blocks_types( array $block_types ): array {
54 $block_types[] = new Blocks\Wysiwyg\Block_Type();
55
56 return $block_types;
57 }
58
59 public function enqueue_admin_assets() {
60 $script_asset = require_once $this->get_dir( 'assets/build/editor.asset.php' );
61
62 wp_enqueue_script(
63 $this->get_handle(),
64 $this->get_url( 'assets/build/editor.js' ),
65 $script_asset['dependencies'],
66 $script_asset['version'],
67 true
68 );
69
70 wp_enqueue_style(
71 $this->get_handle( 'lightgray-skin' ),
72 includes_url( 'js/tinymce/skins/lightgray/skin.min.css' ),
73 array(),
74 $script_asset['version']
75 );
76
77 wp_enqueue_style(
78 $this->get_handle(),
79 $this->get_url( 'assets/build/wysiwyg.css' ),
80 array(
81 'editor-buttons',
82 ),
83 $script_asset['version']
84 );
85 }
86
87 public function register_frontend_scripts() {
88 $script_asset = require_once $this->get_dir( 'assets/build/wysiwyg.asset.php' );
89
90 if ( true === $script_asset ) {
91 return;
92 }
93
94 array_push(
95 $script_asset['dependencies'],
96 BlocksModule::MAIN_SCRIPT_HANDLE
97 );
98
99 wp_register_script(
100 $this->get_handle(),
101 $this->get_url( 'assets/build/wysiwyg.js' ),
102 $script_asset['dependencies'],
103 $script_asset['version'],
104 true
105 );
106 wp_register_style(
107 $this->get_handle(),
108 $this->get_url( 'assets/build/wysiwyg.css' ),
109 array(),
110 $script_asset['version']
111 );
112 }
113 }
114