PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.7
JetFormBuilder — Dynamic Blocks Form Builder v3.4.7
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 / onboarding / use-form / use-form.php
jetformbuilder / modules / onboarding / use-form Last commit date
assets 1 year ago rest-api 1 year ago use-form.php 1 year ago
use-form.php
121 lines
1 <?php
2
3
4 namespace JFB_Modules\Onboarding\Use_Form;
5
6 use JFB_Components\Module\Base_Module_After_Install_It;
7 use JFB_Components\Module\Base_Module_Dir_It;
8 use JFB_Components\Module\Base_Module_Dir_Trait;
9 use JFB_Components\Module\Base_Module_Handle_It;
10 use JFB_Components\Module\Base_Module_Handle_Trait;
11 use JFB_Components\Module\Base_Module_It;
12 use JFB_Components\Module\Base_Module_Url_It;
13 use JFB_Components\Module\Base_Module_Url_Trait;
14 use JFB_Modules\Onboarding\Builders\Block_Editor_Builder;
15 use JFB_Modules\Onboarding\Builders\No_Builder_Handler;
16 use JFB_Modules\Onboarding\Module;
17 use JFB_Modules\Onboarding\Use_Form\Rest_Api\Use_Form_Route\Use_Form_Route;
18
19 // If this file is called directly, abort.
20 if ( ! defined( 'WPINC' ) ) {
21 die;
22 }
23
24 class Use_Form implements
25 Base_Module_Url_It,
26 Base_Module_Dir_It,
27 Base_Module_Handle_It {
28
29 /**
30 * @var Block_Editor_Builder
31 */
32 private $block_builder;
33 /**
34 * @var No_Builder_Handler
35 */
36 private $no_builder;
37
38 public function __construct() {
39 $this->block_builder = new Block_Editor_Builder();
40 $this->no_builder = new No_Builder_Handler();
41 }
42
43 public function init_hooks() {
44 add_action(
45 'jet-form-builder/use-form/register-assets',
46 array( $this, 'register_assets' ),
47 0
48 );
49
50 add_action(
51 'rest_api_init',
52 array( $this, 'rest_api_init' )
53 );
54
55 $this->get_block_builder()->init_hooks();
56 $this->get_no_builder()->init_hooks();
57 }
58
59 public function rest_api_init() {
60 $route = new Use_Form_Route();
61 $route->register();
62 }
63
64 public function register_assets() {
65 $script_asset = require_once $this->get_dir( 'assets/build/index.asset.php' );
66
67 if ( true === $script_asset ) {
68 return;
69 }
70
71 array_push(
72 $script_asset['dependencies'],
73 'jet-fb-components'
74 );
75
76 wp_register_script(
77 $this->get_handle(),
78 $this->get_url( 'assets/build/index.js' ),
79 $script_asset['dependencies'],
80 $script_asset['version'],
81 true
82 );
83 }
84
85 public function get_block_builder(): Block_Editor_Builder {
86 return $this->block_builder;
87 }
88
89 /**
90 * @return No_Builder_Handler
91 */
92 public function get_no_builder(): No_Builder_Handler {
93 return $this->no_builder;
94 }
95
96
97 public function get_dir( string $path ): string {
98 /** @var Module $onboarding */
99 /** @noinspection PhpUnhandledExceptionInspection */
100 $onboarding = jet_form_builder()->module( 'onboarding' );
101
102 return $onboarding->get_dir( 'use-form/' . $path );
103 }
104
105 public function get_handle( string $unique_string = '' ): string {
106 /** @var Module $onboarding */
107 /** @noinspection PhpUnhandledExceptionInspection */
108 $onboarding = jet_form_builder()->module( 'onboarding' );
109
110 return $onboarding->get_handle( 'use-form' . $unique_string );
111 }
112
113 public function get_url( string $url ): string {
114 /** @var Module $onboarding */
115 /** @noinspection PhpUnhandledExceptionInspection */
116 $onboarding = jet_form_builder()->module( 'onboarding' );
117
118 return $onboarding->get_url( 'use-form/' . $url );
119 }
120 }
121