PluginProbe ʕ •ᴥ•ʔ
Rich Showcase for Google Reviews / 3.1
Rich Showcase for Google Reviews v3.1
6.9.8 6.9.7 6.9.6 trunk 1.4 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.5 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.7 1.6.8 1.6.9 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.4 2.4.1 2.4.2 2.5 2.5.1 2.6 2.6.1 2.6.2 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.6.1 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.8.1 4.8.2 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.7.1 5.8 5.9 5.9.1 5.9.2 5.9.3 5.9.7 6.0 6.1 6.2 6.3 6.4 6.4.1 6.5 6.6 6.6.1 6.6.2 6.7 6.8 6.8.1 6.8.2 6.9 6.9.1 6.9.2 6.9.3 6.9.4 6.9.4.1 6.9.4.2 6.9.4.3 6.9.4.4 6.9.5
widget-google-reviews / includes / class-view.php
widget-google-reviews / includes Last commit date
admin 2 years ago core 2 years ago class-activator.php 3 years ago class-assets.php 2 years ago class-builder-page.php 3 years ago class-deactivator.php 3 years ago class-debug-info.php 2 years ago class-feed-ajax.php 2 years ago class-feed-block.php 2 years ago class-feed-deserializer.php 2 years ago class-feed-old.php 4 years ago class-feed-page.php 3 years ago class-feed-serializer.php 3 years ago class-feed-shortcode.php 3 years ago class-feed-widget.php 4 years ago class-plugin-overview-ajax.php 3 years ago class-plugin-overview.php 3 years ago class-plugin-settings.php 2 years ago class-plugin-support.php 3 years ago class-plugin.php 2 years ago class-post-types.php 3 years ago class-reviews-cron.php 2 years ago class-settings-save.php 3 years ago class-view.php 2 years ago index.php 4 years ago page-setting-fig.php 3 years ago page-setting-support.php 4 years ago
class-view.php
491 lines
1 <?php
2
3 namespace WP_Rplg_Google_Reviews\Includes;
4
5 class View {
6
7 public function render($feed_id, $businesses, $reviews, $options, $is_admin = false) {
8 ob_start();
9
10 if ($options->lazy_load_img) {
11 wp_enqueue_script('blazy-js');
12 }
13
14 $max_width = $options->max_width;
15 if (is_numeric($max_width)) {
16 $max_width = $max_width . 'px';
17 }
18 $max_height = $options->max_height;
19 if (is_numeric($max_height)) {
20 $max_height = $max_height . 'px';
21 }
22
23 $style = '';
24 if (isset($max_width) && strlen($max_width) > 0) {
25 $style .= 'width:' . $max_width . '!important;';
26 }
27 if (isset($max_height) && strlen($max_height) > 0) {
28 $style .= 'height:' . $max_height . '!important;overflow-y:auto!important;';
29 }
30 if ($options->centered) {
31 $style .= 'margin:0 auto!important;';
32 }
33
34 ?>
35 <div class="wp-gr wpac<?php if ($options->dark_theme) { ?> wp-dark<?php } ?>"<?php if ($style) { ?> style="<?php echo $style;?>"<?php } ?> data-id="<?php echo $feed_id; ?>" data-layout="<?php echo $options->view_mode; ?>" data-exec="false">
36 <?php
37 switch ($options->view_mode) {
38 case 'slider':
39 $this->render_slider($businesses, $reviews, $options, $is_admin);
40 break;
41 case 'grid':
42 $this->render_grid($businesses, $reviews, $options, $is_admin);
43 break;
44 case 'list':
45 $this->render_list($businesses, $reviews, $options, $is_admin);
46 break;
47 case 'badge':
48 $this->render_badge($businesses, $reviews, $options);
49 break;
50 default:
51 $this->render_list($businesses, $reviews, $options, $is_admin);
52 }
53 ?>
54 </div>
55 <?php
56 return preg_replace('/[\n\r]|(>)\s+(<)/', '$1$2', ob_get_clean());
57 }
58
59 private function render_slider($businesses, $reviews, $options, $is_admin = false) {
60 ?>
61 <div class="grw-row grw-row-m" data-options='<?php
62 echo json_encode(
63 array(
64 'speed' => $options->slider_speed ? $options->slider_speed : 5,
65 'autoplay' => $options->slider_autoplay
66 )
67 ); ?>'>
68 <?php if (count($businesses) > 0) { ?>
69 <div class="grw-header">
70 <div class="grw-header-inner">
71 <div class="wp-google-place<?php if ($options->header_center) { ?> wp-place-center<?php } ?>">
72 <?php $this->grw_place(
73 $businesses[0]->rating,
74 $businesses[0],
75 $businesses[0]->photo,
76 $reviews,
77 $options,
78 true,
79 true
80 ); ?>
81 </div>
82 </div>
83 </div>
84 <?php }
85 if (count($reviews) > 0) { ?>
86 <div class="grw-content">
87 <div class="grw-content-inner">
88 <div class="grw-reviews">
89 <?php foreach ($reviews as $review) { $this->grw_slider_review($review, false, $options, $is_admin); } ?>
90 </div>
91 <?php if (!$options->slider_hide_prevnext) { ?>
92 <div class="grw-controls">
93 <div class="grw-btns grw-prev">
94 <svg viewBox="0 0 24 24"><path d="M14.6,18.4L8.3,12l6.4-6.4l0.7,0.7L9.7,12l5.6,5.6L14.6,18.4z"></path></svg>
95 </div>
96 <div class="grw-btns grw-next">
97 <svg viewBox="0 0 24 24"><path d="M9.4,18.4l-0.7-0.7l5.6-5.6L8.6,6.4l0.7-0.7l6.4,6.4L9.4,18.4z"></path></svg>
98 </div>
99 </div>
100 <?php } ?>
101 </div>
102 <?php if (!$options->slider_hide_dots) { ?><div class="grw-dots"></div><?php } ?>
103 </div>
104 <?php } ?>
105 </div>
106 <?php $this->js_loader('grw_init', '\'slider\'');
107 }
108
109 private function render_grid($businesses, $reviews, $options, $is_admin = false) {
110 if (count($businesses) > 0) { ?>
111 <div class="grw-header">
112 <div class="grw-header-inner">
113 <div class="wp-google-place<?php if ($options->header_center) { ?> wp-place-center<?php } ?>">
114 <?php $this->grw_place(
115 $businesses[0]->rating,
116 $businesses[0],
117 $businesses[0]->photo,
118 $reviews,
119 $options,
120 true,
121 true
122 ); ?>
123 </div>
124 </div>
125 </div>
126 <?php } ?>
127 <div class="grw-row grw-row-m" data-options='<?php
128 echo json_encode(
129 array(
130 'speed' => $options->slider_speed ? $options->slider_speed : 5,
131 'autoplay' => $options->slider_autoplay
132 )
133 ); ?>'>
134 <?php if (count($reviews) > 0) { ?>
135 <div class="grw-content">
136 <div class="grw-content-inner">
137 <div class="grw-reviews">
138 <?php
139 $hr = false;
140 if (count($reviews) > 0) {
141 $i = 0;
142 foreach ($reviews as $review) {
143 if ($options->pagination > 0 && $options->pagination <= $i++) {
144 $hr = true;
145 }
146 $this->grw_slider_review($review, $hr, $options, $is_admin);
147 }
148 }
149 ?>
150 </div>
151 <?php if ($options->pagination > 0 && $hr) { ?>
152 <a class="wp-google-url" href="#" onclick="return rplg_next_reviews.call(this, 'grw', <?php echo $options->pagination; ?>);">
153 <?php echo __('Next Reviews', 'widget-google-reviews'); ?>
154 </a>
155 <?php } ?>
156 </div>
157 </div>
158 <?php } ?>
159 </div>
160 <?php $this->js_loader('grw_init', '\'grid\'');
161 }
162
163 private function render_list($businesses, $reviews, $options, $is_admin = false) {
164 ?>
165 <div class="wp-google-list">
166 <?php foreach ($businesses as $business) { ?>
167 <div class="wp-google-place<?php if ($options->header_center) { ?> wp-place-center<?php } ?>">
168 <?php $this->grw_place(
169 $business->rating,
170 $business,
171 $business->photo,
172 $reviews,
173 $options
174 ); ?>
175 </div>
176 <?php }
177 if (!$options->hide_reviews) { ?>
178 <div class="wp-google-content-inner">
179 <?php $this->grw_place_reviews($reviews, $options, $is_admin); ?>
180 </div>
181 <?php } ?>
182 </div>
183 <?php $this->js_loader('grw_init');
184 }
185
186 private function render_badge($businesses, $reviews, $options) {
187 ?>
188 <script type="text/javascript">
189 function grw_badge_init(el) {
190 var btn = el.querySelector('.wp-google-badge'),
191 form = el.querySelector('.wp-google-form');
192
193 var wpac = document.createElement('div');
194 wpac.className = 'wp-gr wpac';
195 wpac.appendChild(form);
196 document.body.appendChild(wpac);
197
198 btn.onclick = function() {
199 form.style.display='block';
200 };
201 }
202 </script>
203 <?php foreach ($businesses as $business) { ?>
204 <div class="wp-google-badge<?php if ($options->view_mode == 'badge') { ?> wp-google-badge-fixed<?php } ?>">
205 <div class="wp-google-border"></div>
206 <div class="wp-google-badge-btn">
207 <svg viewBox="0 0 512 512" height="44" width="44"><g fill="none" fill-rule="evenodd"><path d="M482.56 261.36c0-16.73-1.5-32.83-4.29-48.27H256v91.29h127.01c-5.47 29.5-22.1 54.49-47.09 71.23v59.21h76.27c44.63-41.09 70.37-101.59 70.37-173.46z" fill="#4285f4"/><path d="M256 492c63.72 0 117.14-21.13 156.19-57.18l-76.27-59.21c-21.13 14.16-48.17 22.53-79.92 22.53-61.47 0-113.49-41.51-132.05-97.3H45.1v61.15c38.83 77.13 118.64 130.01 210.9 130.01z" fill="#34a853"/><path d="M123.95 300.84c-4.72-14.16-7.4-29.29-7.4-44.84s2.68-30.68 7.4-44.84V150.01H45.1C29.12 181.87 20 217.92 20 256c0 38.08 9.12 74.13 25.1 105.99l78.85-61.15z" fill="#fbbc05"/><path d="M256 113.86c34.65 0 65.76 11.91 90.22 35.29l67.69-67.69C373.03 43.39 319.61 20 256 20c-92.25 0-172.07 52.89-210.9 130.01l78.85 61.15c18.56-55.78 70.59-97.3 132.05-97.3z" fill="#ea4335"/><path d="M20 20h472v472H20V20z"/></g></svg>
208 <div class="wp-google-badge-score">
209 <div><?php echo __('Google Rating', 'widget-google-reviews'); ?></div>
210 <span class="wp-google-rating"><?php echo $business->rating; ?></span>
211 <span class="wp-google-stars"><?php $this->grw_stars($business->rating); ?></span>
212 </div>
213 </div>
214 </div>
215 <?php } ?>
216 <div class="wp-google-form" style="display:none">
217 <?php foreach ($businesses as $business) { ?>
218 <div class="wp-google-head">
219 <div class="wp-google-head-inner">
220 <?php
221 $this->grw_place(
222 $business->rating,
223 $business,
224 $business->photo,
225 $reviews,
226 $options,
227 false
228 ); ?>
229 </div>
230 <button class="wp-google-close" type="button" onclick="this.parentNode.parentNode.style.display='none'">×</button>
231 </div>
232 <?php } ?>
233 <div class="wp-google-body"></div>
234 <div class="wp-google-content">
235 <div class="wp-google-content-inner">
236 <?php $this->grw_place_reviews($reviews, $options); ?>
237 </div>
238 </div>
239 <div class="wp-google-footer">
240 <img src="<?php echo GRW_ASSETS_URL; ?>img/powered_by_google_on_<?php if ($options->dark_theme) { ?>non_<?php } ?>white.png" alt="powered by Google" width="144" height="18" title="powered by Google">
241 </div>
242 </div>
243 <?php $this->js_loader('grw_badge_init');
244 }
245
246 function grw_place($rating, $place, $place_img, $reviews, $options, $show_powered = true, $show_writereview = false) {
247 ?>
248 <?php if (!$options->header_hide_photo) { ?>
249 <div class="wp-google-left">
250 <img src="<?php echo $place_img; ?>" alt="<?php echo $place->name; ?>" width="50" height="50" title="<?php echo $place->name; ?>">
251 </div>
252 <?php } ?>
253 <div class="wp-google-right">
254 <?php if (!$options->header_hide_name) { ?>
255 <div class="wp-google-name">
256 <?php $place_name_content = '<span>' . $place->name . '</span>';
257 echo $this->grw_anchor($place->url, '', $place_name_content, $options->open_link, $options->nofollow_link); ?>
258 </div>
259 <?php } ?>
260
261 <?php $this->grw_place_rating($rating, $place->review_count, $options->hide_based_on); ?>
262
263 <?php if ($show_powered) { ?>
264 <div class="wp-google-powered">
265 <img src="<?php echo GRW_ASSETS_URL; ?>img/powered_by_google_on_<?php if ($options->dark_theme) { ?>non_<?php } ?>white.png" alt="powered by Google" width="144" height="18" title="powered by Google">
266 </div>
267 <?php } ?>
268
269 <?php if (!$options->hide_writereview) { ?>
270 <div class="wp-google-wr">
271 <a href="https://search.google.com/local/writereview?placeid=<?php echo $place->id; ?>" onclick="return rplg_leave_review_window.call(this)"><?php echo __('review us on', 'widget-google-reviews'); ?><svg viewBox="0 0 512 512" height="18" width="18"><g fill="none" fill-rule="evenodd"><path d="M482.56 261.36c0-16.73-1.5-32.83-4.29-48.27H256v91.29h127.01c-5.47 29.5-22.1 54.49-47.09 71.23v59.21h76.27c44.63-41.09 70.37-101.59 70.37-173.46z" fill="#4285f4"/><path d="M256 492c63.72 0 117.14-21.13 156.19-57.18l-76.27-59.21c-21.13 14.16-48.17 22.53-79.92 22.53-61.47 0-113.49-41.51-132.05-97.3H45.1v61.15c38.83 77.13 118.64 130.01 210.9 130.01z" fill="#34a853"/><path d="M123.95 300.84c-4.72-14.16-7.4-29.29-7.4-44.84s2.68-30.68 7.4-44.84V150.01H45.1C29.12 181.87 20 217.92 20 256c0 38.08 9.12 74.13 25.1 105.99l78.85-61.15z" fill="#fbbc05"/><path d="M256 113.86c34.65 0 65.76 11.91 90.22 35.29l67.69-67.69C373.03 43.39 319.61 20 256 20c-92.25 0-172.07 52.89-210.9 130.01l78.85 61.15c18.56-55.78 70.59-97.3 132.05-97.3z" fill="#ea4335"/><path d="M20 20h472v472H20V20z"/></g></svg></a>
272 </div>
273 <?php } ?>
274 </div>
275 <?php
276 }
277
278 function grw_place_rating($rating, $review_count, $hide_based_on) {
279 ?>
280 <div>
281 <span class="wp-google-rating"><?php echo $rating; ?></span>
282 <span class="wp-google-stars"><?php $this->grw_stars($rating); ?></span>
283 </div>
284 <?php if (!$hide_based_on && isset($review_count)) { ?>
285 <div class="wp-google-powered"><?php echo vsprintf(__('Based on %s reviews', 'widget-google-reviews'), $this->grw_array($review_count)); ?></div>
286 <?php }
287 }
288
289 function grw_place_reviews($reviews, $options, $is_admin = false) {
290 ?>
291 <div class="wp-google-reviews">
292 <?php
293 $place_id = null;
294 $place_url = null;
295
296 $hr = false;
297 if (count($reviews) > 0) {
298 $i = 0;
299 foreach ($reviews as $review) {
300 if (!$place_id) {
301 $place_id = $review->biz_id;
302 $place_url = $review->biz_url;
303 }
304 if ($options->pagination > 0 && $options->pagination <= $i++) {
305 $hr = true;
306 }
307 $this->grw_place_review($review, $hr, $options, $is_admin);
308 }
309 }
310 ?>
311 </div>
312 <?php if ($options->pagination > 0 && $hr) { ?>
313 <a class="wp-google-url" href="#" onclick="return rplg_next_reviews.call(this, 'wp-google', <?php echo $options->pagination; ?>);">
314 <?php echo __('Next Reviews', 'widget-google-reviews'); ?>
315 </a>
316 <?php
317 } else {
318 $reviews_link = $options->google_def_rev_link ? $place_url : 'https://search.google.com/local/reviews?placeid=' . $place_id;
319 $this->grw_anchor($reviews_link, 'wp-google-url', __('See All Reviews', 'widget-google-reviews'), $options->open_link, $options->nofollow_link);
320 }
321 }
322
323 function grw_place_review($review, $hr, $options, $is_admin = false) {
324 ?>
325 <div class="wp-google-review<?php if ($hr) { echo ' wp-google-hide'; } if ($is_admin && $review->hide != '') { echo ' wp-review-hidden'; } ?>">
326 <?php if (!$options->hide_avatar) { ?>
327 <div class="wp-google-left">
328 <?php
329 $default_avatar = GRW_ASSETS_URL . 'img/guest.png';
330 if (strlen($review->author_avatar) > 0) {
331 $author_avatar = $review->author_avatar;
332 } else {
333 $author_avatar = $default_avatar;
334 }
335 if (isset($options->reviewer_avatar_size)) {
336 $author_avatar = str_replace('s128', 's' . $options->reviewer_avatar_size, $author_avatar);
337 $default_avatar = str_replace('s128', 's' . $options->reviewer_avatar_size, $default_avatar);
338 }
339 $this->grw_image($author_avatar, $review->author_name, $options->lazy_load_img, $default_avatar);
340 ?>
341 </div>
342 <?php } ?>
343 <div class="wp-google-right">
344 <?php
345 if (strlen($review->author_url) > 0) {
346 $this->grw_anchor($review->author_url, 'wp-google-name', $review->author_name, $options->open_link, $options->nofollow_link);
347 } else {
348 if (strlen($review->author_name) > 0) {
349 $author_name = $review->author_name;
350 } else {
351 $author_name = __('Google User', 'widget-google-reviews');
352 }
353 ?><div class="wp-google-name"><?php echo $author_name; ?></div><?php
354 }
355 ?>
356 <div class="wp-google-time" data-time="<?php echo $review->time; ?>"><?php echo gmdate("H:i d M y", $review->time); ?></div>
357 <div class="wp-google-feedback">
358 <span class="wp-google-stars"><?php echo $this->grw_stars($review->rating); ?></span>
359 <span class="wp-google-text"><?php echo $this->grw_trim_text($review->text, $options->text_size); ?></span>
360 </div>
361 <?php if ($is_admin) {
362 echo '<a href="#" class="wp-review-hide" data-id=' . $review->id . '>' . ($review->hide == '' ? 'Hide' : 'Show') . ' review</a>';
363 } ?>
364 </div>
365 </div>
366 <?php
367 }
368
369 function grw_slider_review($review, $hr, $options, $is_admin = false) {
370 $addcls = $options->hide_backgnd ? "" : " grw-backgnd";
371 $addcls .= $options->show_round ? " grw-round" : "";
372 $addcls .= $options->show_shadow ? " grw-shadow" : "";
373 $addcls .= $is_admin && $review->hide != '' ? " wp-review-hidden" : "";
374 ?>
375 <div class="grw-review<?php if ($hr) { echo ' grw-hide'; } ?>">
376 <div class="grw-review-inner<?php echo $addcls; ?>">
377 <div class="wp-google-left">
378 <?php
379 // Google reviewer avatar
380 $default_avatar = GRW_ASSETS_URL . 'img/guest.png';
381 if (strlen($review->author_avatar) > 0) {
382 $author_avatar = $review->author_avatar;
383 } else {
384 $author_avatar = $default_avatar;
385 }
386 if (isset($options->reviewer_avatar_size)) {
387 $author_avatar = str_replace('s128', 's' . $options->reviewer_avatar_size, $author_avatar);
388 $default_avatar = str_replace('s128', 's' . $options->reviewer_avatar_size, $default_avatar);
389 }
390 $this->grw_image($author_avatar, $review->author_name, $options->lazy_load_img, $default_avatar);
391
392 // Google reviewer name
393 if (strlen($review->author_url) > 0) {
394 $this->grw_anchor($review->author_url, 'wp-google-name', $review->author_name, $options->open_link, $options->nofollow_link);
395 } else {
396 if (strlen($review->author_name) > 0) {
397 $author_name = $review->author_name;
398 } else {
399 $author_name = __('Google User', 'widget-google-reviews');
400 }
401 ?><div class="wp-google-name"><?php echo $author_name; ?></div><?php
402 }
403 ?>
404 <div class="wp-google-time" data-time="<?php echo $review->time; ?>"><?php echo gmdate("H:i d M y", $review->time); ?></div>
405 </div>
406 <div class="wp-google-stars"><?php echo $this->grw_stars($review->rating); ?></div>
407 <div>
408 <div class="wp-google-feedback" <?php if (strlen($options->slider_text_height) > 0) {?> style="height:<?php echo $options->slider_text_height; ?>!important"<?php } ?>>
409 <?php if (strlen($review->text) > 0) { ?>
410 <span class="wp-google-text"><?php echo $this->grw_trim_text($review->text, $options->text_size); ?></span>
411 <?php } ?>
412 </div>
413 <?php if ($is_admin) {
414 echo '<a href="#" class="wp-review-hide" data-id=' . $review->id . '>' . ($review->hide == '' ? 'Hide' : 'Show') . ' review</a>';
415 } ?>
416 </div>
417 <svg viewBox="0 0 512 512" height="18" width="18"><g fill="none" fill-rule="evenodd"><path d="M482.56 261.36c0-16.73-1.5-32.83-4.29-48.27H256v91.29h127.01c-5.47 29.5-22.1 54.49-47.09 71.23v59.21h76.27c44.63-41.09 70.37-101.59 70.37-173.46z" fill="#4285f4"/><path d="M256 492c63.72 0 117.14-21.13 156.19-57.18l-76.27-59.21c-21.13 14.16-48.17 22.53-79.92 22.53-61.47 0-113.49-41.51-132.05-97.3H45.1v61.15c38.83 77.13 118.64 130.01 210.9 130.01z" fill="#34a853"/><path d="M123.95 300.84c-4.72-14.16-7.4-29.29-7.4-44.84s2.68-30.68 7.4-44.84V150.01H45.1C29.12 181.87 20 217.92 20 256c0 38.08 9.12 74.13 25.1 105.99l78.85-61.15z" fill="#fbbc05"/><path d="M256 113.86c34.65 0 65.76 11.91 90.22 35.29l67.69-67.69C373.03 43.39 319.61 20 256 20c-92.25 0-172.07 52.89-210.9 130.01l78.85 61.15c18.56-55.78 70.59-97.3 132.05-97.3z" fill="#ea4335"/><path d="M20 20h472v472H20V20z"/></g></svg>
418 </div>
419 </div>
420 <?php
421 }
422
423 function grw_stars($rating) {
424 ?><span class="wp-stars"><?php
425 foreach (array(1,2,3,4,5) as $val) {
426 $score = $rating - $val;
427 if ($score >= 0) {
428 ?><span class="wp-star"><svg width="17" height="17" viewBox="0 0 1792 1792"><path d="M1728 647q0 22-26 48l-363 354 86 500q1 7 1 20 0 21-10.5 35.5t-30.5 14.5q-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#fb8e28"></path></svg></span><?php
429 } else if ($score > -1 && $score < 0) {
430 ?><span class="wp-star"><svg width="17" height="17" viewBox="0 0 1792 1792"><path d="M1250 957l257-250-356-52-66-10-30-60-159-322v963l59 31 318 168-60-355-12-66zm452-262l-363 354 86 500q5 33-6 51.5t-34 18.5q-17 0-40-12l-449-236-449 236q-23 12-40 12-23 0-34-18.5t-6-51.5l86-500-364-354q-32-32-23-59.5t54-34.5l502-73 225-455q20-41 49-41 28 0 49 41l225 455 502 73q45 7 54 34.5t-24 59.5z" fill="#fb8e28"></path></svg></span><?php
431 } else {
432 ?><span class="wp-star"><svg width="17" height="17" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#ccc"></path></svg></span><?php
433 }
434 }
435 ?></span><?php
436 }
437
438 function grw_anchor($url, $class, $text, $open_link, $nofollow_link) {
439 echo '<a href="' . $url . '"' . ($class ? ' class="' . $class . '"' : '') . ($open_link ? ' target="_blank"' : '') . ' rel="' . ($nofollow_link ? 'nofollow ' : '') . 'noopener">' . $text . '</a>';
440 }
441
442 function grw_image($src, $alt, $lazy, $def_ava = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', $atts = '') {
443 ?><img <?php if ($lazy) { ?>src="<?php echo $def_ava; ?>" data-<?php } ?>src="<?php echo $src; ?>" class="rplg-review-avatar<?php if ($lazy) { ?> rplg-blazy<?php } ?>" alt="<?php echo $alt; ?>" width="50" height="50" title="<?php echo $alt; ?>" onerror="if(this.src!='<?php echo $def_ava; ?>')this.src='<?php echo $def_ava; ?>';" <?php echo $atts; ?>><?php
444 }
445
446 function js_loader($func, $data = '') {
447 ?><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="js_loader" onload="(function(el, data) {var f = function() { window.<?php echo $func; ?> ? <?php echo $func; ?>(el, data) : setTimeout(f, 400) }; f() })(this<?php if (strlen($data) > 0) { ?>, <?php echo str_replace('"', '\'', $data); } ?>);" width="1" height="1" style="display:none"><?php
448 }
449
450 function grw_trim_text($text, $size) {
451 if ($size > 0 && $this->grw_strlen($text) > $size) {
452 $sub_text = $this->grw_substr($text, 0, $size);
453 $idx = $this->grw_strrpos($sub_text, ' ') + 1;
454
455 if ($idx < 1 || $size - $idx > ($size / 2)) {
456 $idx = $size;
457 }
458 if ($idx > 0) {
459 $visible_text = $this->grw_substr($text, 0, $idx - 1);
460 $invisible_text = $this->grw_substr($text, $idx - 1, $this->grw_strlen($text));
461 }
462 echo $visible_text;
463 if ($this->grw_strlen($invisible_text) > 0) {
464 ?><span>... </span><span class="wp-more"><?php echo $invisible_text; ?></span><span class="wp-more-toggle"><?php echo __('read more', 'widget-google-reviews'); ?></span><?php
465 }
466 } else {
467 echo $text;
468 }
469 }
470
471 function grw_strlen($str) {
472 return function_exists('mb_strlen') ? mb_strlen($str, 'UTF-8') : strlen($str);
473 }
474
475 function grw_strrpos($haystack, $needle, $offset = 0) {
476 return function_exists('mb_strrpos') ? mb_strrpos($haystack, $needle, $offset, 'UTF-8') : strrpos($haystack, $needle, $offset);
477 }
478
479 function grw_substr($str, $start, $length = NULL) {
480 return function_exists('mb_substr') ? mb_substr($str, $start, $length, 'UTF-8') : substr($str, $start, $length);
481 }
482
483 function grw_array($params=null) {
484 if (!is_array($params)) {
485 $params = func_get_args();
486 $params = array_slice($params, 0);
487 }
488 return $params;
489 }
490 }
491