PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
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 / compatibility / bricks / bricks.php
jetformbuilder / compatibility / bricks Last commit date
assets 1 month ago widgets 1 month ago bricks.php 6 months ago onboarding-builder.php 1 year ago
bricks.php
131 lines
1 <?php
2
3
4 namespace JFB_Compatibility\Bricks;
5
6 use Bricks\Elements;
7 use Jet_Form_Builder\Plugin;
8 use Jet_Form_Builder\Classes\Tools;
9 use JFB_Components\Compatibility\Base_Compat_Handle_Trait;
10 use JFB_Components\Compatibility\Base_Compat_Url_Trait;
11 use JFB_Components\Compatibility\Base_Compat_Dir_Trait;
12 use JFB_Components\Module\Base_Module_After_Install_It;
13 use JFB_Components\Module\Base_Module_Handle_It;
14 use JFB_Components\Module\Base_Module_It;
15 use JFB_Components\Module\Base_Module_Url_It;
16 use JFB_Components\Module\Base_Module_Dir_It;
17
18 // If this file is called directly, abort.
19 if ( ! defined( 'WPINC' ) ) {
20 die;
21 }
22
23 class Bricks implements
24 Base_Module_It,
25 Base_Module_Handle_It,
26 Base_Module_Url_It,
27 Base_Module_Dir_It,
28 Base_Module_After_Install_It {
29
30 use Base_Compat_Handle_Trait;
31 use Base_Compat_Url_Trait;
32 use Base_Compat_Dir_Trait;
33
34 /**
35 * @var Onboarding_Builder
36 */
37 private $onboarding_builder;
38
39 public function rep_item_id() {
40 return 'bricks';
41 }
42
43 public function condition(): bool {
44 return defined( 'BRICKS_VERSION' );
45 }
46
47 public function on_install() {
48 $this->onboarding_builder = new Onboarding_Builder();
49 }
50
51 public function on_uninstall() {
52 }
53
54 public function init_hooks() {
55 add_action( 'init', array( $this, 'register_elements' ), 10 );
56 add_action( 'wp_enqueue_scripts', array( $this, 'editor_styles' ) );
57 add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ), 20 );
58
59 $this->get_onboarding_builder()->init_hooks();
60 }
61
62 public function remove_hooks() {
63 remove_action( 'init', array( $this, 'register_elements' ) );
64 remove_action( 'wp_enqueue_scripts', array( $this, 'editor_styles' ) );
65 remove_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ), 20 );
66 }
67
68 public function register_elements() {
69 $file_path = $this->get_dir( 'widgets/form.php' );
70 Elements::register_element( $file_path, '', 'JFB_Compatibility\Bricks\Widgets\Form' );
71
72 do_action( 'jet-form-builder/bricks/register-elements' );
73 }
74
75 public function editor_styles() {
76 // Enqueue your files on the canvas & frontend, not the builder panel. Otherwise custom CSS might affect builder)
77 if ( Tools::is_editor() ) {
78 wp_enqueue_style(
79 $this->get_handle( 'icons' ),
80 $this->get_url( 'assets/build/editor/icons.css' ),
81 array(),
82 Plugin::instance()->get_version()
83 );
84 }
85 }
86
87 /**
88 * Enqueue frontend scripts for AJAX popup support
89 *
90 * @since 3.5.6
91 */
92 public function frontend_scripts() {
93 // Only enqueue on frontend, not in editor
94 if ( Tools::is_editor() ) {
95 return;
96 }
97
98 $asset_file = $this->get_dir( 'assets/build/frontend.asset.php' );
99
100 if ( file_exists( $asset_file ) ) {
101 $asset = require $asset_file;
102 } else {
103 $asset = array(
104 'dependencies' => array(),
105 'version' => Plugin::instance()->get_version(),
106 );
107 }
108
109 // Start with dependencies from asset file
110 $dependencies = $asset['dependencies'] ?? array();
111
112 $script_url = $this->get_url( 'assets/build/frontend.js' );
113 $script_handle = $this->get_handle( 'frontend' );
114
115 wp_enqueue_script(
116 $script_handle,
117 $script_url,
118 $dependencies,
119 $asset['version'] ?? Plugin::instance()->get_version(),
120 true
121 );
122 }
123
124 /**
125 * @return Onboarding_Builder
126 */
127 public function get_onboarding_builder(): Onboarding_Builder {
128 return $this->onboarding_builder;
129 }
130 }
131