PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.0
JetFormBuilder — Dynamic Blocks Form Builder v3.1.0
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 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 / jet-style / module.php
jetformbuilder / modules / jet-style Last commit date
.config 2 years ago assets-build 2 years ago assets-src 2 years ago css-compilers 2 years ago .babelrc 2 years ago .gitattributes 2 years ago css-compiler-manager.php 2 years ago module.php 2 years ago package.json 2 years ago
module.php
127 lines
1 <?php
2
3
4 namespace JFB_Modules\Jet_Style;
5
6 use Jet_Form_Builder\Classes\Arrayable\Array_Tools;
7 use JFB_Components\Module\Base_Module_After_Install_It;
8 use JFB_Components\Module\Base_Module_Handle_It;
9 use JFB_Components\Module\Base_Module_Handle_Trait;
10 use JFB_Components\Module\Base_Module_It;
11 use JFB_Components\Module\Base_Module_Url_It;
12 use JFB_Components\Module\Base_Module_Url_Trait;
13
14 // If this file is called directly, abort.
15 if ( ! defined( 'WPINC' ) ) {
16 die;
17 }
18
19 /**
20 * @since 3.1.0
21 *
22 * Class Module
23 * @package JFB_Modules\Jet_Style
24 */
25 class Module implements
26 Base_Module_It,
27 Base_Module_Handle_It,
28 Base_Module_Url_It,
29 Base_Module_After_Install_It {
30
31 use Base_Module_Url_Trait;
32 use Base_Module_Handle_Trait;
33
34 const SUPPORT_NAME = 'jetStyle';
35
36 /**
37 * @var Css_Compiler_Manager
38 */
39 private $compiler;
40
41 public function rep_item_id() {
42 return 'jet-style';
43 }
44
45 public function condition(): bool {
46 // since WP 6.2
47 return class_exists( '\WP_HTML_Tag_Processor' );
48 }
49
50 public function on_install() {
51 $this->compiler = new Css_Compiler_Manager();
52
53 \WP_Block_Supports::get_instance()->register(
54 self::SUPPORT_NAME,
55 array(
56 'register_attribute' => array( $this, 'register_support' ),
57 'apply' => array( $this, 'apply_support' ),
58 )
59 );
60 }
61
62 public function on_uninstall() {
63 unset( $this->compiler );
64
65 \WP_Block_Supports::get_instance()->register( self::SUPPORT_NAME, array() );
66 }
67
68 public function init_hooks() {
69 add_action(
70 'jet-form-builder/editor-assets/before',
71 array( $this, 'register_scripts' ),
72 0
73 );
74 }
75
76 public function remove_hooks() {
77 remove_action(
78 'jet-form-builder/editor-assets/before',
79 array( $this, 'register_scripts' ),
80 0
81 );
82 }
83
84 public function register_scripts() {
85 wp_enqueue_script(
86 $this->get_handle(),
87 $this->get_url( 'assets-build/js/editor/main{min}.js' ),
88 array(),
89 jet_form_builder()->get_version(),
90 true
91 );
92 }
93
94 public function register_support( \WP_Block_Type $block_type ) {
95 // Setup attributes and styles within that if needed.
96 if ( ! $block_type->attributes ) {
97 $block_type->attributes = array();
98 }
99
100 if ( block_has_support( $block_type, array( self::SUPPORT_NAME ) ) &&
101 ! array_key_exists( 'style', $block_type->attributes )
102 ) {
103 $block_type->attributes['style'] = array(
104 'type' => 'object',
105 );
106 }
107 }
108
109 public function apply_support( \WP_Block_Type $block_type, array $block_attributes ): array {
110 $support_config = Array_Tools::get( $block_type->supports, array( self::SUPPORT_NAME ), false );
111 $root_styles = $block_attributes['style'] ?? array();
112
113 if (
114 ! is_array( $support_config ) ||
115 empty( $root_styles )
116 ) {
117 return array();
118 }
119
120 return $this->get_compiler()->compile( $root_styles, $support_config );
121 }
122
123 public function get_compiler(): Css_Compiler_Manager {
124 return $this->compiler;
125 }
126 }
127