PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.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 / blocks-v2 / repeater-field / block-asset.php
jetformbuilder / modules / blocks-v2 / repeater-field Last commit date
assets 8 months ago .eslintrc.js 1 year ago block-asset.php 1 year ago block-render.php 1 year ago block-type-row.php 1 year ago block-type.php 1 year ago block.json 1 year ago
block-asset.php
101 lines
1 <?php
2
3 namespace JFB_Modules\Blocks_V2\Repeater_Field;
4
5 use Jet_Form_Builder\Exceptions\Repository_Exception;
6 use JFB_Modules\Blocks_V2\Interfaces\Block_Asset_Interface;
7 use JFB_Modules\Blocks_V2\Module;
8 use Jet_Form_Builder\Blocks\Module as LegacyBlocksModule;
9
10 class Block_Asset implements Block_Asset_Interface {
11
12 const HANDLE = 'jet-fb-repeater-field';
13
14 public function init_hooks() {
15 add_action(
16 'jet-form-builder/editor-assets/before',
17 array( $this, 'enqueue_editor_assets' )
18 );
19 add_action(
20 'wp_enqueue_scripts',
21 array( $this, 'register_frontend_assets' )
22 );
23 add_action(
24 'jet_plugins/frontend/register_scripts',
25 array( $this, 'register_frontend_assets' )
26 );
27 }
28
29 /**
30 * @throws Repository_Exception
31 */
32 public function register_frontend_assets() {
33 $asset = require_once $this->get_dir( '/assets/build/frontend.asset.php' );
34
35 if ( true === $asset ) {
36 return;
37 }
38
39 $asset['dependencies'][] = LegacyBlocksModule::MAIN_SCRIPT_HANDLE;
40
41 wp_register_script(
42 self::HANDLE,
43 $this->get_url( '/assets/build/frontend.js' ),
44 $asset['dependencies'],
45 $asset['version'],
46 true
47 );
48
49 wp_register_style(
50 self::HANDLE,
51 $this->get_url( '/assets/build/frontend.css' ),
52 array(),
53 $asset['version']
54 );
55 }
56
57 /**
58 * @return void
59 * @throws Repository_Exception
60 */
61 public function enqueue_editor_assets() {
62 $asset = require_once $this->get_dir( '/assets/build/editor.asset.php' );
63
64 if ( true === $asset ) {
65 return;
66 }
67
68 wp_enqueue_script(
69 $this->get_handle( 'repeater-field-editor' ),
70 $this->get_url( '/assets/build/editor.js' ),
71 $asset['dependencies'],
72 $asset['version'],
73 true
74 );
75 }
76
77 /** @noinspection PhpUnhandledExceptionInspection */
78 private function get_dir( string $path = '' ): string {
79 /** @var Module $compat */
80 $compat = jet_form_builder()->module( 'blocks-v2' );
81
82 return $compat->get_dir( 'repeater-field' . $path );
83 }
84
85 /** @noinspection PhpUnhandledExceptionInspection */
86 private function get_url( string $path ): string {
87 /** @var Module $compat */
88 $compat = jet_form_builder()->module( 'blocks-v2' );
89
90 return $compat->get_url( 'repeater-field' . $path );
91 }
92
93 /** @noinspection PhpUnhandledExceptionInspection */
94 private function get_handle( string $prefix ): string {
95 /** @var Module $compat */
96 $compat = jet_form_builder()->module( 'blocks-v2' );
97
98 return $compat->get_handle( $prefix );
99 }
100 }
101