PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.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 All 134 releases
jetformbuilder / compatibility / jet-style-manager / jet-style-manager.php

jet-style-manager.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at compatibility/jet-style-manager/jet-style-manager.php

114 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Compatibility\Jet_Style_Manager;
5
6 use JET_SM\Gutenberg\Controls_Manager;
7 use JFB_Compatibility\Jet_Style_Manager\Blocks\Form;
8 use JFB_Compatibility\Jet_Style_Manager\Blocks\Interfaces\Style_Block_It;
9 use JFB_Components\Module\Base_Module_After_Install_It;
10 use JFB_Components\Module\Base_Module_It;
11 use JFB_Components\Repository\Interfaces\Repository_Pattern_Interface;
12 use JFB_Components\Repository\Repository_Pattern_Trait;
13
14 // If this file is called directly, abort.
15 if ( ! defined( 'WPINC' ) ) {
16 die;
17 }
18
19 class Jet_Style_Manager implements Base_Module_It, Base_Module_After_Install_It, Repository_Pattern_Interface {
20
21 use Repository_Pattern_Trait;
22
23 public function rep_item_id() {
24 return 'jet-style-manager';
25 }
26
27 public function on_install() {
28 $this->rep_install();
29 }
30
31 public function on_uninstall() {
32 $this->rep_clear();
33 }
34
35 public function condition(): bool {
36 return (
37 class_exists( 'JET_SM\Gutenberg\Controls_Manager' )
38 && class_exists( 'JET_SM\Gutenberg\Block_Manager' )
39 );
40 }
41
42 public function init_hooks() {
43 add_action( 'init', array( $this, 'register_block_styles' ), 9 );
44 }
45
46 public function remove_hooks() {
47 add_action( 'init', array( $this, 'register_block_styles' ), 9 );
48 }
49
50
51 public function rep_instances(): array {
52 return array(
53 new Form(),
54 );
55 }
56
57 public function register_block_styles() {
58 /** @var Style_Block_It $block */
59 foreach ( $this->rep_generate_items() as $block ) {
60 $block->set_namespace( '.jet-form-builder' );
61 $block->set_manager( new Controls_Manager( $block->rep_item_id() ) );
62 $block->process_controls();
63 }
64 }
65
66 public function create_margin( string $selector, $extra_options = array() ): array {
67 $margin = array(
68 'type' => 'dimensions',
69 'label' => __( 'Margin', 'jet-form-builder' ),
70 'units' => array( 'px', '%' ),
71 'separator' => 'after',
72 'css_selector' => array(
73 $selector => 'margin: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
74 ),
75 );
76
77 // probably an id of the control
78 if ( is_string( $extra_options ) ) {
79 $margin['id'] = $extra_options;
80 }
81 if ( is_array( $extra_options ) && $extra_options ) {
82 $margin = array_merge( $margin, $extra_options );
83 }
84
85 return $margin;
86 }
87
88 public function create_padding( string $selector, $extra_options = array() ): array {
89 $padding = array(
90 'type' => 'dimensions',
91 'label' => __( 'Padding', 'jet-form-builder' ),
92 'units' => array( 'px', '%', 'em' ),
93 'separator' => 'after',
94 'css_selector' => array(
95 $selector => 'padding: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
96 ),
97 );
98
99 // probably an id of the control
100 if ( is_string( $extra_options ) ) {
101 $padding['id'] = $extra_options;
102 }
103 if ( is_array( $extra_options ) && $extra_options ) {
104 $padding = array_merge( $padding, $extra_options );
105 }
106
107 return $padding;
108 }
109
110 public function install( Style_Block_It $block ) {
111 $this->rep_install_item_soft( $block );
112 }
113 }
114