PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.4
YayMail – WooCommerce Email Customizer v4.4.4
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
yaymail / src / Elements / BillingShippingAddress.php

BillingShippingAddress.php in YayMail – WooCommerce Email Customizer 4.4.4, at src/Elements/BillingShippingAddress.php

228 lines 11.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace YayMail\Elements;
3
4 use YayMail\Abstracts\BaseElement;
5 use YayMail\Utils\SingletonTrait;
6
7 /**
8 * Billing Address Elements
9 */
10 class BillingShippingAddress extends BaseElement {
11
12 use SingletonTrait;
13
14 protected static $type = 'billing_shipping_address';
15
16 public $available_email_ids = [ YAYMAIL_WITH_ORDER_EMAILS ];
17
18 public static function get_data( $attributes = [] ) {
19 $is_email_improvements_enabled = get_option( 'woocommerce_feature_email_improvements_enabled', 'no' ) === 'yes';
20 $layout_type = $is_email_improvements_enabled ? 'modern' : 'legacy';
21
22 self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20">
23 <defs>
24 <style>
25 .cls-1 {
26 fill: none;
27 }
28 </style>
29 </defs>
30 <g>
31 <polygon class="cls-1" points="4.61 8.21 4.14 9.53 15.87 9.53 14.36 5.33 10.04 5.33 10.04 8.21 4.61 8.21"/>
32 <path class="cls-1" d="M3.73,10.67l-.31.87v4.79h13.18v-4.79l-.31-.87H3.73ZM5.59,13.4c-.15.15-.36.24-.57.24s-.42-.09-.57-.24-.24-.36-.24-.57.08-.42.24-.57c.15-.15.36-.24.57-.24s.42.09.57.24c.15.15.24.36.24.57s-.08.42-.24.57ZM12.81,15.16c0,.09-.07.16-.16.16h-5.3c-.09,0-.16-.07-.16-.16v-1.7c0-.09.07-.16.16-.16h.8c.09,0,.16.07.16.16v.73h3.37v-.73c0-.09.07-.16.16-.16h.8c.09,0,.16.07.16.16v1.7ZM15.55,13.4c-.15.15-.36.24-.57.24s-.42-.09-.57-.24-.24-.36-.24-.57.08-.42.24-.57c.15-.15.36-.24.57-.24s.42.09.57.24c.15.15.24.36.24.57s-.08.42-.24.57Z"/>
33 <path d="M18.99,9.56s0-.08-.01-.12l-.48-.84s-.06-.06-.1-.07c-.04-.01-.08,0-.12.02l-1.02.6-1.57-4.37c-.08-.26-.25-.49-.47-.65-.22-.16-.48-.25-.76-.25h-4.43v1.45h4.32l1.51,4.21H4.14l.48-1.32h-1.54l-.34.93-1.02-.6s-.08-.03-.12-.02c-.04.01-.08.04-.1.07l-.48.84c-.04.08-.02.17.06.22l1.21.71-.29.81c-.02.06-.04.13-.04.2v7.04c0,.32.24.57.53.57h1.36c.25,0,.46-.19.51-.45l.15-.76h10.96l.15.76c.05.26.27.45.51.45h1.36c.29,0,.53-.26.53-.57v-7.04c0-.07-.01-.14-.04-.2l-.29-.81,1.21-.71s.06-.06.07-.1ZM16.59,16.33H3.41v-4.79l.31-.87h12.55l.31.87v4.79Z"/>
34 <path d="M5.02,12.02c-.21,0-.42.09-.57.24-.15.15-.24.36-.24.57s.08.42.24.57.36.24.57.24.42-.09.57-.24.24-.36.24-.57-.08-.42-.24-.57c-.15-.15-.36-.24-.57-.24Z"/>
35 <path d="M12.65,13.3h-.8c-.09,0-.16.07-.16.16v.73h-3.37v-.73c0-.09-.07-.16-.16-.16h-.8c-.09,0-.16.07-.16.16v1.7c0,.09.07.16.16.16h5.3c.09,0,.16-.07.16-.16v-1.7c0-.09-.07-.16-.16-.16Z"/>
36 <path d="M14.98,12.02c-.21,0-.42.09-.57.24-.15.15-.24.36-.24.57s.08.42.24.57.36.24.57.24.42-.09.57-.24.24-.36.24-.57-.08-.42-.24-.57c-.15-.15-.36-.24-.57-.24Z"/>
37 </g>
38 <g>
39 <path d="M8.71,7.99H2.17c-.55,0-1-.45-1-1.01V2.01c0-.56.45-1.01,1-1.01h6.53c.55,0,1,.45,1,1.01v4.98c0,.56-.45,1.01-1,1.01ZM8.71,6.98v.5-.5h0ZM2.17,2.01v4.98h6.53V2.01H2.17Z"/>
40 <path d="M4.14,3.63c.17,0,.31.14.31.32s-.14.32-.31.32-.31-.14-.31-.32.14-.32.31-.32M4.14,2.88c-.59,0-1.06.48-1.06,1.07s.48,1.07,1.06,1.07,1.06-.48,1.06-1.07-.48-1.07-1.06-1.07h0Z"/>
41 <path d="M5.77,5.95h-.75c0-.49-.4-.89-.88-.89s-.88.4-.88.89h-.75c0-.91.73-1.65,1.63-1.65s1.63.74,1.63,1.65Z"/>
42 <rect x="6.32" y="3.48" width="1.23" height="1.01"/>
43 <rect x="6.32" y="4.9" width="1.93" height="1.01"/>
44 </g>
45 </svg>';
46
47 $result = [
48 'id' => uniqid(),
49 'type' => self::$type,
50 'name' => __( 'Billing Shipping Address', 'yaymail' ),
51 'icon' => self::$icon,
52 'group' => 'woocommerce',
53 'available' => true,
54 'position' => 180,
55 'data' => [
56 'container_group_definition' => [
57 'component' => 'GroupDefinition',
58 'title' => __( 'Container settings', 'yaymail' ),
59 'description' => __( 'Handle container layout settings', 'yaymail' ),
60 ],
61 'padding' => ElementsHelper::get_spacing( $attributes ),
62 'background_color' => ElementsHelper::get_color(
63 $attributes,
64 [
65 'default_value' => '#fff',
66 ]
67 ),
68 'content_breaker' => [
69 'component' => 'LineBreaker',
70 ],
71 'content_group_definition' => [
72 'component' => 'GroupDefinition',
73 'title' => __( 'Content settings', 'yaymail' ),
74 'description' => __( 'Handle content settings', 'yaymail' ),
75 ],
76 'layout_type' => [
77 'value_path' => 'layout_type',
78 'component' => 'Selector',
79 'title' => __( 'Layout type', 'yaymail' ),
80 'default_value' => isset( $attributes['layout_type'] ) ? $attributes['layout_type'] : $layout_type,
81 'options' => [
82 [
83 'label' => __( 'Legacy', 'yaymail' ),
84 'value' => 'legacy',
85 ],
86 [
87 'label' => __( 'Modern', 'yaymail' ),
88 'value' => 'modern',
89 ],
90 ],
91 'type' => 'content',
92 ],
93 'responsive_on_mobile' => [
94 'value_path' => 'responsive_on_mobile',
95 'component' => 'Switcher',
96 'title' => __( 'Responsive on mobile', 'yaymail' ),
97 'default_value' => isset( $attributes['responsive_on_mobile'] ) ? (bool) $attributes['responsive_on_mobile'] : false,
98 'type' => 'content',
99 ],
100 'title_color' => ElementsHelper::get_color(
101 $attributes,
102 [
103 'value_path' => 'title_color',
104 'title' => __( 'Title color', 'yaymail' ),
105 'default_value' => YAYMAIL_COLOR_WC_DEFAULT,
106 ]
107 ),
108 'text_color' => ElementsHelper::get_color(
109 $attributes,
110 [
111 'value_path' => 'text_color',
112 'title' => __( 'Text color', 'yaymail' ),
113 'default_value' => YAYMAIL_COLOR_TEXT_DEFAULT,
114 ]
115 ),
116 'border_color' => ElementsHelper::get_color(
117 $attributes,
118 [
119 'value_path' => 'border_color',
120 'title' => __( 'Table border color', 'yaymail' ),
121 'default_value' => YAYMAIL_COLOR_BORDER_DEFAULT,
122 'conditions' => [
123 'condition_1' => [
124 'attribute' => 'layout_type',
125 'comparison' => '!=',
126 'value' => 'modern',
127 ],
128 ]
129 ]
130 ),
131 'font_family' => ElementsHelper::get_font_family_selector( $attributes ),
132 'billing_title' => ElementsHelper::get_rich_text(
133 $attributes,
134 [
135 'value_path' => 'billing_title',
136 'title' => __( 'Billing title', 'yaymail' ),
137 'default_value' => '<span style="font-size: 20px;font-weight:600;">' . __( 'Billing Address', 'woocommerce' ) . '</span>',
138 'editor_id' => 'bsa_billing_title',
139 'text_color_path' => 'title_color',
140 'background_color_path' => 'background_color',
141 ]
142 ),
143 'billing_content_font_size' => ElementsHelper::get_dimension(
144 $attributes,
145 [
146 'value_path' => 'billing_content_font_size',
147 'title' => __( 'Billing content font size', 'yaymail' ),
148 'default_value' => '14',
149 'min' => 8,
150 'max' => 25,
151 'unit' => 'px',
152 'type' => 'style',
153 ]
154 ),
155 'billing_content_alignment' => ElementsHelper::get_align(
156 $attributes,
157 [
158 'value_path' => 'billing_content_alignment',
159 'title' => __( 'Billing content alignment', 'yaymail' ),
160 'default_value' => 'left',
161 ]
162 ),
163 'billing_content_text_format' => ElementsHelper::get_text_format_toggles(
164 $attributes,
165 [
166 'value_path' => 'billing_content_text_format',
167 'title' => __( 'Billing address text formatting', 'yaymail' ),
168 ]
169 ),
170 'shipping_title' => ElementsHelper::get_rich_text(
171 $attributes,
172 [
173 'value_path' => 'shipping_title',
174 'title' => __( 'Shipping title', 'yaymail' ),
175 'default_value' => '<span style="font-size: 20px;font-weight:600;">' . __( 'Shipping Address', 'woocommerce' ) . '</span>',
176 'editor_id' => 'bsa_shipping_title',
177 'text_color_path' => 'title_color',
178 'background_color_path' => 'background_color',
179 ]
180 ),
181 'shipping_content_font_size' => ElementsHelper::get_dimension(
182 $attributes,
183 [
184 'value_path' => 'shipping_content_font_size',
185 'title' => __( 'Shipping content font size', 'yaymail' ),
186 'default_value' => '14',
187 'min' => 8,
188 'max' => 25,
189 'unit' => 'px',
190 'type' => 'style',
191 ]
192 ),
193 'shipping_content_alignment' => ElementsHelper::get_align(
194 $attributes,
195 [
196 'value_path' => 'shipping_content_alignment',
197 'title' => __( 'Shipping content alignment', 'yaymail' ),
198 'default_value' => 'left',
199 ]
200 ),
201 'shipping_content_text_format' => ElementsHelper::get_text_format_toggles(
202 $attributes,
203 [
204 'value_path' => 'shipping_content_text_format',
205 'title' => __( 'Shipping address text formatting', 'yaymail' ),
206 ]
207 ),
208 'shipping_address_content' => [
209 'value_path' => 'shipping_address_content',
210 'component' => '',
211 'title' => __( 'Shipping Content', 'yaymail' ),
212 'default_value' => '[yaymail_shipping_address]',
213 'type' => 'content',
214 ],
215 'billing_address_content' => [
216 'value_path' => 'billing_address_content',
217 'component' => '',
218 'title' => __( 'Billing Content', 'yaymail' ),
219 'default_value' => '[yaymail_billing_address]',
220 'type' => 'content',
221 ],
222
223 ],
224 ];
225 return $result;
226 }
227 }
228