PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.2
JetFormBuilder — Dynamic Blocks Form Builder v3.5.2
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 / wp-experiments / module.php
jetformbuilder / modules / wp-experiments Last commit date
module.php 2 years ago
module.php
97 lines
1 <?php
2
3
4 namespace JFB_Modules\Wp_Experiments;
5
6 // If this file is called directly, abort.
7 use Jet_Form_Builder\Blocks\Block_Helper;
8 use Jet_Form_Builder\Classes\Arrayable\Array_Tools;
9 use JFB_Components\Module\Base_Module_After_Install_It;
10 use JFB_Components\Module\Base_Module_It;
11
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 /**
17 * @since 3.1.0
18 *
19 * Class Wp_Experiments
20 * @package JFB_Modules\Wp_Experiments
21 */
22 class Module implements Base_Module_It, Base_Module_After_Install_It {
23
24 const SUPPORT_CUSTOM_LAYOUT = 'jetCustomWrapperLayout';
25
26 private $layout_prop = 'layout';
27
28 public function rep_item_id() {
29 return 'wp-experiments';
30 }
31
32 public function condition(): bool {
33 return true;
34 }
35
36 public function init_hooks() {
37 add_filter(
38 'block_type_metadata',
39 array( $this, 'disable_layout_support' )
40 );
41 }
42
43 public function remove_hooks() {
44 remove_filter(
45 'block_type_metadata',
46 array( $this, 'disable_layout_support' )
47 );
48 }
49
50 public function on_install() {
51 if ( function_exists( 'wp_is_development_mode' ) ) {
52 return;
53 }
54 $this->layout_prop = '__experimentalLayout';
55 }
56
57 public function on_uninstall() {
58 }
59
60 public function disable_layout_support( array $metadata ): array {
61 if (
62 ! Block_Helper::is_field( $metadata['name'] ) ||
63 ! is_array( $metadata['supports'] ) ||
64 ! Array_Tools::get( $metadata['supports'], array( self::SUPPORT_CUSTOM_LAYOUT ), false )
65 ) {
66 return $metadata;
67 }
68
69 $metadata['supports'][ self::SUPPORT_CUSTOM_LAYOUT ] = $metadata['supports'][ $this->layout_prop ];
70 unset( $metadata['supports'][ $this->layout_prop ] );
71
72 return $metadata;
73 }
74
75 public function enable_native_layout() {
76 $block_type = Block_Helper::current_block_type();
77
78 if ( ! $block_type ) {
79 return;
80 }
81
82 $block_type->supports[ $this->layout_prop ] = $block_type->supports[ self::SUPPORT_CUSTOM_LAYOUT ];
83 unset( $block_type->supports[ self::SUPPORT_CUSTOM_LAYOUT ] );
84 }
85
86 public function remove_native_layout() {
87 $block_type = Block_Helper::current_block_type();
88
89 if ( ! $block_type ) {
90 return;
91 }
92
93 $block_type->supports[ self::SUPPORT_CUSTOM_LAYOUT ] = $block_type->supports[ $this->layout_prop ];
94 unset( $block_type->supports[ $this->layout_prop ] );
95 }
96 }
97