PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.3
JetFormBuilder — Dynamic Blocks Form Builder v3.4.3
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 2 years ago blocks 2 years ago module.php 2 years ago
module.php
110 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 }
50
51 public function remove_hooks() {
52 remove_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) );
53 remove_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
54 remove_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ) );
55 remove_action( 'jet_plugins/frontend/register_scripts', array( $this, 'register_frontend_scripts' ) );
56 }
57
58 public function add_blocks_types( array $types ): array {
59 $types[] = new Blocks\Switcher\Block_Type();
60
61 return $types;
62 }
63
64 public function enqueue_admin_assets() {
65 $script_asset = require_once $this->get_dir( 'assets/build/editor.asset.php' );
66
67 wp_enqueue_script(
68 $this->get_handle(),
69 $this->get_url( 'assets/build/editor.js' ),
70 $script_asset['dependencies'],
71 $script_asset['version'],
72 true
73 );
74
75 wp_enqueue_style(
76 $this->get_handle(),
77 $this->get_url( 'assets/build/switcher.css' ),
78 array(),
79 $script_asset['version']
80 );
81 }
82
83 public function register_frontend_scripts() {
84 $script_asset = require_once $this->get_dir( 'assets/build/switcher.asset.php' );
85
86 if ( true === $script_asset ) {
87 return;
88 }
89
90 array_push(
91 $script_asset['dependencies'],
92 BlocksModule::MAIN_SCRIPT_HANDLE
93 );
94
95 wp_register_script(
96 $this->get_handle(),
97 $this->get_url( 'assets/build/switcher.js' ),
98 $script_asset['dependencies'],
99 $script_asset['version'],
100 true
101 );
102 wp_register_style(
103 $this->get_handle(),
104 $this->get_url( 'assets/build/switcher.css' ),
105 array(),
106 $script_asset['version']
107 );
108 }
109 }
110