PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.0
YayMail – WooCommerce Email Customizer v4.4.0
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 / OrderProgress.php

OrderProgress.php in YayMail – WooCommerce Email Customizer 4.4.0, at src/Elements/OrderProgress.php

194 lines 9.5 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 * OrderProgress element.
9 */
10 class OrderProgress extends BaseElement {
11
12 use SingletonTrait;
13
14 protected static $type = 'order_progress';
15
16 public $available_email_ids = [ YAYMAIL_WITH_ORDER_EMAILS ];
17
18 public static function get_data( $attributes = [] ) {
19 $default_icon = esc_url( YAYMAIL_PLUGIN_URL . 'assets/images/union.png' );
20
21 self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M3,2.5h14v1.75H3Z"/><path fill-rule="evenodd" d="M3.5,4.25h13v6.5h-13ZM4.25,5h11.5v5h-11.5Z"/><path d="M9.5,2.5h1v8.25h-1Z"/><path d="M4,15.5h12v.6H4Z"/><path d="M2.5,15.8a1.8,1.8 0 1,0 3.6,0a1.8,1.8 0 1,0 -3.6,0Z"/><path fill-rule="evenodd" d="M8.2,15.8a1.8,1.8 0 1,0 3.6,0a1.8,1.8 0 1,0 -3.6,0ZM9.15,15.8a.85,.85 0 1,1 1.7,0a.85,.85 0 1,1 -1.7,0Z"/><path fill-rule="evenodd" d="M13.7,15.8a1.8,1.8 0 1,0 3.6,0a1.8,1.8 0 1,0 -3.6,0ZM14.65,15.8a.85,.85 0 1,1 1.7,0a.85,.85 0 1,1 -1.7,0Z"/></svg>';
22
23 // Default three steps; users may add up to five total (ORDER_PROGRESS_MAX_STEPS in customizer).
24 $default_steps = [
25 [
26 'title' => __( 'Ordered', 'yaymail' ),
27 'label_active_color' => '#636363',
28 'label_inactive_color' => '#636363',
29 'image_active_url' => $default_icon,
30 'image_inactive_url' => $default_icon,
31 'image_bg_color' => '#873eff',
32 ],
33 [
34 'title' => __( 'Processing', 'yaymail' ),
35 'label_active_color' => '#636363',
36 'label_inactive_color' => '#636363',
37 'image_active_url' => $default_icon,
38 'image_inactive_url' => $default_icon,
39 'image_bg_color' => '#873eff',
40 ],
41 [
42 'title' => __( 'Completed', 'yaymail' ),
43 'label_active_color' => '#636363',
44 'label_inactive_color' => '#636363',
45 'image_active_url' => $default_icon,
46 'image_inactive_url' => $default_icon,
47 'image_bg_color' => '#873eff',
48 ],
49 ];
50
51 return [
52 'id' => uniqid(),
53 'type' => self::$type,
54 'name' => __( 'Order Progress', 'yaymail' ),
55 'icon' => self::$icon,
56 'group' => 'woocommerce',
57 'available' => true,
58 'position' => 152,
59 'data' => [
60 'container_group_definition' => [
61 'component' => 'GroupDefinition',
62 'title' => __( 'Container settings', 'yaymail' ),
63 'description' => __( 'Handle container layout settings', 'yaymail' ),
64 ],
65 'padding' => [
66 'value_path' => 'padding',
67 'component' => 'Spacing',
68 'title' => __( 'Padding', 'yaymail' ),
69 'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [
70 'top' => '10',
71 'right' => '50',
72 'bottom' => '10',
73 'left' => '50',
74 ],
75 'type' => 'style',
76 ],
77 'background_color' => ElementsHelper::get_color(
78 $attributes,
79 [
80 'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#ffffff',
81 ]
82 ),
83 'display_style' => [
84 'value_path' => 'display_style',
85 'component' => 'Selector',
86 'title' => __( 'Display style', 'yaymail' ),
87 'default_value' => 'step_marker',
88 'options' => [
89 [
90 'value' => 'step_marker',
91 'label' => __( 'Step marker', 'yaymail' ),
92 ],
93 [
94 'value' => 'filled_bar',
95 'label' => __( 'Filled bar', 'yaymail' ),
96 ],
97 ],
98 'type' => 'style',
99 ],
100 'content_breaker' => [
101 'component' => 'LineBreaker',
102 ],
103 'content_group_definition' => [
104 'component' => 'GroupDefinition',
105 'title' => __( 'Content settings', 'yaymail' ),
106 'description' => __( 'Handle content settings', 'yaymail' ),
107 ],
108 'current_step_index' => [
109 'value_path' => 'current_step_index',
110 'component' => 'OrderProgressCurrentStep',
111 'title' => __( 'Current step', 'yaymail' ),
112 'description' => __( 'Choose the active step.', 'yaymail' ),
113 'default_value' => isset( $attributes['current_step_index'] ) ? $attributes['current_step_index'] : 0,
114 'type' => 'content',
115 ],
116 'connector_height' => ElementsHelper::get_dimension(
117 $attributes,
118 [
119 'value_path' => 'connector_height',
120 'title' => __( 'Connector height', 'yaymail' ),
121 'default_value' => isset( $attributes['connector_height'] ) ? $attributes['connector_height'] : '2',
122 'min' => 1,
123 'max' => 10,
124 'unit' => 'px',
125 'type' => 'style',
126 ]
127 ),
128 'connector_active_color' => ElementsHelper::get_color(
129 $attributes,
130 [
131 'value_path' => 'connector_active_color',
132 'title' => __( 'Connector color (active)', 'yaymail' ),
133 'default_value' => isset( $attributes['connector_active_color'] ) ? $attributes['connector_active_color'] : '#873eff',
134 ]
135 ),
136 'connector_inactive_color' => ElementsHelper::get_color(
137 $attributes,
138 [
139 'value_path' => 'connector_inactive_color',
140 'title' => __( 'Connector color (inactive)', 'yaymail' ),
141 'default_value' => isset( $attributes['connector_inactive_color'] ) ? $attributes['connector_inactive_color'] : '#E2E6EE',
142 ]
143 ),
144 'icon_size' => ElementsHelper::get_dimension(
145 $attributes,
146 [
147 'value_path' => 'icon_size',
148 'title' => __( 'Icon size', 'yaymail' ),
149 'default_value' => isset( $attributes['icon_size'] ) ? $attributes['icon_size'] : '24',
150 'min' => 10,
151 'max' => 80,
152 'unit' => 'px',
153 'type' => 'style',
154 ]
155 ),
156 'label_font_size' => ElementsHelper::get_dimension(
157 $attributes,
158 [
159 'value_path' => 'label_font_size',
160 'title' => __( 'Label font size', 'yaymail' ),
161 'default_value' => isset( $attributes['label_font_size'] ) ? $attributes['label_font_size'] : '14',
162 'min' => 8,
163 'max' => 24,
164 'unit' => 'px',
165 'type' => 'style',
166 ]
167 ),
168 'font_family' => [
169 'value_path' => 'font_family',
170 'component' => 'FontFamilySelector',
171 'title' => __( 'Label font family', 'yaymail' ),
172 'default_value' => isset( $attributes['font_family'] ) ? $attributes['font_family'] : YAYMAIL_DEFAULT_FAMILY,
173 'type' => 'style',
174 ],
175 'appearance_breaker' => [
176 'component' => 'LineBreaker',
177 ],
178 'appearance_group_definition' => [
179 'component' => 'GroupDefinition',
180 'title' => __( 'Appearance', 'yaymail' ),
181 'description' => __( 'Handle step label colors and icon background color.', 'yaymail' ),
182 ],
183 'steps' => [
184 'value_path' => 'steps',
185 'component' => 'OrderProgressSteps',
186 'title' => __( 'Steps', 'yaymail' ),
187 'default_value' => isset( $attributes['steps'] ) && is_array( $attributes['steps'] ) ? $attributes['steps'] : $default_steps,
188 'type' => 'content',
189 ],
190 ],
191 ];
192 }
193 }
194