PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.1
JetFormBuilder — Dynamic Blocks Form Builder v3.1.1
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 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 / advanced-choices / module.php
jetformbuilder / modules / advanced-choices Last commit date
.config 3 years ago assets-build 3 years ago assets-src 3 years ago block-parsers 3 years ago block-renders 3 years ago block-sanitizers 3 years ago block-types 3 years ago blocks-metadata 3 years ago .babelrc 3 years ago .gitattributes 3 years ago module.php 3 years ago package.json 3 years ago
module.php
154 lines
1 <?php
2
3
4 namespace JFB_Modules\Advanced_Choices;
5
6 use Jet_Form_Builder\Blocks\Module as BlocksModule;
7 use JFB_Modules\Advanced_Choices\Block_Parsers\Choices_Field_Parser;
8 use JFB_Modules\Advanced_Choices\Block_Sanitizers\Choices_Default_Value_Sanitizer;
9 use JFB_Components\Module\Base_Module_After_Install_It;
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_Dir_It;
14 use JFB_Components\Module\Base_Module_Dir_Trait;
15 use JFB_Modules\Advanced_Choices\Block_Types;
16 use JFB_Components\Module\Base_Module_Url_It;
17 use JFB_Components\Module\Base_Module_Url_Trait;
18 use Jet_Form_Builder\Plugin;
19 use JFB_Modules\Block_Sanitizer;
20 use JFB_Modules\Block_Parsers;
21
22 // If this file is called directly, abort.
23 if ( ! defined( 'WPINC' ) ) {
24 die;
25 }
26
27 /**
28 * @since 3.1.0
29 *
30 * Class Module
31 * @package JFB_Modules\Advanced_Choices
32 */
33 class Module implements
34 Base_Module_It,
35 Base_Module_Dir_It,
36 Base_Module_Handle_It,
37 Base_Module_Url_It,
38 Base_Module_After_Install_It {
39
40 use Base_Module_Dir_Trait;
41 use Base_Module_Handle_Trait;
42 use Base_Module_Url_Trait;
43
44 public function rep_item_id() {
45 return 'advanced-choices';
46 }
47
48 public function condition(): bool {
49 return true;
50 }
51
52 /**
53 * @noinspection PhpUnhandledExceptionInspection
54 */
55 public function on_install() {
56 /** @var Block_Sanitizer\Module $sanitizer */
57 $sanitizer = jet_form_builder()->module( 'block-sanitizer' );
58 /** @var Block_Parsers\Module $parsers */
59 $parsers = jet_form_builder()->module( 'block-parsers' );
60
61 $sanitizer->register( new Choices_Default_Value_Sanitizer() );
62 $parsers->install( new Choices_Field_Parser() );
63 }
64
65 /**
66 * @noinspection PhpUnhandledExceptionInspection
67 */
68 public function on_uninstall() {
69 /** @var Block_Sanitizer\Module $sanitizer */
70 $sanitizer = jet_form_builder()->module( 'block-sanitizer' );
71 /** @var Block_Parsers\Module $parsers */
72 $parsers = jet_form_builder()->module( 'block-parsers' );
73
74 $sanitizer->unregister( new Choices_Default_Value_Sanitizer() );
75 $parsers->uninstall( new Choices_Field_Parser() );
76 }
77
78 public function init_hooks() {
79 add_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
80 add_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
81
82 if ( ! jet_form_builder()->has_module( 'jet-style' ) ) {
83 return;
84 }
85
86 add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
87 add_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
88 }
89
90 public function remove_hooks() {
91 remove_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
92 remove_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
93
94 if ( ! jet_form_builder()->has_module( 'jet-style' ) ) {
95 return;
96 }
97
98 remove_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
99 remove_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
100 }
101
102 public function add_blocks_types( array $block_types ): array {
103 $types = jet_form_builder()->has_module( 'jet-style' )
104 ? array(
105 new Block_Types\Choices_Field(),
106 new Block_Types\Choice(),
107 new Block_Types\Choice_Control(),
108 ) : array(
109 new Block_Types\Choices_Field_Not_Supported(),
110 );
111
112 return array_merge( $block_types, $types );
113 }
114
115 public function register_frontend_scripts() {
116 wp_register_script(
117 $this->get_handle(),
118 $this->get_url( 'assets-build/js/frontend/choices.field{min}.js' ),
119 array(
120 BlocksModule::MAIN_SCRIPT_HANDLE,
121 ),
122 Plugin::instance()->get_version(),
123 true
124 );
125 wp_register_style(
126 $this->get_handle(),
127 $this->get_url( 'assets-build/css/main.css' ),
128 array(),
129 jet_form_builder()->get_version()
130 );
131 }
132
133 public function enqueue_admin_assets() {
134 $path = jet_form_builder()->has_module( 'jet-style' )
135 ? 'assets-build/js/editor/main{min}.js'
136 : 'assets-build/js/editor-not-supported/main{min}.js';
137
138 wp_enqueue_script(
139 $this->get_handle(),
140 $this->get_url( $path ),
141 array(),
142 jet_form_builder()->get_version(),
143 true
144 );
145
146 wp_enqueue_style(
147 $this->get_handle(),
148 $this->get_url( 'assets-build/css/main.css' ),
149 array(),
150 jet_form_builder()->get_version()
151 );
152 }
153 }
154