PluginProbe ʕ •ᴥ•ʔ
Grid & Styler For Contact Form 7 And Divi / 1.7.1
Grid & Styler For Contact Form 7 And Divi v1.7.1
trunk 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.4.1 1.4.2 1.5.2 1.6.0 1.6.1 1.7.0 1.7.1 2.1.0 2.1.1
cf7-grid-and-styler-for-divi / includes / classes / Divi / MarginPadding.php
cf7-grid-and-styler-for-divi / includes / classes / Divi Last commit date
ET_Builder_Module_Field_Border.php 1 year ago MarginPadding.php 1 year ago
MarginPadding.php
122 lines
1 <?php
2 namespace WPT\Cf7Divi\Divi;
3
4 use ET_Builder_Module_Helper_ResponsiveOptions;
5
6 /**
7 * MarginPadding.
8 */
9 class MarginPadding {
10 protected $container;
11
12 /**
13 * Constructor.
14 */
15 public function __construct($container) {
16 $this->container = $container;
17 }
18
19 /**
20 * Margin field
21 */
22 public function get_margin_field($prefix, $tab_slug, $toggle_slug, $default = '') {
23 $fields = [];
24
25 $fields[$prefix . '_custom_margin'] = [
26 'label' => esc_html__('Margin', 'et_builder'),
27 'type' => 'custom_margin',
28 'mobile_options' => true,
29 'tab_slug' => $tab_slug,
30 'toggle_slug' => $toggle_slug,
31 'default' => $default,
32 ];
33
34 return $fields;
35
36 }
37
38 /**
39 * Margin padding field
40 */
41 public function get_margin_padding_field($prefix, $tab_slug, $toggle_slug, $margin_default = '', $padding_default = '') {
42 $margin_field = $this->get_margin_field($prefix, $tab_slug, $toggle_slug, $margin_default);
43 $padding_field = $this->get_padding_field($prefix, $tab_slug, $toggle_slug, $padding_default);
44
45 return $margin_field + $padding_field;
46
47 }
48
49 /**
50 * Padding field
51 */
52 public function get_padding_field($prefix, $tab_slug, $toggle_slug, $default = '') {
53 $fields = [];
54
55 $fields[$prefix . '_custom_padding'] = [
56 'label' => esc_html__('Padding', 'et_builder'),
57 'type' => 'custom_margin',
58 'mobile_options' => true,
59 'tab_slug' => $tab_slug,
60 'toggle_slug' => $toggle_slug,
61 'default' => $default,
62 ];
63
64 return $fields;
65
66 }
67
68 /**
69 * Responsive margin settings.
70 */
71 public function responsive_margin($props, $prefix, $selector, $render_slug) {
72 $responsive = ET_Builder_Module_Helper_ResponsiveOptions::instance();
73
74 $is_margin_responsive = $responsive->is_responsive_enabled($props, "{$prefix}_custom_margin");
75
76 $margin_desktop = $responsive->get_any_value($props, "{$prefix}_custom_margin");
77 $margin_tablet = $is_margin_responsive ? $responsive->get_any_value($props, "{$prefix}_custom_margin_tablet") : '';
78 $margin_phone = $is_margin_responsive ? $responsive->get_any_value($props, "{$prefix}_custom_margin_phone") : '';
79
80 $important = true;
81
82 $margin_styles = [
83 'desktop' => '' !== $margin_desktop ? rtrim(et_builder_get_element_style_css($margin_desktop, 'margin', $important)) : '',
84 'tablet' => '' !== $margin_tablet ? rtrim(et_builder_get_element_style_css($margin_tablet, 'margin', $important)) : '',
85 'phone' => '' !== $margin_phone ? rtrim(et_builder_get_element_style_css($margin_phone, 'margin', $important)) : '',
86 ];
87
88 $responsive->declare_responsive_css($margin_styles, $selector, $render_slug);
89 }
90
91 /**
92 * Responsive margin padding
93 */
94 public function responsive_margin_padding($props, $prefix, $selector, $render_slug) {
95 $this->responsive_margin($props, $prefix, $selector, $render_slug);
96 $this->responsive_padding($props, $prefix, $selector, $render_slug);
97 }
98
99 public function responsive_padding($props, $prefix, $selector, $render_slug) {
100 $responsive = ET_Builder_Module_Helper_ResponsiveOptions::instance();
101
102 $is_padding_responsive = $responsive->is_responsive_enabled($props, "{$prefix}_custom_padding");
103
104 $padding_desktop = $responsive->get_any_value($props, "{$prefix}_custom_padding");
105 $padding_tablet = $is_padding_responsive ? $responsive->get_any_value($props, "{$prefix}_custom_padding_tablet") : '';
106 $padding_phone = $is_padding_responsive ? $responsive->get_any_value($props, "{$prefix}_custom_padding_phone") : '';
107
108 $important = true;
109
110 $padding_styles = [
111 'desktop' => '' !== $padding_desktop ? rtrim(et_builder_get_element_style_css($padding_desktop, 'padding', $important)) : '',
112 'tablet' => '' !== $padding_tablet ? rtrim(et_builder_get_element_style_css($padding_tablet, 'padding', $important)) : '',
113 'phone' => '' !== $padding_phone ? rtrim(et_builder_get_element_style_css($padding_phone, 'padding', $important)) : '',
114 ];
115
116 // wp_die(var_dump($padding_styles));
117
118 $responsive->declare_responsive_css($padding_styles, $selector, $render_slug);
119
120 }
121 }
122