/var/www/hkosl.com/aga/wp-content/plugins/so-widgets-bundle/widgets/testimonial/testimonial.php


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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
/*
Widget Name: Testimonials
Description: Display some testimonials.
Author: SiteOrigin
Author URI: https://siteorigin.com
Documentation: https://siteorigin.com/widgets-bundle/testimonials-widget/
*/

class SiteOrigin_Widgets_Testimonials_Widget extends SiteOrigin_Widget {

    function 
__construct() {
        
parent::__construct(
            
'sow-testimonials',
            
__('SiteOrigin Testimonials''so-widgets-bundle'),
            array(
                
'description' => __('Share your product/service testimonials in a variety of different ways.''so-widgets-bundle'),
                
'help' => 'https://siteorigin.com/widgets-bundle/testimonial-widget-documentation/'
            
),
            array(

            ),
            
false,
            
plugin_dir_path__FILE__ )
        );
    }

    function 
initialize(){
        
$this->register_frontend_styles( array(
            array(
                
'sow-testimonial',
                
plugin_dir_url(__FILE__) . 'css/style.css'
            
)
        ) );
    }

    function 
get_widget_form(){
        return array(
            
'title' => array(
                
'type' => 'text',
                
'label' => __('Title''so-widgets-bundle'),
            ),
            
'testimonials' => array(
                
'type' => 'repeater',
                
'label' => __'Testimonials''so-widgets-bundle' ),
                
'item_name'  => __'Testimonial''so-widgets-bundle' ),
                
'item_label' => array(
                    
'selector'     => "[id*='testimonials-name']",
                    
'update_event' => 'change',
                    
'value_method' => 'val'
                
),
                
'fields' => array(
                    
'name' => array(
                        
'type' => 'text',
                        
'label' => __('Name''so-widgets-bundle'),
                        
'description' => __('The author of the testimonial''so-widgets-bundle'),
                    ),

                    
'link_name' => array(
                        
'type' => 'checkbox',
                        
'label' => __('Link name''so-widgets-bundle'),
                    ),

                    
'location' => array(
                        
'type' => 'text',
                        
'label' => __('Location''so-widgets-bundle'),
                        
'description' => __('Their location or company name''so-widgets-bundle'),
                    ),

                    
'image' => array(
                        
'type' => 'media',
                        
'label' => __('Image''so-widgets-bundle'),
                    ),

                    
'link_image' => array(
                        
'type' => 'checkbox',
                        
'label' => __('Link image''so-widgets-bundle'),
                    ),

                    
'text' => array(
                        
'type' => 'tinymce',
                        
'label' => __('Text''so-widgets-bundle'),
                        
'description' => __('What your customer had to say''so-widgets-bundle'),
                    ),

                    
'url' => array(
                        
'type' => 'text',
                        
'label' => __('URL''so-widgets-bundle'),
                    ),

                    
'new_window' => array(
                        
'type' => 'checkbox',
                        
'label' => __('Open In New Window''so-widgets-bundle'),
                    ),
                )
            ),

            
'settings' => array(
                
'type' => 'section',
                
'label' => __('Settings''so-widgets-bundle'),
                
'fields' => array(

                    
'per_line' => array(
                        
'type' => 'slider',
                        
'label' => __'Testimonials per row''so-widgets-bundle' ),
                        
'min' => 1,
                        
'max' => 5,
                        
'integer' => true,
                        
'default' => 3
                    
),

                    
'responsive' => array(
                        
'type' => 'section',
                        
'label' => __('Responsive''so-widgets-bundle'),
                        
'hide' => true,
                        
'fields' => array(
                            
'tablet' => array(
                                
'type' => 'section',
                                
'label' => __('Tablet''so-widgets-bundle'),
                                
'fields' => array(
                                    
'per_line' => array(
                                        
'type' => 'slider',
                                        
'label' => __'Testimonials per row''so-widgets-bundle' ),
                                        
'min' => 1,
                                        
'max' => 5,
                                        
'integer' => true,
                                        
'default' => 2
                                    
),
                                    
'image_size' => array(
                                        
'type' => 'slider',
                                        
'label' => __'Image size''so-widgets-bundle' ),
                                        
'integer' => true,
                                        
'default' => 50,
                                        
'max' => 150,
                                        
'min' => 20,
                                    ),
                                    
'width' => array(
                                        
'type' => 'text',
                                        
'label' => __'Resolution''so-widgets-bundle' ),
                                        
'description' => __'The resolution to treat as a tablet resolution.''so-widgets-bundle' ),
                                        
'default' => 800,
                                        
'sanitize' => 'intval',
                                    )
                                )
                            ),
                            
'mobile' => array(
                                
'type' => 'section',
                                
'label' => __('Mobile Phone''so-widgets-bundle'),
                                
'fields' => array(
                                    
'per_line' => array(
                                        
'type' => 'slider',
                                        
'label' => __'Testimonials per row''so-widgets-bundle' ),
                                        
'min' => 1,
                                        
'max' => 5,
                                        
'integer' => true,
                                        
'default' => 1
                                    
),
                                    
'image_size' => array(
                                        
'type' => 'slider',
                                        
'label' => __'Image size''so-widgets-bundle' ),
                                        
'integer' => true,
                                        
'default' => 50,
                                        
'max' => 150,
                                        
'min' => 20,
                                    ),
                                    
'width' => array(
                                        
'type' => 'text',
                                        
'label' => __'Resolution''so-widgets-bundle' ),
                                        
'description' => __'The resolution to treat as a mobile resolution.''so-widgets-bundle' ),
                                        
'default' => 480,
                                        
'sanitize' => 'intval',
                                    )
                                )
                            )

                        )
                    ),
                )
            ),

            
'design' => array(
                
'type' => 'section',
                
'label' => __('Design''so-widgets-bundle'),
                
'fields' => array(

                    
'image' => array(
                        
'type' => 'section',
                        
'label' => __('Image''so-widgets-bundle'),
                        
'fields' => array(
                            
'image_shape' => array(
                                
'type' => 'select',
                                
'label' => __('Testimonial image shape''so-widgets-bundle'),
                                
'options' => array(
                                    
'square' => __('Square''so-widgets-bundle'),
                                    
'round' => __('Round''so-widgets-bundle'),
                                ),
                                
'default' => 'square',
                            ),

                            
'image_size' => array(
                                
'type' => 'slider',
                                
'label' => __('Image size''so-widgets-bundle'),
                                
'integer' => true,
                                
'default' => 50,
                                
'max' => 150,
                                
'min' => 20,
                            ),
                        ),
                    ),

                    
'colors' => array(
                        
'type' => 'section',
                        
'label' => __('Colors''so-widgets-bundle'),
                        
'fields' => array(
                            
'testimonial_background' => array(
                                
'type' => 'color',
                                
'label' => __('Widget Background''so-widgets-bundle'),
                            ),
                            
'text_background' => array(
                                
'type' => 'color',
                                
'label' => __('Text Background''so-widgets-bundle'),
                                
'default' => '#f0f0f0',
                            ),
                            
'text_color' => array(
                                
'type' => 'color',
                                
'label' => __('Text Color''so-widgets-bundle'),
                                
'default' => '#444444',
                            ),
                        ),
                    ),

                    
'padding' => array(
                        
'type' => 'slider',
                        
'label' => __('Padding''so-widgets-bundle'),
                        
'integer' => true,
                        
'default' => 10,
                        
'max' => 100,
                        
'min' => 0,
                    ),

                    
'border_radius' => array(
                        
'type' => 'slider',
                        
'label' => __'Testimonial Radius''so-widgets-bundle' ),
                        
'integer' => true,
                        
'default' => 4,
                        
'max' => 100,
                        
'min' => 0,
                    ),

                    
'user_position' => array(
                        
'type' => 'select',
                        
'label' => __('User position''so-widgets-bundle'),
                        
'options' => array(
                            
'left' => __('Left''so-widgets-bundle'),
                            
'right' => __('Right''so-widgets-bundle'),
                            
'middle' => __('Middle''so-widgets-bundle'),
                        ),
                        
'default' => 'left',
                    ),

                    
'layout' => array(
                        
'type' => 'select',
                        
'label' => __('Testimonial layout''so-widgets-bundle'),
                        
'options' => array(
                            
'side' => __('Side by side''so-widgets-bundle'),
                            
'text_above' => __('Text above user''so-widgets-bundle'),
                            
'text_below' => __('Text below user''so-widgets-bundle'),
                        ),
                        
'default' => 'side',
                    ),
                ),
            ),
        );
    }

    function 
caret_svg(){
        static 
$done false;
        if( 
$done ) return;

        
?>
        <svg style="position: absolute; width: 0; height: 0;" width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
            <defs>
                <symbol id="icon-caret-down" viewBox="0 0 585 1024">
                    <title>caret-down</title>
                    <path class="path1" d="M585.143 402.286q0 14.857-10.857 25.714l-256 256q-10.857 10.857-25.714 10.857t-25.714-10.857l-256-256q-10.857-10.857-10.857-25.714t10.857-25.714 25.714-10.857h512q14.857 0 25.714 10.857t10.857 25.714z"></path>
                </symbol>
                <symbol id="icon-caret-up" viewBox="0 0 585 1024">
                    <title>caret-up</title>
                    <path class="path1" d="M585.143 694.857q0 14.857-10.857 25.714t-25.714 10.857h-512q-14.857 0-25.714-10.857t-10.857-25.714 10.857-25.714l256-256q10.857-10.857 25.714-10.857t25.714 10.857l256 256q10.857 10.857 10.857 25.714z"></path>
                </symbol>
                <symbol id="icon-caret-left" viewBox="0 0 366 1024">
                    <title>caret-left</title>
                    <path class="path1" d="M365.714 256v512q0 14.857-10.857 25.714t-25.714 10.857-25.714-10.857l-256-256q-10.857-10.857-10.857-25.714t10.857-25.714l256-256q10.857-10.857 25.714-10.857t25.714 10.857 10.857 25.714z"></path>
                </symbol>
                <symbol id="icon-caret-right" viewBox="0 0 366 1024">
                    <title>caret-right</title>
                    <path class="path1" d="M329.143 512q0 14.857-10.857 25.714l-256 256q-10.857 10.857-25.714 10.857t-25.714-10.857-10.857-25.714v-512q0-14.857 10.857-25.714t25.714-10.857 25.714 10.857l256 256q10.857 10.857 10.857 25.714z"></path>
                </symbol>
            </defs>
        </svg>
        <?php
        $done 
true;
    }

    function 
get_less_variables$instance ){
        if ( empty( 
$instance ) ) {
            return array();
        }
        return array (
            
'image_size' => intval($instance['design']['image']['image_size']) . 'px',
            
'testimonial_size' => round(100/$instance['settings']['per_line'], 4) . '%',
            
'testimonial_padding' => intval($instance['design']['padding']) . 'px',
            
'testimonial_background' => $instance['design']['colors']['testimonial_background'],

            
// The text block
            
'text_border_radius' => intval($instance['design']['border_radius']) . 'px',
            
'text_background' => $instance['design']['colors']['text_background'],
            
'text_color' => $instance['design']['colors']['text_color'],

            
// All the responsive sizes
            
'tablet_testimonial_size' => round(100/$instance['settings']['responsive']['tablet']['per_line'], 4) . '%',
            
'tablet_image_size' => intval$instance['settings']['responsive']['tablet']['image_size'] ) . 'px',
            
'tablet_width' => intval($instance['settings']['responsive']['tablet']['width']) . 'px',
            
'mobile_testimonial_size' => round(100/$instance['settings']['responsive']['mobile']['per_line'], 4) . '%',
            
'mobile_image_size' => intval$instance['settings']['responsive']['mobile']['image_size'] ) . 'px',
            
'mobile_width' => intval($instance['settings']['responsive']['mobile']['width']) . 'px',
        );
    }

    function 
get_template_variables$instance$args ){
        return array(
            
'testimonials' => !empty($instance['testimonials']) ? $instance['testimonials'] : array(),
            
'settings' => $instance['settings'],
            
'design' => $instance['design'],
        );
    }

    function 
testimonial_user_image$image_id$design ){
        if ( ! empty( 
$image_id ) ) {
            if( 
$design['image']['image_shape'] == 'square') {
                return 
wp_get_attachment_image$image_id, array( $design['image']['image_size'], $design['image']['image_size'] ), false, array(
                    
'class' => 'sow-image-shape-' $design['image']['image_shape'],
                ) );
            }
            else {
                
$src wp_get_attachment_image_src$image_id, array( $design['image']['image_size'], $design['image']['image_size'] ) );
                return 
'<div class="sow-round-image-frame" style="background-image: url(' esc_url$src[0] ) . ');"></div>';
            }
        }
    }

    function 
testimonial_pointer$design ){

    }

    function 
testimonial_wrapper_class($design){
        
$classes = array();
        
$classes[] = 'sow-user-' sanitize_html_class$design['user_position'] );
        
$classes[] = 'sow-layout-' sanitize_html_class$design['layout'] );
        return 
str_replace'_''-'implode' '$classes ) );
    }

    function 
get_form_teaser(){
        if( 
class_exists'SiteOrigin_Premium' ) ) return false;
        return 
sprintf(
            
__'Get more font customization options with %sSiteOrigin Premium%s''so-widgets-bundle' ),
            
'<a href="https://siteorigin.com/downloads/premium/?featured_addon=plugin/testimonial" target="_blank" rel="noopener noreferrer">',
            
'</a>'
        
);
    }
}

siteorigin_widget_register'sow-testimonials'__FILE__'SiteOrigin_Widgets_Testimonials_Widget' );