PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
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 3.4.2 3.4.3 All 55 releases
yaymail / src / Elements / Button.php

Button.php in YayMail – WooCommerce Email Customizer trunk, at src/Elements/Button.php

172 lines 7.6 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 use YayMail\Constants\AttributesData;
7 /**
8 * Button Elements
9 */
10 class Button extends BaseElement {
11
12 use SingletonTrait;
13
14 protected static $type = 'button';
15
16 public $available_email_ids = [ YAYMAIL_ALL_EMAILS ];
17
18 public static function get_data( $attributes = [] ) {
19 self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" version="1.1" viewBox="0 0 20 20">
20 <path d="M10,1C5,1,1,5,1,10s4,9,9,9,9-4,9-9S15,1,10,1ZM10,17.5c-4.1,0-7.5-3.4-7.5-7.5s3.4-7.5,7.5-7.5,7.5,3.4,7.5,7.5-3.4,7.5-7.5,7.5Z"/>
21 <path d="M12.8,9.2h-2.1v-2.1c0-.4-.3-.8-.8-.8s-.8.3-.8.8v2.1h-2.1c-.4,0-.8.3-.8.8s.3.8.8.8h2.1v2.1c0,.4.3.8.8.8s.8-.3.8-.8v-2.1h2.1c.4,0,.8-.3.8-.8s-.3-.8-.8-.8Z"/>
22 </svg>';
23
24 return [
25 'id' => uniqid(),
26 'type' => self::$type,
27 'name' => __( 'Button', 'yaymail' ),
28 'icon' => self::$icon,
29 'group' => 'basic',
30 'available' => true,
31 'position' => 60,
32 'data' => [
33 'container_group_definition' => [
34 'component' => 'GroupDefinition',
35 'title' => __( 'Container settings', 'yaymail' ),
36 'description' => __( 'Handle container layout settings', 'yaymail' ),
37 ],
38 'padding' => ElementsHelper::get_spacing(
39 $attributes,
40 [
41 'title' => __( 'Padding', 'yaymail' ),
42 ]
43 ),
44 'background_color' => ElementsHelper::get_color(
45 $attributes,
46 [
47 'default_value' => '#fff',
48 ]
49 ),
50 'button_setting_breaker' => [
51 'component' => 'LineBreaker',
52 ],
53 'button_group_definition' => [
54 'component' => 'GroupDefinition',
55 'title' => __( 'Button settings', 'yaymail' ),
56 'description' => __( 'Handle button settings', 'yaymail' ),
57 ],
58 'button_type' => ElementsHelper::get_button_type_selector( $attributes ),
59 'align' => ElementsHelper::get_align(
60 $attributes,
61 [
62 'title' => __( 'Button position', 'yaymail' ),
63 ]
64 ),
65 'width' => ElementsHelper::get_button_width_selector( $attributes ),
66 'custom_width' => ElementsHelper::get_dimension(
67 $attributes,
68 [
69 'value_path' => 'custom_width',
70 'title' => __( 'Custom width', 'yaymail' ),
71 'default_value' => '50',
72 'min' => 0,
73 'max' => 100,
74 'unit' => '%',
75 'conditions' => [
76 'condition_1' => [
77 'attribute' => 'width',
78 'comparison' => '==',
79 'value' => 'custom',
80 ],
81 ],
82 ]
83 ),
84 'height' => ElementsHelper::get_dimension(
85 $attributes,
86 [
87 'value_path' => 'height',
88 'title' => __( 'Height', 'yaymail' ),
89 'default_value' => '21',
90 'min' => 0,
91 'max' => 100,
92 ]
93 ),
94 'button_padding' => [
95 'value_path' => 'button_padding',
96 'component' => 'Spacing',
97 'title' => __( 'Padding', 'yaymail' ),
98 'default_value' => [
99 'top' => '12',
100 'right' => '20',
101 'bottom' => '12',
102 'left' => '20',
103 ],
104 'type' => 'style',
105 ],
106 'button_background_color' => ElementsHelper::get_color(
107 $attributes,
108 [
109 'value_path' => 'button_background_color',
110 'title' => __( 'Background color', 'yaymail' ),
111 'default_value' => yaymail_get_default_brand_color(),
112 ]
113 ),
114 'text_color' => ElementsHelper::get_color(
115 $attributes,
116 [
117 'value_path' => 'text_color',
118 'title' => __( 'Text color', 'yaymail' ),
119 'default_value' => '#ffffff',
120 ]
121 ),
122 'border' => [
123 'value_path' => 'border',
124 'component' => 'Border',
125 'title' => __( 'Border', 'yaymail' ),
126 'default_value' => isset( $attributes['border'] ) ? $attributes['border'] : AttributesData::BORDER_DEFAULT,
127 'type' => 'style',
128 ],
129 'border_radius' => ElementsHelper::get_border_radius(
130 $attributes,
131 [
132 'value_path' => 'border_radius',
133 'title' => __( 'Border radius', 'yaymail' ),
134 'default_value' => [
135 'top_left' => '5',
136 'top_right' => '5',
137 'bottom_right' => '5',
138 'bottom_left' => '5',
139 ],
140 ]
141 ),
142 'button_content_group_definition' => [
143 'component' => 'GroupDefinition',
144 'title' => __( 'Button content', 'yaymail' ),
145 'description' => __( 'Handle button content', 'yaymail' ),
146 ],
147 'text' => ElementsHelper::get_text_input(
148 $attributes,
149 [
150 'value_path' => 'text',
151 'title' => __( 'Button text', 'yaymail' ),
152 'default_value' => __( 'Click me', 'yaymail' ),
153 ]
154 ),
155 'url' => ElementsHelper::get_text_input( $attributes ),
156 'font_size' => ElementsHelper::get_dimension(
157 $attributes,
158 [
159 'value_path' => 'font_size',
160 'title' => __( 'Font size', 'yaymail' ),
161 'default_value' => '13',
162 'min' => 10,
163 'max' => 40,
164 ]
165 ),
166 'weight' => ElementsHelper::get_font_weight_selector( $attributes ),
167 'font_family' => ElementsHelper::get_font_family_selector( $attributes ),
168 ],
169 ];
170 }
171 }
172