1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
<?php /* Widget Name: Features Description: Displays a block of features with icons. Author: SiteOrigin Author URI: https://siteorigin.com Documentation: https://siteorigin.com/widgets-bundle/features-widget-documentation/ */
class SiteOrigin_Widget_Features_Widget extends SiteOrigin_Widget { function __construct() { parent::__construct( 'sow-features', __( 'SiteOrigin Features', 'so-widgets-bundle' ), array( 'description' => __( 'Displays a list of features.', 'so-widgets-bundle' ), 'help' => 'https://siteorigin.com/widgets-bundle/features-widget-documentation/' ), array(), false, plugin_dir_path(__FILE__) ); }
function initialize() { $this->register_frontend_styles( array( array( 'siteorigin-widgets', plugin_dir_url(__FILE__) . 'css/style.css', array(), SOW_BUNDLE_VERSION ) ) ); }
function get_widget_form(){
return array( 'features' => array( 'type' => 'repeater', 'label' => __( 'Features', 'so-widgets-bundle' ), 'item_name' => __( 'Feature', 'so-widgets-bundle' ), 'item_label' => array( 'selector' => "[id*='features-title']", 'update_event' => 'change', 'value_method' => 'val' ), 'fields' => array(
// The container shape
'container_color' => array( 'type' => 'color', 'label' => __( 'Icon container color', 'so-widgets-bundle' ), 'default' => '#404040', ),
'container_position' => array( 'type' => 'select', 'label' => __( 'Icon container position', 'so-widgets-bundle' ), 'options' => array( 'top' => __( 'Top', 'so-widgets-bundle' ), 'right' => __( 'Right', 'so-widgets-bundle' ), 'bottom' => __( 'Bottom', 'so-widgets-bundle' ), 'left' => __( 'Left', 'so-widgets-bundle' ), ), 'default' => 'top', ),
// The Icon
'icon' => array( 'type' => 'icon', 'label' => __( 'Icon', 'so-widgets-bundle' ), ),
'icon_title' => array( 'type' => 'text', 'label' => __( 'Icon title', 'so-widgets-bundle' ), ),
'icon_color' => array( 'type' => 'color', 'label' => __( 'Icon color', 'so-widgets-bundle' ), 'default' => '#FFFFFF', ),
'icon_image' => array( 'type' => 'media', 'library' => 'image', 'label' => __( 'Icon image', 'so-widgets-bundle' ), 'description' => __( 'Use your own icon image.', 'so-widgets-bundle' ), ),
'icon_image_size' => array( 'type' => 'image-size', 'label' => __( 'Icon image size', 'so-widgets-bundle' ), ),
// The text under the icon
'title' => array( 'type' => 'text', 'label' => __( 'Title text', 'so-widgets-bundle' ), ),
'text' => array( 'type' => 'tinymce', 'label' => __( 'Text', 'so-widgets-bundle' ) ),
'more_text' => array( 'type' => 'text', 'label' => __( 'More link text', 'so-widgets-bundle' ), ),
'more_url' => array( 'type' => 'link', 'label' => __( 'More link URL', 'so-widgets-bundle' ), ), ), ),
'fonts' => array( 'type' => 'section', 'label' => __( 'Font Design', 'so-widgets-bundle' ), 'hide' => true, 'fields' => array( 'title_options' => array( 'type' => 'section', 'label' => __( 'Title', 'so-widgets-bundle' ), 'hide' => true, 'fields' => array( 'font' => array( 'type' => 'font', 'label' => __( 'Font', 'so-widgets-bundle' ), 'default' => 'default' ), 'size' => array( 'type' => 'measurement', 'label' => __( 'Size', 'so-widgets-bundle' ), ), 'color' => array( 'type' => 'color', 'label' => __( 'Color', 'so-widgets-bundle' ), ) ) ),
'text_options' => array( 'type' => 'section', 'label' => __( 'Text', 'so-widgets-bundle' ), 'hide' => true, 'fields' => array( 'font' => array( 'type' => 'font', 'label' => __( 'Font', 'so-widgets-bundle' ), 'default' => 'default' ), 'size' => array( 'type' => 'measurement', 'label' => __( 'Size', 'so-widgets-bundle' ), ), 'color' => array( 'type' => 'color', 'label' => __( 'Color', 'so-widgets-bundle' ), ) ) ),
'more_text_options' => array( 'type' => 'section', 'label' => __( 'More Link', 'so-widgets-bundle' ), 'hide' => true, 'fields' => array( 'font' => array( 'type' => 'font', 'label' => __( 'Font', 'so-widgets-bundle' ), 'default' => 'default' ), 'size' => array( 'type' => 'measurement', 'label' => __( 'Size', 'so-widgets-bundle' ), ), 'color' => array( 'type' => 'color', 'label' => __( 'Color', 'so-widgets-bundle' ), ) ) ), ), ),
'container_shape' => array( 'type' => 'select', 'label' => __( 'Icon container shape', 'so-widgets-bundle' ), 'default' => 'round', 'options' => include dirname( __FILE__ ) . '/inc/containers.php', ),
'container_size' => array( 'type' => 'measurement', 'label' => __( 'Icon container size', 'so-widgets-bundle' ), 'default' => '84px', ),
'icon_size' => array( 'type' => 'measurement', 'label' => __( 'Icon size', 'so-widgets-bundle' ), 'default' => '24px', ),
'icon_size_custom' => array( 'type' => 'checkbox', 'label' => __( 'Use icon size for custom icon', 'so-widgets-bundle' ), 'default' => false, ),
'per_row' => array( 'type' => 'number', 'label' => __( 'Features per row', 'so-widgets-bundle' ), 'default' => 3, ),
'responsive' => array( 'type' => 'checkbox', 'label' => __( 'Responsive layout', 'so-widgets-bundle' ), 'default' => true, ),
'title_link' => array( 'type' => 'checkbox', 'label' => __( 'Link feature title to more URL', 'so-widgets-bundle' ), 'default' => false, ),
'icon_link' => array( 'type' => 'checkbox', 'label' => __( 'Link icon to more URL', 'so-widgets-bundle' ), 'default' => false, ),
'new_window' => array( 'type' => 'checkbox', 'label' => __( 'Open more URL in a new window', 'so-widgets-bundle' ), 'default' => false, ),
); }
function get_less_variables( $instance ) { $less_vars = array();
if ( empty( $instance ) ) { return $less_vars; }
$fonts = $instance['fonts']; $styleable_text_fields = array( 'title', 'text', 'more_text' );
foreach ( $styleable_text_fields as $field_name ) {
if ( ! empty( $fonts[$field_name.'_options'] ) ) { $styles = $fonts[$field_name.'_options']; if ( ! empty( $styles['size'] ) ) { $less_vars[$field_name.'_size'] = $styles['size']; } if ( ! empty( $styles['color'] ) ) { $less_vars[$field_name.'_color'] = $styles['color']; } if ( ! empty( $styles['font'] ) ) { $font = siteorigin_widget_get_font( $styles['font'] ); $less_vars[$field_name.'_font'] = $font['family']; if ( ! empty( $font['weight'] ) ) { $less_vars[$field_name.'_font_weight'] = $font['weight']; } } } }
$less_vars['container_size'] = $instance['container_size']; $less_vars['icon_size'] = $instance['icon_size']; $less_vars['per_row'] = $instance['per_row']; $less_vars['use_icon_size'] = empty( $instance['icon_size_custom'] ) ? 'false' : 'true';
$global_settings = $this->get_global_settings();
if ( ! empty( $global_settings['responsive_breakpoint'] ) ) { $less_vars['responsive_breakpoint'] = $global_settings['responsive_breakpoint']; }
return $less_vars; }
function get_settings_form() { return array( 'responsive_breakpoint' => array( 'type' => 'measurement', 'label' => __( 'Responsive Breakpoint', 'so-widgets-bundle' ), 'default' => '520px', 'description' => __( 'This setting controls when the features widget will collapse for mobile devices. The default value is 520px', 'so-widgets-bundle' ) ) ); }
function get_google_font_fields( $instance ) {
$fonts = $instance['fonts'];
return array( $fonts['title_options']['font'], $fonts['text_options']['font'], $fonts['more_text_options']['font'], ); } }
siteorigin_widget_register('sow-features', __FILE__, 'SiteOrigin_Widget_Features_Widget');
|