Yasr – Yet Another Stars Rating - Version 2.3.5

Version Description

  • IMPROVED: is now possible to select between "Organization" or "Person" in "Rich snippet options". You may need to save again "Publisher name" and "Image Url"
  • IMPROVED: code cleanup
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 2.3.5
Comparing to
See all releases

Code changes from version 2.3.4 to 2.3.5

admin/classes/YasrOnInstall.php CHANGED
@@ -154,8 +154,9 @@ class YasrOnInstall {
154
  $option['custom_text_must_sign_in'] = __('You have already voted for this article', 'yet-another-stars-rating');
155
  $option['enable_ip'] = 'no';
156
  $option['snippet_itemtype'] = 'Product';
157
- $option['blogposting_organization_name'] = get_bloginfo('name');
158
- $option['blogposting_organization_logo'] = get_site_icon_url();
 
159
  $option['allowed_user'] = 'allow_anonymous';
160
  $option['visitors_stats'] = 'yes';
161
  $option['enable_ajax'] = 'no';
154
  $option['custom_text_must_sign_in'] = __('You have already voted for this article', 'yet-another-stars-rating');
155
  $option['enable_ip'] = 'no';
156
  $option['snippet_itemtype'] = 'Product';
157
+ $option['publisher'] = 'Organization';
158
+ $option['publisher_name'] = get_bloginfo('name');
159
+ $option['publisher_logo'] = get_site_icon_url();
160
  $option['allowed_user'] = 'allow_anonymous';
161
  $option['visitors_stats'] = 'yes';
162
  $option['enable_ajax'] = 'no';
admin/classes/YasrSettings.php CHANGED
@@ -77,8 +77,8 @@ class YasrSettings {
77
  }
78
 
79
  /**
80
- * @param string $option_title
81
- * @param array $array_options
82
  * @param string $name
83
  * @param string $class
84
  * @param bool | string | int $default_value
@@ -86,9 +86,14 @@ class YasrSettings {
86
  */
87
  public static function printRadioType($option_title, $array_options, $name, $class, $default_value=false, $id=false) {
88
 
89
- echo '<strong>' . $option_title . '</strong><br />';
 
 
90
 
91
  if(is_array($array_options)) {
 
 
 
92
  foreach ($array_options as $value => $label) {
93
  $id_string = $id . '-' . strtolower(trim(str_replace(' ', '', $value)));
94
  //must be inside foreach, or when loop arrive to last element
@@ -122,6 +127,8 @@ class YasrSettings {
122
  __(ucwords($label), 'yet-another-stars-rating'));
123
 
124
  } //end foreach
 
 
125
  }
126
  }
127
 
77
  }
78
 
79
  /**
80
+ * @param bool | string $option_title
81
+ * @param array $array_options
82
  * @param string $name
83
  * @param string $class
84
  * @param bool | string | int $default_value
86
  */
87
  public static function printRadioType($option_title, $array_options, $name, $class, $default_value=false, $id=false) {
88
 
89
+ if($option_title) {
90
+ echo '<strong>' . $option_title . '</strong><br />';
91
+ }
92
 
93
  if(is_array($array_options)) {
94
+
95
+ echo '<div class="yasr-indented-answer">';
96
+
97
  foreach ($array_options as $value => $label) {
98
  $id_string = $id . '-' . strtolower(trim(str_replace(' ', '', $value)));
99
  //must be inside foreach, or when loop arrive to last element
127
  __(ucwords($label), 'yet-another-stars-rating'));
128
 
129
  } //end foreach
130
+
131
+ echo '</div>';
132
  }
133
  }
134
 
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -117,7 +117,32 @@ function yasr_upgrade_pro_box( $position = false )
117
  <a href="<?php
118
  echo yasr_fs()->get_upgrade_url() ;
119
  ?>">
120
- <button class="button button-primary">Upgrade Now</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  </a>
122
  </div>
123
 
117
  <a href="<?php
118
  echo yasr_fs()->get_upgrade_url() ;
119
  ?>">
120
+ <button class="button button-primary">
121
+ <span style="font-size: large; font-weight: bold;">
122
+ <?php
123
+ _e( 'Upgrade Now', 'yet-another-stars-rating' );
124
+ ?>
125
+ </span>
126
+ </button>
127
+ </a>
128
+ <div style="display: block; margin-top: 10px; margin-bottom: 10px; ">
129
+ --- or ---
130
+ </div>
131
+ <a href="<?php
132
+ echo yasr_fs()->get_trial_url() ;
133
+ ?>">
134
+ <button class="button button-primary">
135
+ <span style="display: block; font-size: large; font-weight: bold; margin: -3px;">
136
+ <?php
137
+ _e( 'Start Free Trial', 'yet-another-stars-rating' );
138
+ ?>
139
+ </span>
140
+ <span style="display: block; margin-top: -10px; font-size: smaller;">
141
+ <?php
142
+ _e( 'No credit-card, risk free!', 'yet-another-stars-rating' );
143
+ ?>
144
+ </span>
145
+ </button>
146
  </a>
147
  </div>
148
 
admin/settings/yasr-settings-functions.php CHANGED
@@ -59,13 +59,17 @@ function yasr_general_options_init() {
59
  }
60
 
61
 
62
- //if it's not blogposting avoid undefined variable
63
- if (!isset($option['blogposting_organization_name'])) {
64
- $option['blogposting_organization_name'] = get_bloginfo('name');
65
  }
66
 
67
- if (!isset($option['blogposting_organization_logo'])) {
68
- $option['blogposting_organization_logo'] = get_site_icon_url();
 
 
 
 
69
  }
70
 
71
  if(!isset($option['enable_ajax'])) {
@@ -184,99 +188,62 @@ function yasr_auto_insert_callback($option) {
184
  <p>&nbsp;</p>
185
 
186
  <div>
187
- <strong><?php _e('What?', 'yet-another-stars-rating'); ?></strong>
188
-
189
- <div class="yasr-indented-answer">
190
-
191
- <input type="radio" name="yasr_general_options[auto_insert_what]" value="visitor_rating"
192
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_what'] === 'visitor_rating') {
193
- echo " checked=\"checked\" ";
194
- } ?> >
195
- <?php _e('Visitor Votes', 'yet-another-stars-rating') ?>
196
- <br/>
197
-
198
- <input type="radio" name="yasr_general_options[auto_insert_what]" value="overall_rating"
199
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_what'] === 'overall_rating') {
200
- echo " checked=\"checked\" ";
201
- } ?> >
202
- <?php _e('Overall Rating / Author Rating', 'yet-another-stars-rating') ?>
203
- <br/>
204
-
205
- <input type="radio" name="yasr_general_options[auto_insert_what]" value="both"
206
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_what'] === 'both') {
207
- echo " checked=\"checked\" ";
208
- } ?> >
209
- <?php _e('Both', 'yet-another-stars-rating') ?>
210
- </div>
211
  </div>
212
 
213
  <p>&nbsp;</p>
214
 
215
  <div>
216
- <strong><?php _e('Where?', 'yet-another-stars-rating'); ?></strong>
217
- <div class="yasr-indented-answer">
218
- <input type="radio" name="yasr_general_options[auto_insert_where]" value="top"
219
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_where'] === 'top') {
220
- echo " checked=\"checked\" ";
221
- } ?> >
222
- <?php _e('Before the content', 'yet-another-stars-rating') ?>
223
- <br/>
224
-
225
- <input type="radio" name="yasr_general_options[auto_insert_where]" value="bottom"
226
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_where'] === 'bottom') {
227
- echo " checked=\"checked\" ";
228
- } ?> >
229
- <?php _e('After the content', 'yet-another-stars-rating') ?>
230
- <br/>
231
- </div>
232
  </div>
233
 
234
  <p>&nbsp;</p>
235
 
236
  <div>
237
- <strong><?php _e('Align', 'yet-another-stars-rating'); ?></strong>
238
-
239
- <div class="yasr-indented-answer">
 
 
 
 
 
 
 
 
 
 
240
 
241
- <div class="yasr-option-align">
242
- <input type="radio" name="yasr_general_options[auto_insert_align]" value="left"
243
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_align'] === 'left') {
244
- echo " checked=\"checked\" ";
245
- } ?> >
246
- <span class="yasr-text-options-size">
247
- <?php _e('Left', 'yet-another-stars-rating') ?>
248
- </span>
249
- </div>
250
-
251
- <div class="yasr-option-align">
252
- <input type="radio" name="yasr_general_options[auto_insert_align]" value="center"
253
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_align'] === 'center') {
254
- echo " checked=\"checked\" ";
255
- } ?> >
256
- <span class="yasr-text-options-size">
257
- <?php _e('Center', 'yet-another-stars-rating') ?>
258
- </span>
259
- </div>
260
-
261
- <div class="yasr-option-align">
262
- <input type="radio" name="yasr_general_options[auto_insert_align]" value="right"
263
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_align'] === 'right') {
264
- echo " checked=\"checked\" ";
265
- } ?> >
266
- <span class="yasr-text-options-size">
267
- <?php _e('Right', 'yet-another-stars-rating') ?>
268
- </span>
269
- </div>
270
- </div>
271
  </div>
272
 
273
  <p>&nbsp;</p>
274
 
275
  <div>
276
  <strong><?php _e('Size', 'yet-another-stars-rating'); ?></strong>
277
-
278
  <div class="yasr-indented-answer">
279
-
280
  <?php
281
  $name = 'yasr_general_options[auto_insert_size]';
282
  $class = 'yasr-auto-insert-options-class';
@@ -287,64 +254,58 @@ function yasr_auto_insert_callback($option) {
287
  </div>
288
 
289
  <p>&nbsp;</p>
290
- <strong><?php _e('Exclude Pages?', 'yet-another-stars-rating'); ?></strong>
291
-
292
- <div class="yasr-indented-answer">
293
- <input type="radio" name="yasr_general_options[auto_insert_exclude_pages]" value="yes"
294
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_exclude_pages'] === 'yes') {
295
- echo " checked=\"checked\" ";
296
- } ?> >
297
- <?php _e('Yes', 'yet-another-stars-rating'); ?>
298
-
299
- &nbsp;&nbsp;&nbsp;
300
-
301
- <input type="radio" name="yasr_general_options[auto_insert_exclude_pages]" value="no"
302
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_exclude_pages'] === 'no') {
303
- echo " checked=\"checked\" ";
304
- } ?> >
305
- <?php _e('No', 'yet-another-stars-rating'); ?>
306
- <br/>
307
-
308
  <p>&nbsp;</p>
309
-
310
  </div>
311
 
312
  <?php
313
 
314
  $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
315
 
316
- if ($custom_post_types) { ?>
317
- <strong><?php _e('Use only in custom post types?', 'yet-another-stars-rating'); ?></strong>
318
- <div class="yasr-indented-answer">
319
- <input type="radio" name="yasr_general_options[auto_insert_custom_post_only]" value="yes"
320
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_custom_post_only'] === 'yes') {
321
- echo " checked=\"checked\" ";
322
- } ?> >
323
- <?php _e('Yes', 'yet-another-stars-rating'); ?>
324
 
 
325
 
326
- <input type="radio" name="yasr_general_options[auto_insert_custom_post_only]" value="no"
327
- class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_custom_post_only'] === 'no') {
328
- echo " checked=\"checked\" ";
329
- } ?> >
330
- <?php _e('No', 'yet-another-stars-rating'); ?>
 
 
 
331
 
332
- <p>
333
 
334
- <?php _e("You see this because you use custom post types.", 'yet-another-stars-rating'); ?>
335
- <br/>
336
- <?php _e("If you want to use auto insert only in custom post types, choose Yes", 'yet-another-stars-rating'); ?>
337
-
338
- <p>&nbsp;</p>
339
 
 
 
 
 
340
  </div>
 
341
 
342
  <?php
343
  }
344
 
345
  else {
346
  ?>
347
- <input type="hidden" name="yasr_general_options[auto_insert_custom_post_only]" value="no" ?>
348
  <?php
349
  }
350
 
@@ -509,30 +470,25 @@ function yasr_visitors_stats_callback($option) {
509
 
510
  function yasr_allow_only_logged_in_callback($option) {
511
 
512
- ?>
513
-
514
- <input type='radio' name='yasr_general_options[allowed_user]' value='logged_only'
515
- class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user'] === 'logged_only') {
516
- echo " checked=\"checked\" ";
517
- } ?> />
518
- <?php _e('Allow only logged-in users', 'yet-another-stars-rating') ?>
519
- <br/>
520
-
521
- <input type='radio' name='yasr_general_options[allowed_user]' value='allow_anonymous'
522
- class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user'] === 'allow_anonymous') {
523
- echo " checked=\"checked\" ";
524
- } ?> />
525
- <?php _e('Allow everybody (logged in and anonymous)', 'yet-another-stars-rating') ?>
526
- <br/>
527
 
528
- <br /><br />
529
- <?php
530
- _e(
531
- 'Select who can rate your posts for yasr_visitor_votes shortcode.',
532
- 'yet-another-stars-rating')
533
  ?>
534
 
535
- <p>&nbsp;</p>
 
 
 
 
 
 
 
536
 
537
  <?php
538
  submit_button(YASR_SAVE_All_SETTINGS_TEXT);
@@ -561,7 +517,8 @@ function yasr_show_overall_in_loop_callback($option) {
561
 
562
  <br/> <br/>
563
 
564
- <?php _e('If you enable this, "Overall Rating" will be showed not only in the single article or page, but also in pages like Home Page, category pages or archives.', 'yet-another-stars-rating') ?>
 
565
 
566
  <p>&nbsp;</p>
567
 
@@ -641,19 +598,22 @@ function yasr_enable_ip_callback($option) {
641
 
642
  function yasr_choose_snippet_callback($option) {
643
 
644
- $blogposting_organization_name = $option['blogposting_organization_name'];
645
- $blogposting_organization_logo = $option['blogposting_organization_logo'];
646
 
647
  ?>
648
 
649
- <strong><?php _e('Select default item type for all post or pages', 'yet-another-stars-rating'); ?></strong>
 
 
650
 
651
  <div class="yasr-indented-answer" id="yasr-choose-snippet-type">
652
  <?php
653
  $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
654
  sort($review_types);
655
  ?>
656
- <select name="yasr_general_options[snippet_itemtype]" id="yasr-choose-reviews-types-list">
 
657
  <?php
658
  foreach ($review_types as $type) {
659
  $type = trim($type);
@@ -674,45 +634,67 @@ function yasr_choose_snippet_callback($option) {
674
  }
675
  }
676
  ?>
677
- </select>
 
678
 
679
- <div class="yasr-help-box-settings" id="yasr-blogPosting-additional-info" style="display:block">
680
 
681
- <?php _e("Add more info to your rich snippets filling these forms", "yet-another-stars-rating"); ?>
 
 
 
 
 
 
 
 
 
 
 
682
 
683
- <br/> <br/>
684
 
685
- <input type='text' name='yasr_general_options[blogposting_organization_name]'
686
- id="yasr-general-options-blogposting-organization-name"
687
- class="yasr-blogPosting-additional-info-inputs" <?php printf('value="%s"', $blogposting_organization_name); ?>
688
- maxlength="180"/>
 
689
  <?php _e('Publisher name (e.g. Google)', 'yet-another-stars-rating') ?>
 
690
 
691
- <br/> <br/>
692
 
693
- <input type='text' name='yasr_general_options[blogposting_organization_logo]'
694
- id="yasr-general-options-blogposting-organization-logo"
695
- class="yasr-blogPosting-additional-info-inputs" <?php printf('value="%s"', $blogposting_organization_logo); ?>
696
- maxlength="300"/>
697
- <?php _e('Logo Url (if empty siteicon will be used instead)', 'yet-another-stars-rating') ?>
 
 
698
 
699
- </div>
 
700
 
 
701
 
702
- <br/>
 
 
 
 
 
 
703
 
704
- <?php _e('You can always change it in the single post or page.', 'yet-another-stars-rating'); ?>
705
- <br/>
706
- <?php _e(
707
- 'This will affect only the post/page where you didn\'t change manually the itemtype yet.',
708
- 'yet-another-stars-rating'); ?>
709
- <br />
710
- <?php echo(sprintf(__('Please keep in mind that since September, 16, 2019 blogPosting item type will
711
- no show stars in SERP anymore. %sHere%s the announcement by Google.',
712
- 'yet-another-stars-rating'),
713
- '<a href="https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html">',
714
- '</a>'));
715
- ?>
716
 
717
  <p>&nbsp;</p>
718
 
@@ -804,7 +786,7 @@ function yasr_general_options_sanitize($option) {
804
  //Always use esc_html
805
  $output[$key] = esc_html($output[$key]);
806
 
807
- if ($key === 'blogposting_organization_logo') {
808
  //if is not a valid url get_site_icon_url instead
809
  if (filter_var($value, FILTER_VALIDATE_URL) === false) {
810
  $output[$key] = get_site_icon_url();
59
  }
60
 
61
 
62
+ //Avoid undefined
63
+ if (!isset($option['publisher'])) {
64
+ $option['publisher'] = 'Organization';
65
  }
66
 
67
+ if (!isset($option['publisher_name'])) {
68
+ $option['publisher_name'] = get_bloginfo('name');
69
+ }
70
+
71
+ if (!isset($option['publisher_logo'])) {
72
+ $option['publisher_logo'] = get_site_icon_url();
73
  }
74
 
75
  if(!isset($option['enable_ajax'])) {
188
  <p>&nbsp;</p>
189
 
190
  <div>
191
+ <?php
192
+ $option_title = __('What?', 'yet-another-stars-rating');
193
+ $array_options = array (
194
+ 'visitor_rating' => __('Visitor Votes', 'yet-another-stars-rating'),
195
+ 'overall_rating' => __('Overall Rating / Author Rating', 'yet-another-stars-rating'),
196
+ 'both' => __('Both', 'yet-another-stars-rating')
197
+ );
198
+ $default = $option['auto_insert_what'];
199
+ $name = 'yasr_general_options[auto_insert_what]';
200
+ $class = 'yasr-auto-insert-options-class';
201
+
202
+ YasrSettings::printRadioType( $option_title, $array_options, $name, $class, $default);
203
+ ?>
 
 
 
 
 
 
 
 
 
 
 
204
  </div>
205
 
206
  <p>&nbsp;</p>
207
 
208
  <div>
209
+ <?php
210
+ $option_title = __('Where?', 'yet-another-stars-rating');
211
+ $array_options = array (
212
+ 'top' => __('Before the content', 'yet-another-stars-rating'),
213
+ 'bottom' => __('After the content', 'yet-another-stars-rating'),
214
+ );
215
+ $default = $option['auto_insert_where'];
216
+ $name = 'yasr_general_options[auto_insert_where]';
217
+ $class = 'yasr-auto-insert-options-class';
218
+
219
+ YasrSettings::printRadioType( $option_title, $array_options, $name, $class, $default);
220
+ ?>
 
 
 
 
221
  </div>
222
 
223
  <p>&nbsp;</p>
224
 
225
  <div>
226
+ <?php
227
+ $option_title = __('Align', 'yet-another-stars-rating');
228
+ $array_options = array (
229
+ 'left' => __('Left', 'yet-another-stars-rating'),
230
+ 'center' => __('Center', 'yet-another-stars-rating'),
231
+ 'right' => __('Right', 'yet-another-stars-rating')
232
+ );
233
+ $default = $option['auto_insert_align'];
234
+ $name = 'yasr_general_options[auto_insert_align]';
235
+ $class = 'yasr-auto-insert-options-class';
236
+
237
+ YasrSettings::printRadioType($option_title, $array_options, $name, $class, $default);
238
+ ?>
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  </div>
241
 
242
  <p>&nbsp;</p>
243
 
244
  <div>
245
  <strong><?php _e('Size', 'yet-another-stars-rating'); ?></strong>
 
246
  <div class="yasr-indented-answer">
 
247
  <?php
248
  $name = 'yasr_general_options[auto_insert_size]';
249
  $class = 'yasr-auto-insert-options-class';
254
  </div>
255
 
256
  <p>&nbsp;</p>
257
+ <div>
258
+ <?php
259
+ $option_title = __('Exclude Pages?', 'yet-another-stars-rating');
260
+ $array_options = array (
261
+ 'yes' => __('Yes', 'yet-another-stars-rating'),
262
+ 'no' => __('No', 'yet-another-stars-rating'),
263
+ );
264
+ $default = $option['auto_insert_exclude_pages'];
265
+ $name = 'yasr_general_options[auto_insert_exclude_pages]';
266
+ $class = 'yasr-auto-insert-options-class';
267
+
268
+ YasrSettings::printRadioType($option_title, $array_options, $name, $class, $default);
269
+ ?>
 
 
 
 
 
270
  <p>&nbsp;</p>
 
271
  </div>
272
 
273
  <?php
274
 
275
  $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
276
 
277
+ if ($custom_post_types) {
 
 
 
 
 
 
 
278
 
279
+ echo '<div>';
280
 
281
+ $option_title = __('Use only in custom post types?', 'yet-another-stars-rating');
282
+ $array_options = array (
283
+ 'yes' => __('Yes', 'yet-another-stars-rating'),
284
+ 'no' => __('No', 'yet-another-stars-rating'),
285
+ );
286
+ $default = $option['auto_insert_custom_post_only'];
287
+ $name = 'yasr_general_options[auto_insert_custom_post_only]';
288
+ $class = 'yasr-auto-insert-options-class';
289
 
290
+ YasrSettings::printRadioType($option_title, $array_options, $name, $class, $default);
291
 
292
+ echo '</div>';
293
+ ?>
294
+ <p>
 
 
295
 
296
+ <div class="yasr-indented-answer">
297
+ <?php _e("You see this because you use custom post types.", 'yet-another-stars-rating'); ?>
298
+ <br/>
299
+ <?php _e("If you want to use auto insert only in custom post types, choose Yes", 'yet-another-stars-rating'); ?>
300
  </div>
301
+ <p>&nbsp;</p>
302
 
303
  <?php
304
  }
305
 
306
  else {
307
  ?>
308
+ <input type="hidden" name="yasr_general_options[auto_insert_custom_post_only]" value="no">
309
  <?php
310
  }
311
 
470
 
471
  function yasr_allow_only_logged_in_callback($option) {
472
 
473
+ $array_options = array(
474
+ 'logged_only' => __('Allow only logged-in users', 'yet-another-stars-rating' ),
475
+ 'allow_anonymous' => __('Allow everybody (logged in and anonymous)', 'yet-another-stars-rating' ),
476
+ );
477
+ $default = $option['allowed_user'];
478
+ $name = 'yasr_general_options[allowed_user]';
479
+ $class = 'yasr_auto_insert_loggedonly';
 
 
 
 
 
 
 
 
480
 
481
+ YasrSettings::printRadioType( false, $array_options, $name, $class, $default );
 
 
 
 
482
  ?>
483
 
484
+ <br />
485
+ <div class="yasr-indented-answer">
486
+ <?php
487
+ _e(
488
+ 'Select who can rate your posts for yasr_visitor_votes and yasr_visitor_multiset shortcodes.',
489
+ 'yet-another-stars-rating')
490
+ ?>
491
+ </div>
492
 
493
  <?php
494
  submit_button(YASR_SAVE_All_SETTINGS_TEXT);
517
 
518
  <br/> <br/>
519
 
520
+ <?php _e('If you enable this, "Overall Rating" will be showed not only in the single article or page, but also
521
+ in pages like Home Page, category pages or archives.', 'yet-another-stars-rating') ?>
522
 
523
  <p>&nbsp;</p>
524
 
598
 
599
  function yasr_choose_snippet_callback($option) {
600
 
601
+ $publisher_name = $option['publisher_name'];
602
+ $publisher_logo = $option['publisher_logo'];
603
 
604
  ?>
605
 
606
+ <strong>
607
+ <?php _e('Select default itemType for all post or pages', 'yet-another-stars-rating'); ?>
608
+ </strong>
609
 
610
  <div class="yasr-indented-answer" id="yasr-choose-snippet-type">
611
  <?php
612
  $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
613
  sort($review_types);
614
  ?>
615
+ <label for="yasr-choose-reviews-types-list">
616
+ <select name="yasr_general_options[snippet_itemtype]" id="yasr-choose-reviews-types-list">
617
  <?php
618
  foreach ($review_types as $type) {
619
  $type = trim($type);
634
  }
635
  }
636
  ?>
637
+ </select>
638
+ </label>
639
 
640
+ <br/> <br/>
641
 
642
+ <?php
643
+ $option_title = __(' Choose whether the site represents an organization or a person.', 'yet-another-stars-rating');
644
+ $array_options = array (
645
+ 'Organization' => 'Organization',
646
+ 'Person' => 'Person'
647
+ );
648
+ $default = $option['publisher'];
649
+ $name = 'yasr_general_options[publisher]';
650
+ $id = 'yasr-general-options-publisher';
651
+
652
+ YasrSettings::printRadioType( $option_title, $array_options, $name, '', $default, $id );
653
+ ?>
654
 
655
+ <br/>
656
 
657
+ <label for="yasr-general-options-publisher-name">
658
+ <input type='text' name='yasr_general_options[publisher_name]'
659
+ id="yasr-general-options-publisher-name"
660
+ class="yasr-additional-info-inputs" <?php printf('value="%s"', $publisher_name); ?>
661
+ maxlength="180"/>
662
  <?php _e('Publisher name (e.g. Google)', 'yet-another-stars-rating') ?>
663
+ </label>
664
 
665
+ <br/> <br/>
666
 
667
+ <label for="yasr-general-options-publisher-logo"></label>
668
+ <input type='text' name='yasr_general_options[publisher_logo]'
669
+ id="yasr-general-options-publisher-logo"
670
+ class="yasr-blogPosting-additional-info-inputs"
671
+ <?php printf('value="%s"', $publisher_logo); ?>
672
+ maxlength="300"/>
673
+ <?php _e('Image Url (if empty siteicon will be used instead)', 'yet-another-stars-rating') ?>
674
 
675
+ <div class="yasr-help-box-settings" id="yasr-blogPosting-additional-info" style="display:block">
676
+ <?php _e('You can always change itemType in the single post or page.', 'yet-another-stars-rating');
677
 
678
+ echo "<br />";
679
 
680
+ echo(sprintf(
681
+ __('Please keep in mind that since September, 16, 2019 blogPosting itemType will
682
+ no show stars in SERP anymore. %sHere%s the announcement by Google.',
683
+ 'yet-another-stars-rating'),
684
+ '<a href="https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html">',
685
+ '</a>')
686
+ );
687
 
688
+ echo "<br />";
689
+ echo (sprintf(
690
+ __('Also, %sread Google guidelines%s', 'yet-another-stars-rating'),
691
+ '<a href="https://developers.google.com/search/docs/data-types/review-snippet#guidelines">',
692
+ '</a>')
693
+ );
694
+
695
+ ?>
696
+
697
+ </div>
 
 
698
 
699
  <p>&nbsp;</p>
700
 
786
  //Always use esc_html
787
  $output[$key] = esc_html($output[$key]);
788
 
789
+ if ($key === 'publisher_logo') {
790
  //if is not a valid url get_site_icon_url instead
791
  if (filter_var($value, FILTER_VALIDATE_URL) === false) {
792
  $output[$key] = get_site_icon_url();
includes/rest/classes/YasrCustomEndpoint.php CHANGED
@@ -29,7 +29,7 @@ class YasrCustomEndpoint extends WP_REST_Controller {
29
  $base = 'yasr-multiset';
30
 
31
  register_rest_route(
32
- $namespace . $version . $base . '/',
33
  '(?P<set_id>\d+)',
34
  array(
35
  'methods' => WP_REST_Server::READABLE,
29
  $base = 'yasr-multiset';
30
 
31
  register_rest_route(
32
+ $namespace . $version . $base,
33
  '(?P<set_id>\d+)',
34
  array(
35
  'methods' => WP_REST_Server::READABLE,
includes/yasr-includes-init.php CHANGED
@@ -116,15 +116,21 @@ define('YASR_ALLOWED_USER', $yasr_stored_options['allowed_user']);
116
  define('YASR_ENABLE_IP', $yasr_stored_options['enable_ip']);
117
  define('YASR_ITEMTYPE', $yasr_stored_options['snippet_itemtype']);
118
 
119
- if (isset($yasr_stored_options['blogposting_organization_name'])) {
120
- define('YASR_BLOGPOSTING_ORGANIZATION_NAME', $yasr_stored_options['blogposting_organization_name']);
121
  } else {
122
- define('YASR_BLOGPOSTING_ORGANIZATION_NAME', '');
123
  }
124
 
125
- if (isset($yasr_stored_options['blogposting_organization_logo'])) {
126
- if (filter_var($yasr_stored_options['blogposting_organization_logo'], FILTER_VALIDATE_URL) !== false) {
127
- define('YASR_BLOGPOSTING_ORGANIZATION_LOGO', $yasr_stored_options['blogposting_organization_logo']);
 
 
 
 
 
 
128
  }
129
  }
130
 
116
  define('YASR_ENABLE_IP', $yasr_stored_options['enable_ip']);
117
  define('YASR_ITEMTYPE', $yasr_stored_options['snippet_itemtype']);
118
 
119
+ if (isset($yasr_stored_options['publisher'])) {
120
+ define('YASR_PUBLISHER_TYPE', $yasr_stored_options['publisher']);
121
  } else {
122
+ define('YASR_PUBLISHER_TYPE', 'Organization'); //default value
123
  }
124
 
125
+ if (isset($yasr_stored_options['publisher_name'])) {
126
+ define('YASR_PUBLISHER_NAME', $yasr_stored_options['publisher_name']);
127
+ } else {
128
+ define('YASR_PUBLISHER_NAME', get_bloginfo('name'));
129
+ }
130
+
131
+ if (isset($yasr_stored_options['publisher_logo'])) {
132
+ if (filter_var($yasr_stored_options['publisher_logo'], FILTER_VALIDATE_URL) !== false) {
133
+ define('YASR_PUBLISHER_LOGO', $yasr_stored_options['publisher_logo']);
134
  }
135
  }
136
 
public/yasr-public-filters.php CHANGED
@@ -172,11 +172,11 @@ function yasr_add_schema($content) {
172
  $post_image_url = ''; //avoid undefined
173
  $logo_image_url = ''; //avoid undefined
174
 
175
- if (defined('YASR_BLOGPOSTING_ORGANIZATION_LOGO')) {
176
- $logo_image_url = YASR_BLOGPOSTING_ORGANIZATION_LOGO;
177
  $post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
178
 
179
- $logo_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url(YASR_BLOGPOSTING_ORGANIZATION_LOGO, PHP_URL_PATH);
180
 
181
  $post_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
182
  $logo_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
@@ -195,7 +195,7 @@ function yasr_add_schema($content) {
195
  }
196
 
197
  $rich_snippet['@type'] = $review_choosen;
198
- $rich_snippet['name'] = $review_name;
199
  $cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
200
 
201
  $rich_snippet['description'] = wp_trim_words( $cleaned_content, 55, '...' );
@@ -207,12 +207,16 @@ function yasr_add_schema($content) {
207
  'height' => $post_image_size[1]
208
  );
209
 
 
 
 
 
 
210
  if ($review_choosen === 'Place') {
211
  $rich_snippet['@type'] = 'LocalBusiness';
212
  }
213
 
214
  elseif ($review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
215
- $rich_snippet['@type'] = 'BlogPosting';
216
  $rich_snippet['datePublished'] = $date;
217
  $rich_snippet['headline'] = $review_name;
218
  $rich_snippet['mainEntityOfPage'] = array(
@@ -221,11 +225,11 @@ function yasr_add_schema($content) {
221
  );
222
  $rich_snippet['author'] = array(
223
  '@type' => 'Person',
224
- 'name' => (string) $author
225
  );
226
  $rich_snippet['publisher'] = array(
227
  '@type' => 'Organization',
228
- 'name' => wp_strip_all_tags(YASR_BLOGPOSTING_ORGANIZATION_NAME), //already sanitized in the settings, just to be safe
229
  'logo' => array(
230
  '@type' => 'ImageObject',
231
  'url' => $logo_image_url,
@@ -280,12 +284,31 @@ function yasr_add_schema($content) {
280
  'ratingValue' => $average_rating,
281
  'ratingCount' => $visitor_votes['number_of_votes'],
282
  'bestRating' => 5,
283
- 'worstRating' => 1
284
  );
285
  }
286
  }
287
  }
 
288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  }
290
 
291
  //if doesn't exists a filter for yasr_filter_existing_schema, put $rich_snippet into $more_rich_snippet
172
  $post_image_url = ''; //avoid undefined
173
  $logo_image_url = ''; //avoid undefined
174
 
175
+ if (defined('YASR_PUBLISHER_LOGO')) {
176
+ $logo_image_url = YASR_PUBLISHER_LOGO;
177
  $post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
178
 
179
+ $logo_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url(YASR_PUBLISHER_LOGO, PHP_URL_PATH);
180
 
181
  $post_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
182
  $logo_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
195
  }
196
 
197
  $rich_snippet['@type'] = $review_choosen;
198
+ $rich_snippet['name'] = $review_name;
199
  $cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
200
 
201
  $rich_snippet['description'] = wp_trim_words( $cleaned_content, 55, '...' );
207
  'height' => $post_image_size[1]
208
  );
209
 
210
+ $publisher_image_index = 'logo';
211
+ if(YASR_PUBLISHER_TYPE === 'Person') {
212
+ $publisher_image_index = 'image';
213
+ }
214
+
215
  if ($review_choosen === 'Place') {
216
  $rich_snippet['@type'] = 'LocalBusiness';
217
  }
218
 
219
  elseif ($review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
 
220
  $rich_snippet['datePublished'] = $date;
221
  $rich_snippet['headline'] = $review_name;
222
  $rich_snippet['mainEntityOfPage'] = array(
225
  );
226
  $rich_snippet['author'] = array(
227
  '@type' => 'Person',
228
+ 'name' => $author
229
  );
230
  $rich_snippet['publisher'] = array(
231
  '@type' => 'Organization',
232
+ 'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME), //already sanitized in the settings, just to be safe
233
  'logo' => array(
234
  '@type' => 'ImageObject',
235
  'url' => $logo_image_url,
284
  'ratingValue' => $average_rating,
285
  'ratingCount' => $visitor_votes['number_of_votes'],
286
  'bestRating' => 5,
287
+ 'worstRating' => 1,
288
  );
289
  }
290
  }
291
  }
292
+ }
293
 
294
+ if(isset($rich_snippet['Review']) || $review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
295
+ $publisher = array(
296
+ '@type' => YASR_PUBLISHER_TYPE,
297
+ 'name' => wp_strip_all_tags( YASR_PUBLISHER_NAME ),//already sanitized in the settings, just to be safe
298
+ $publisher_image_index => array(
299
+ '@type' => 'ImageObject',
300
+ 'url' => $logo_image_url,
301
+ 'width' => $logo_image_size[0],
302
+ 'height' => $logo_image_size[1]
303
+ ),
304
+ );
305
+
306
+ /** @noinspection NotOptimalIfConditionsInspection */
307
+ if(isset($rich_snippet['Review'])) {
308
+ $rich_snippet['Review']['publisher'] = $publisher;
309
+ } else {
310
+ $rich_snippet['publisher'] = $publisher;
311
+ }
312
  }
313
 
314
  //if doesn't exists a filter for yasr_filter_existing_schema, put $rich_snippet into $more_rich_snippet
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
- Stable tag: 2.3.4
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -147,6 +147,12 @@ If doesn't, you should work on your seo reputation.
147
 
148
  The full changelog can be found in the plugin's directory. Recent entries:
149
 
 
 
 
 
 
 
150
  = 2.3.4 =
151
  * IMPROVED: added Software Application itemType
152
  * IMPROVED: added Organization itemType
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
+ Stable tag: 2.3.5
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
147
 
148
  The full changelog can be found in the plugin's directory. Recent entries:
149
 
150
+ = 2.3.5 =
151
+ * IMPROVED: is now possible to select between "Organization" or "Person" in "Rich snippet options".
152
+ You may need to save again "Publisher name" and "Image Url"
153
+ * IMPROVED: code cleanup
154
+
155
+
156
  = 2.3.4 =
157
  * IMPROVED: added Software Application itemType
158
  * IMPROVED: added Organization itemType
yet-another-stars-rating.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
- * Version: 2.3.4
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
@@ -77,7 +77,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
- define( 'YASR_VERSION_NUM', '2.3.4' );
81
  //Plugin absolute path
82
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
83
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
+ * Version: 2.3.5
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
+ define( 'YASR_VERSION_NUM', '2.3.5' );
81
  //Plugin absolute path
82
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
83
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );