PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.2
JetFormBuilder — Dynamic Blocks Form Builder v3.5.2
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 / switcher / module.php
jetformbuilder / modules / switcher Last commit date
assets 1 year ago blocks 1 year ago module.php 1 year ago
module.php
124 lines
1 <?php
2
3
4 namespace JFB_Modules\Switcher;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 use Jet_Form_Builder\Blocks\Module as BlocksModule;
12 use JFB_Components\Module\Base_Module_After_Install_It;
13 use JFB_Components\Module\Base_Module_Dir_Trait;
14 use JFB_Components\Module\Base_Module_Handle_It;
15 use JFB_Components\Module\Base_Module_Handle_Trait;
16 use JFB_Components\Module\Base_Module_It;
17 use JFB_Components\Module\Base_Module_Url_It;
18 use JFB_Components\Module\Base_Module_Url_Trait;
19
20 class Module implements
21 Base_Module_After_Install_It,
22 Base_Module_It,
23 Base_Module_Url_It,
24 Base_Module_Handle_It {
25
26 use Base_Module_Handle_Trait;
27 use Base_Module_Dir_Trait;
28 use Base_Module_Url_Trait;
29
30 public function rep_item_id() {
31 return 'switcher';
32 }
33
34 public function condition(): bool {
35 return jet_form_builder()->has_module( 'jet-style' );
36 }
37
38 public function on_install() {
39 }
40
41 public function on_uninstall() {
42 }
43
44 public function init_hooks() {
45 add_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
46 add_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
47 add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
48 add_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
49 add_action( 'enqueue_block_editor_assets', array( $this, 'preview_styles' ) );
50 }
51
52 public function remove_hooks() {
53 remove_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
54 remove_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
55 remove_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
56 remove_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
57 }
58
59 public function add_blocks_types( array $types ): array {
60 $types[] = new Blocks\Switcher\Block_Type();
61
62 return $types;
63 }
64
65 public function preview_styles() {
66
67 $script_asset = require $this->get_dir( 'assets/build/editor.asset.php' );
68
69 wp_enqueue_style(
70 $this->get_handle(),
71 $this->get_url( 'assets/build/switcher.css' ),
72 array(),
73 $script_asset['version']
74 );
75 }
76
77 public function enqueue_admin_assets() {
78
79 $script_asset = require $this->get_dir( 'assets/build/editor.asset.php' );
80
81 wp_enqueue_script(
82 $this->get_handle(),
83 $this->get_url( 'assets/build/editor.js' ),
84 $script_asset['dependencies'],
85 $script_asset['version'],
86 true
87 );
88
89 wp_enqueue_style(
90 $this->get_handle(),
91 $this->get_url( 'assets/build/switcher.css' ),
92 array(),
93 $script_asset['version']
94 );
95 }
96
97 public function register_frontend_scripts() {
98 $script_asset = require_once $this->get_dir( 'assets/build/switcher.asset.php' );
99
100 if ( true === $script_asset ) {
101 return;
102 }
103
104 array_push(
105 $script_asset['dependencies'],
106 BlocksModule::MAIN_SCRIPT_HANDLE
107 );
108
109 wp_register_script(
110 $this->get_handle(),
111 $this->get_url( 'assets/build/switcher.js' ),
112 $script_asset['dependencies'],
113 $script_asset['version'],
114 true
115 );
116 wp_register_style(
117 $this->get_handle(),
118 $this->get_url( 'assets/build/switcher.css' ),
119 array(),
120 $script_asset['version']
121 );
122 }
123 }
124