Schema & Structured Data for WP & AMP - Version 1.0.5

Version Description

(30 November 2018) =

  • New Feature: Service schema type add to the schema type list
  • New Feature: Comments Markup, The comments on post will also appear in schema markup
  • New Feature: WP SEO Structured Data Schema migration tool
  • New Feature: Compatibility with kk Star Ratings plugin, Now the ratings will be indexed in google search and results will be appearing in the form of a rich snippet
  • Bug Fixed: Some of the missing fields added in NewsArticle schema type markup( articleSection, articleBody, wordCount & timeRequired ).
Download this release

Release Info

Developer ampforwp
Plugin Icon 128x128 Schema & Structured Data for WP & AMP
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.4.1 to 1.0.5

admin_section/add-schema/add_new.php CHANGED
@@ -44,10 +44,15 @@ $saswp_add_data_type_config = array(
44
  if(! current_user_can( 'manage_options' ) ) {
45
  return ;
46
  }
47
- if( wp_verify_nonce($_GET['_wpnonce'], '_wpnonce')){
 
 
 
 
48
  saswp_add_new_steps_call();
49
- }
50
-
 
51
  }
52
 
53
  function saswp_add_new_steps_call(){
44
  if(! current_user_can( 'manage_options' ) ) {
45
  return ;
46
  }
47
+ if(!isset($_GET['_wpnonce'])){
48
+ return ;
49
+ }else{
50
+ $wp_nonce = $_GET['_wpnonce'];
51
+ if( wp_verify_nonce($wp_nonce, '_wpnonce')){
52
  saswp_add_new_steps_call();
53
+ }
54
+ }
55
+
56
  }
57
 
58
  function saswp_add_new_steps_call(){
admin_section/common-function.php CHANGED
@@ -332,6 +332,159 @@
332
 
333
  }
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  function saswp_import_schema_pro_plugin_data(){
336
 
337
  $schema_post = array();
332
 
333
  }
334
 
335
+ function saswp_import_wp_seo_schema_plugin_data(){
336
+ global $KcSeoWPSchema;
337
+ global $wpdb;
338
+ $settings = get_option($KcSeoWPSchema->options['settings']);
339
+
340
+ if(isset($settings)){
341
+ $saswp_plugin_options = array();
342
+ $local_business_details = array();
343
+ $wpdb->query('START TRANSACTION');
344
+
345
+ $user_id = get_current_user_id();
346
+
347
+ if($settings['site_type'] !='Organization'){
348
+
349
+ $schema_post = array(
350
+ 'post_author' => $user_id,
351
+ 'post_status' => 'publish',
352
+ 'post_type' => 'saswp',
353
+ );
354
+ $schema_post['post_title'] = 'Organization (Migrated from WP SEO Plugin)';
355
+
356
+ if(isset($settings['type_name'])){
357
+ $schema_post['post_title'] = $settings['type_name'].'(Migrated from WP SEO Plugin)';
358
+ }
359
+ if(isset($settings['site_image'])){
360
+ $image_details = wp_get_attachment_image_src($settings['site_image'], 'full');
361
+
362
+ $local_business_details['local_business_logo'] = array(
363
+ 'url' =>$image_details[0],
364
+ 'id' =>$settings['site_image'],
365
+ 'height' =>$image_details[1],
366
+ 'width' =>$image_details[2],
367
+ 'thumbnail' =>$image_details[0]
368
+ );
369
+ }
370
+ if(isset($settings['site_price_range'])){
371
+ $local_business_details['local_price_range'] = $settings['site_price_range'];
372
+ }
373
+ if(isset($settings['site_telephone'])){
374
+ $local_business_details['local_phone'] = $settings['site_telephone'];
375
+ }
376
+ // if(isset($settings['business_info']['openingHours'])){
377
+ //
378
+ // }
379
+ // if(isset($settings['business_info']['openingHours'])){
380
+ //
381
+ // }
382
+ if(isset($settings['web_url'])){
383
+ $local_business_details['local_website'] = $settings['web_url'];
384
+ }
385
+
386
+ if(isset($settings['address']['locality'])){
387
+ $local_business_details['local_city'] = $settings['site_telephone'];
388
+ }
389
+ if(isset($settings['address']['region'])){
390
+ $local_business_details['local_state'] = $settings['address']['region'];
391
+ }
392
+ if(isset($settings['address']['postalcode'])){
393
+ $local_business_details['local_postal_code'] = $settings['address']['postalcode'];
394
+ }
395
+ if(isset($settings['address']['street'])){
396
+ $local_business_details['local_street_address'] = $settings['site_telephone'];
397
+ }
398
+
399
+ $post_id = wp_insert_post($schema_post);
400
+ $result = $post_id;
401
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
402
+ $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
403
+
404
+ $data_group_array = array();
405
+ $data_group_array['group-0'] =array(
406
+ 'data_array' => array(
407
+ array(
408
+ 'key_1' => 'post_type',
409
+ 'key_2' => 'equal',
410
+ 'key_3' => 'post',
411
+ )
412
+ )
413
+ );
414
+
415
+ $saswp_meta_key = array(
416
+ 'schema_type' => 'local_business',
417
+ 'data_group_array'=>$data_group_array,
418
+ 'imported_from' => 'wp_seo_schema',
419
+ 'saswp_local_business_details' => $local_business_details
420
+ );
421
+
422
+ foreach ($saswp_meta_key as $key => $val){
423
+ update_post_meta($post_id, $key, $val);
424
+ }
425
+
426
+ }
427
+
428
+ if(isset($settings['person']['name'])){
429
+ $saswp_plugin_options['sd-person-name'] = $settings['person']['name'];
430
+ }
431
+
432
+ if(isset($settings['person']['jobTitle'])){
433
+ $saswp_plugin_options['sd-person-job-title'] = $settings['person']['jobTitle'];
434
+ }
435
+
436
+ if(isset($settings['person']['image'])){
437
+ $image_details = wp_get_attachment_image_src($settings['person']['image'], 'full');
438
+
439
+ $saswp_plugin_options['sd-person-image'] = array(
440
+ 'url' =>$image_details[0],
441
+ 'id' =>$settings['organization_logo'],
442
+ 'height' =>$image_details[1],
443
+ 'width' =>$image_details[2],
444
+ 'thumbnail' =>$image_details[0]
445
+ );
446
+ }
447
+
448
+ if(isset($settings['organization_logo'])){
449
+ $image_details = wp_get_attachment_image_src($settings['organization_logo'], 'full');
450
+
451
+ $saswp_plugin_options['sd_logo'] = array(
452
+ 'url' =>$image_details[0],
453
+ 'id' =>$settings['organization_logo'],
454
+ 'height' =>$image_details[1],
455
+ 'width' =>$image_details[2],
456
+ 'thumbnail' =>$image_details[0]
457
+ );
458
+ }
459
+ if(isset($settings['contact']['contactType'])){
460
+ $saswp_plugin_options['saswp_contact_type'] = $settings['contact']['contactType'];
461
+ $saswp_plugin_options['saswp_kb_contact_1'] = 1;
462
+ }
463
+ if(isset($settings['contact']['telephone'])){
464
+ $saswp_plugin_options['saswp_kb_telephone'] = $settings['contact']['telephone'];
465
+ }
466
+ if(isset($settings['sitename'])){
467
+ $saswp_plugin_options['sd_name'] = $settings['sitename'];
468
+ }
469
+
470
+ if(isset($settings['siteurl'])){
471
+ $saswp_plugin_options['sd_url'] = $settings['sitename'];
472
+ }
473
+ $get_options = get_option('sd_data');
474
+ $merge_options = array_merge($get_options, $saswp_plugin_options);
475
+ $result = update_option('sd_data', $merge_options);
476
+
477
+ if (is_wp_error($result) ){
478
+ echo esc_attr($result->get_error_message());
479
+ $wpdb->query('ROLLBACK');
480
+ }else{
481
+ $wpdb->query('COMMIT');
482
+ return true;
483
+ }
484
+ }
485
+
486
+
487
+ }
488
  function saswp_import_schema_pro_plugin_data(){
489
 
490
  $schema_post = array();
admin_section/css/main-style.css CHANGED
@@ -435,4 +435,23 @@ clear: both;
435
  }
436
  .saswp-enable-review-on-post label{
437
  font-weight: 500;
438
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  }
436
  .saswp-enable-review-on-post label{
437
  font-weight: 500;
438
+ }
439
+ /*
440
+ Compatibility tab css starts here
441
+ */
442
+ .saswp-compatibility table th{
443
+ width: auto;
444
+ padding: 0px;
445
+ }
446
+ .saswp-compatibility .saswp-knowledge-label {
447
+ float: left;
448
+ clear: both;
449
+ }
450
+ .saswp-compatibility .saswp-knowledge-field {
451
+ float: right;
452
+ width: 75%;
453
+ padding-bottom: 10px;
454
+ }
455
+ /*
456
+ Compatibility tab css ends
457
+ */
admin_section/js/main-script.js CHANGED
@@ -39,7 +39,10 @@ jQuery(document).ready(function($){
39
  $(".saswp-option-table-class tr").find('select').attr('disabled', false);
40
  $("#saswp_dayofweek").attr('disabled', false);
41
  $('.select-post-type').val('show_globally').trigger('change');
42
- }
 
 
 
43
  });
44
 
45
  $("#saswp_business_type").change(function(){
@@ -57,7 +60,10 @@ jQuery(document).ready(function($){
57
  $(".saswp-business-text-field-tr").show();
58
  $(".saswp-"+businesstype+'-tr').find('select').attr('disabled', false);
59
  $("#saswp_dayofweek").attr('disabled', false);
60
- }
 
 
 
61
 
62
  }).change();
63
 
@@ -210,6 +216,15 @@ jQuery(document).ready(function($){
210
  }
211
  break;
212
 
 
 
 
 
 
 
 
 
 
213
  case 'saswp_compativility_checkbox':
214
 
215
  if ($(this).is(':checked')) {
@@ -228,6 +243,15 @@ jQuery(document).ready(function($){
228
  }
229
  break;
230
 
 
 
 
 
 
 
 
 
 
231
  default:
232
  break;
233
  }
@@ -284,8 +308,9 @@ jQuery(document).ready(function($){
284
 
285
  $(".saswp-send-query").on("click", function(e){
286
  e.preventDefault();
287
- var message = $("#saswp_query_message").val();
288
- $.ajax({
 
289
  type: "POST",
290
  url:ajaxurl,
291
  dataType: "json",
@@ -303,7 +328,10 @@ jQuery(document).ready(function($){
303
  error: function(response){
304
  console.log(response);
305
  }
306
- });
 
 
 
307
 
308
  });
309
 
39
  $(".saswp-option-table-class tr").find('select').attr('disabled', false);
40
  $("#saswp_dayofweek").attr('disabled', false);
41
  $('.select-post-type').val('show_globally').trigger('change');
42
+ }
43
+ if(schematype == 'Service'){
44
+ $(".saswp-service-text-field-tr").show();
45
+ }
46
  });
47
 
48
  $("#saswp_business_type").change(function(){
60
  $(".saswp-business-text-field-tr").show();
61
  $(".saswp-"+businesstype+'-tr').find('select').attr('disabled', false);
62
  $("#saswp_dayofweek").attr('disabled', false);
63
+ }
64
+ if(schematype == 'Service'){
65
+ $(".saswp-service-text-field-tr").show();
66
+ }
67
 
68
  }).change();
69
 
216
  }
217
  break;
218
 
219
+ case 'saswp_comments_schema_checkbox':
220
+
221
+ if ($(this).is(':checked')) {
222
+ $("#saswp_comments_schema").val(1);
223
+ }else{
224
+ $("#saswp_comments_schema").val(0);
225
+ }
226
+ break;
227
+
228
  case 'saswp_compativility_checkbox':
229
 
230
  if ($(this).is(':checked')) {
243
  }
244
  break;
245
 
246
+ case 'saswp-kk-star-raring-checkbox':
247
+
248
+ if ($(this).is(':checked')) {
249
+ $("#saswp-kk-star-raring").val(1);
250
+ }else{
251
+ $("#saswp-kk-star-raring").val(0);
252
+ }
253
+ break;
254
+
255
  default:
256
  break;
257
  }
308
 
309
  $(".saswp-send-query").on("click", function(e){
310
  e.preventDefault();
311
+ var message = $("#saswp_query_message").val();
312
+ if($.trim(message) !=''){
313
+ $.ajax({
314
  type: "POST",
315
  url:ajaxurl,
316
  dataType: "json",
328
  error: function(response){
329
  console.log(response);
330
  }
331
+ });
332
+ }else{
333
+ alert('Please enter the message');
334
+ }
335
 
336
  });
337
 
admin_section/js/saswp-add-new.js CHANGED
@@ -263,6 +263,9 @@ jQuery(document).ready(function($) {
263
  $("#saswp_dayofweek").attr('disabled', false);
264
  $('.select-post-type').val('show_globally').trigger('change');
265
  }
 
 
 
266
 
267
  }).change();
268
 
@@ -281,7 +284,10 @@ jQuery(document).ready(function($) {
281
  $(".saswp-business-text-field-tr").show();
282
  $(".saswp-"+businesstype+'-tr').find('select').attr('disabled', false);
283
  $("#saswp_dayofweek").attr('disabled', false);
284
- }
 
 
 
285
 
286
  }).change();
287
 
263
  $("#saswp_dayofweek").attr('disabled', false);
264
  $('.select-post-type').val('show_globally').trigger('change');
265
  }
266
+ if(schematype == 'Service'){
267
+ $(".saswp-service-text-field-tr").show();
268
+ }
269
 
270
  }).change();
271
 
284
  $(".saswp-business-text-field-tr").show();
285
  $(".saswp-"+businesstype+'-tr').find('select').attr('disabled', false);
286
  $("#saswp_dayofweek").attr('disabled', false);
287
+ }
288
+ if(schematype == 'Service'){
289
+ $(".saswp-service-text-field-tr").show();
290
+ }
291
 
292
  }).change();
293
 
admin_section/plugin-installer/install.php CHANGED
@@ -66,10 +66,14 @@
66
  return ;
67
  }
68
  global $saswp_installer_config;
69
-
70
- if( wp_verify_nonce($_GET['_saswp_nonce'], 'saswp_install_wizard_nonce')){
 
 
 
71
  saswp_steps_call();
72
- }
 
73
 
74
  }
75
 
66
  return ;
67
  }
68
  global $saswp_installer_config;
69
+ if(!isset($_GET['_saswp_nonce'])){
70
+ return;
71
+ }else{
72
+ $wp_nonce = $_GET['_saswp_nonce'];
73
+ if( wp_verify_nonce($wp_nonce, 'saswp_install_wizard_nonce')){
74
  saswp_steps_call();
75
+ }
76
+ }
77
 
78
  }
79
 
admin_section/settings.php CHANGED
@@ -33,9 +33,9 @@ function saswp_admin_interface_render(){
33
  $is_amp = true;
34
  }
35
  if($is_amp){
36
- $tab = saswp_get_tab('general', array('general','knowledge','schema', 'tools', 'amp','review','support'));
37
  }else{
38
- $tab = saswp_get_tab('general', array('general','knowledge','schema','tools' ,'review','support'));
39
  }
40
 
41
  ?>
@@ -59,6 +59,8 @@ function saswp_admin_interface_render(){
59
 
60
  echo '<a href="' . esc_url(saswp_admin_link('review')) . '" class="nav-tab ' . esc_attr( $tab == 'review' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Review','schema-and-structured-data-for-wp') . '</a>';
61
 
 
 
62
  echo '<a href="' . esc_url(saswp_admin_link('support')) . '" class="nav-tab ' . esc_attr( $tab == 'support' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Support','schema-and-structured-data-for-wp') . '</a>';
63
  ?>
64
 
@@ -96,6 +98,11 @@ function saswp_admin_interface_render(){
96
  do_settings_sections( 'saswp_review_section' ); // Page slug
97
  echo "</div>";
98
 
 
 
 
 
 
99
  echo "<div class='saswp-support' ".( $tab != 'support' ? 'style="display:none;"' : '').">";
100
  // Status
101
  do_settings_sections( 'saswp_support_section' ); // Page slug
@@ -199,6 +206,16 @@ function saswp_settings_init(){
199
  'saswp_review_section' // Settings Section ID
200
  );
201
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  add_settings_section('saswp_support_section', __return_false(), '__return_false', 'saswp_support_section');
204
 
@@ -348,7 +365,19 @@ function saswp_general_page_callback(){
348
  'id' => 'saswp_breadcrumb_schema',
349
  'name' => 'sd_data[saswp_breadcrumb_schema]',
350
  )
351
- ))
 
 
 
 
 
 
 
 
 
 
 
 
352
 
353
  ?>
354
  <div class="saswp-settings-list">
@@ -738,14 +767,19 @@ function saswp_import_callback(){
738
  $message = '<p>'.esc_html__('This plugin\'s data already has been imported. Do you want to import again?. click on button above button.','schema-and-structured-data-for-wp').'</p>';
739
  $schema_message = '';
740
  $schema_pro_message = '';
 
741
  $schema_plugin = saswp_check_data_imported_from('schema');
742
- $schema_pro_plugin = saswp_check_data_imported_from('schema_pro');
 
743
  if($schema_plugin->post_count !=0){
744
  $schema_message =$message;
745
  }
746
  if($schema_pro_plugin->post_count !=0){
747
  $schema_pro_message =$message;
748
  }
 
 
 
749
 
750
  echo '<h2>'.esc_html__('Migration','schema-and-structured-data-for-wp').'</h2>';
751
  ?>
@@ -760,6 +794,11 @@ function saswp_import_callback(){
760
  <?php echo $schema_pro_message; ?>
761
  </div>
762
  </li>
 
 
 
 
 
763
  </ul>
764
  <?php
765
  echo '<h2>'.esc_html__('Import / Export','schema-and-structured-data-for-wp').'</h2>';
@@ -897,6 +936,33 @@ function saswp_review_page_callback(){
897
  $field_objs->saswp_field_generator($meta_fields, $settings);
898
 
899
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
900
 
901
  function saswp_support_page_callback(){
902
 
33
  $is_amp = true;
34
  }
35
  if($is_amp){
36
+ $tab = saswp_get_tab('general', array('general','knowledge','schema', 'tools', 'amp','review','compatibility','support'));
37
  }else{
38
+ $tab = saswp_get_tab('general', array('general','knowledge','schema','tools' ,'review','compatibility','support'));
39
  }
40
 
41
  ?>
59
 
60
  echo '<a href="' . esc_url(saswp_admin_link('review')) . '" class="nav-tab ' . esc_attr( $tab == 'review' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Review','schema-and-structured-data-for-wp') . '</a>';
61
 
62
+ echo '<a href="' . esc_url(saswp_admin_link('compatibility')) . '" class="nav-tab ' . esc_attr( $tab == 'compatibility' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Compatibility','schema-and-structured-data-for-wp') . '</a>';
63
+
64
  echo '<a href="' . esc_url(saswp_admin_link('support')) . '" class="nav-tab ' . esc_attr( $tab == 'support' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Support','schema-and-structured-data-for-wp') . '</a>';
65
  ?>
66
 
98
  do_settings_sections( 'saswp_review_section' ); // Page slug
99
  echo "</div>";
100
 
101
+ echo "<div class='saswp-compatibility' ".( $tab != 'compatibility' ? 'style="display:none;"' : '').">";
102
+ // Status
103
+ do_settings_sections( 'saswp_compatibility_section' ); // Page slug
104
+ echo "</div>";
105
+
106
  echo "<div class='saswp-support' ".( $tab != 'support' ? 'style="display:none;"' : '').">";
107
  // Status
108
  do_settings_sections( 'saswp_support_section' ); // Page slug
206
  'saswp_review_section' // Settings Section ID
207
  );
208
 
209
+ add_settings_section('saswp_compatibility_section', __return_false(), '__return_false', 'saswp_compatibility_section');
210
+
211
+ add_settings_field(
212
+ 'saswp_compatibility_settings', // ID
213
+ '', // Title
214
+ 'saswp_compatibility_page_callback', // CB
215
+ 'saswp_compatibility_section', // Page slug
216
+ 'saswp_compatibility_section' // Settings Section ID
217
+ );
218
+
219
 
220
  add_settings_section('saswp_support_section', __return_false(), '__return_false', 'saswp_support_section');
221
 
365
  'id' => 'saswp_breadcrumb_schema',
366
  'name' => 'sd_data[saswp_breadcrumb_schema]',
367
  )
368
+ ),
369
+ array(
370
+ 'label' => 'Comments',
371
+ 'id' => 'saswp_comments_schema_checkbox',
372
+ 'name' => 'saswp_comments_schema_checkbox',
373
+ 'type' => 'checkbox',
374
+ 'class' => 'checkbox saswp-checkbox',
375
+ 'hidden' => array(
376
+ 'id' => 'saswp_comments_schema',
377
+ 'name' => 'sd_data[saswp_comments_schema]',
378
+ )
379
+ )
380
+ )
381
 
382
  ?>
383
  <div class="saswp-settings-list">
767
  $message = '<p>'.esc_html__('This plugin\'s data already has been imported. Do you want to import again?. click on button above button.','schema-and-structured-data-for-wp').'</p>';
768
  $schema_message = '';
769
  $schema_pro_message = '';
770
+ $wp_seo_schema_message = '';
771
  $schema_plugin = saswp_check_data_imported_from('schema');
772
+ $schema_pro_plugin = saswp_check_data_imported_from('schema_pro');
773
+ $wp_seo_schema_plugin = saswp_check_data_imported_from('wp_seo_schema');
774
  if($schema_plugin->post_count !=0){
775
  $schema_message =$message;
776
  }
777
  if($schema_pro_plugin->post_count !=0){
778
  $schema_pro_message =$message;
779
  }
780
+ if($wp_seo_schema_plugin->post_count !=0){
781
+ $wp_seo_schema_message =$message;
782
+ }
783
 
784
  echo '<h2>'.esc_html__('Migration','schema-and-structured-data-for-wp').'</h2>';
785
  ?>
794
  <?php echo $schema_pro_message; ?>
795
  </div>
796
  </li>
797
+ <li><div class="saswp-tools-field-title"><div class="saswp-tooltip"><span class="saswp-tooltiptext"><?php echo esc_html__('All the settings and data you can import from this plugin when you click start importing','schema-and-structured-data-for-wp') ?></span><strong><?php echo esc_html__('WP SEO Schema','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="wp_seo_schema" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
798
+ <p class="saswp-imported-message"></p>
799
+ <?php echo $wp_seo_schema_message; ?>
800
+ </div>
801
+ </li>
802
  </ul>
803
  <?php
804
  echo '<h2>'.esc_html__('Import / Export','schema-and-structured-data-for-wp').'</h2>';
936
  $field_objs->saswp_field_generator($meta_fields, $settings);
937
 
938
  }
939
+ function saswp_compatibility_page_callback(){
940
+
941
+ $settings = saswp_defaultSettings();
942
+ $field_objs = new saswp_fields_generator();
943
+ $meta_fields = array(
944
+ array(
945
+ 'label' => 'kk Star Ratings',
946
+ 'id' => 'saswp-kk-star-raring-checkbox',
947
+ 'name' => 'saswp-kk-star-raring-checkbox',
948
+ 'type' => 'checkbox',
949
+ 'class' => 'checkbox saswp-checkbox',
950
+ 'hidden' => array(
951
+ 'id' => 'saswp-kk-star-raring',
952
+ 'name' => 'sd_data[saswp-kk-star-raring]',
953
+ )
954
+ ),
955
+
956
+ );
957
+ if(is_plugin_active('kk-star-ratings/index.php')){
958
+ $field_objs->saswp_field_generator($meta_fields, $settings);
959
+ }else{
960
+ echo '<p>'.esc_html__('None of the plugin is active which has compatibility with Schema & Structured Data For WP', 'schema-and-structured-data-for-wp').'</p>';
961
+ }
962
+
963
+
964
+ }
965
+
966
 
967
  function saswp_support_page_callback(){
968
 
admin_section/structure_admin.php CHANGED
@@ -886,6 +886,11 @@ function saswp_import_plugin_data(){
886
  if ( is_plugin_active('wp-schema-pro/wp-schema-pro.php')) {
887
  $result = saswp_import_schema_pro_plugin_data();
888
  }
 
 
 
 
 
889
  break;
890
 
891
  default:
886
  if ( is_plugin_active('wp-schema-pro/wp-schema-pro.php')) {
887
  $result = saswp_import_schema_pro_plugin_data();
888
  }
889
+ break;
890
+ case 'wp_seo_schema':
891
+ if ( is_plugin_active('wp-seo-structured-data-schema/wp-seo-structured-data-schema.php')) {
892
+ $result = saswp_import_wp_seo_schema_plugin_data();
893
+ }
894
  break;
895
 
896
  default:
output/output.php CHANGED
@@ -2,10 +2,7 @@
2
  if (! defined('ABSPATH') ) exit;
3
 
4
  function saswp_kb_schema_output() {
5
- global $sd_data;
6
- if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
7
- return ;
8
- }
9
  // social profile
10
  $sd_social_profile = array();
11
 
@@ -163,17 +160,14 @@ function sd_is_blog() {
163
  return ( is_author() || is_category() || is_tag() || is_date() || is_home() || is_single() ) && 'post' == get_post_type();
164
  }
165
 
166
- function saswp_schema_output() {
167
  global $sd_data;
168
 
169
  $Conditionals = saswp_get_all_schema_posts();
170
 
171
  if(!$Conditionals){
172
  return ;
173
- }
174
- if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
175
- return ;
176
- }
177
  $all_schema_output = array();
178
  foreach($Conditionals as $schemaConditionals){
179
 
@@ -206,6 +200,7 @@ function saswp_schema_output() {
206
 
207
  $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
208
  $aggregateRating = array();
 
209
 
210
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
211
  $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
@@ -224,6 +219,16 @@ function saswp_schema_output() {
224
  "reviewCount" => $saswp_review_count
225
  );
226
  }
 
 
 
 
 
 
 
 
 
 
227
 
228
  if(is_page()){
229
  $schema_type = $schema_type; //$sd_data['sd_page_type'];
@@ -259,6 +264,16 @@ function saswp_schema_output() {
259
  'name' => $sd_data['sd_name'],
260
  ),
261
  );
 
 
 
 
 
 
 
 
 
 
262
  // For WebPage
263
  if( 'WebPage' === $schema_type){
264
 
@@ -298,9 +313,15 @@ function saswp_schema_output() {
298
 
299
 
300
  );
 
 
 
301
  if(!empty($aggregateRating)){
302
  $input1['mainEntity']['aggregateRating'] = $aggregateRating;
303
  }
 
 
 
304
  }
305
 
306
  // For Article
@@ -332,6 +353,9 @@ function saswp_schema_output() {
332
  ),
333
 
334
  );
 
 
 
335
  }
336
 
337
  // Recipe
@@ -376,9 +400,15 @@ function saswp_schema_output() {
376
  ),
377
 
378
  );
 
 
 
379
  if(!empty($aggregateRating)){
380
  $input1['aggregateRating'] = $aggregateRating;
381
  }
 
 
 
382
  }
383
 
384
  // Product
@@ -394,24 +424,37 @@ function saswp_schema_output() {
394
  'url' => get_permalink(),
395
  'name' => get_the_title(),
396
  'description' => get_the_excerpt(),
397
- );
398
  if(!empty($aggregateRating)){
399
  $input1['aggregateRating'] = $aggregateRating;
400
  }
 
 
 
401
  }
402
 
403
- if( 'NewsArticle' === $schema_type ){
404
- $input1 = array(
 
 
 
 
 
 
405
  '@context' => 'http://schema.org',
406
- '@type' => $schema_type ,
407
- 'mainEntityOfPage' => get_permalink(),
408
  'url' => get_permalink(),
409
  'headline' => get_the_title(),
 
410
  'datePublished' => $date,
411
  'dateModified' => $modified_date,
412
  'description' => get_the_excerpt(),
 
 
413
  'name' => get_the_title(),
414
  'thumbnailUrl' => $image_details[0],
 
 
415
  'mainEntity' => array(
416
  '@type' => 'WebPage',
417
  '@id' => get_permalink(),
@@ -437,10 +480,78 @@ function saswp_schema_output() {
437
  'name' => $sd_data['sd_name'],
438
  ),
439
  );
 
 
 
 
 
440
  if(!empty($aggregateRating)){
441
  $input1['aggregateRating'] = $aggregateRating;
442
  }
 
 
 
443
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
 
445
  // VideoObject
446
  if( 'VideoObject' === $schema_type){
@@ -486,9 +597,15 @@ function saswp_schema_output() {
486
  ),
487
 
488
  );
 
 
 
489
  if(!empty($aggregateRating)){
490
  $input1['aggregateRating'] = $aggregateRating;
491
- }
 
 
 
492
 
493
  }
494
 
@@ -532,11 +649,13 @@ function saswp_schema_output() {
532
  'closes'=> $business_details['local_closes_time'],
533
  ),
534
 
535
- );
536
  if(!empty($aggregateRating)){
537
  $input1['aggregateRating'] = $aggregateRating;
538
  }
539
-
 
 
540
  if(isset($business_details['local_price_range'])){
541
  $input1['priceRange'] = $business_details['local_price_range'];
542
  }
@@ -646,6 +765,15 @@ function saswp_post_specific_schema_output() {
646
  "reviewCount" => $saswp_review_count
647
  );
648
  }
 
 
 
 
 
 
 
 
 
649
 
650
  if( 'Blogposting' === $schema_type){
651
  // Blogposting Schema
@@ -674,6 +802,12 @@ function saswp_post_specific_schema_output() {
674
  'name' => $all_post_meta['saswp_blogposting_organization_name_'.$schema_id][0],
675
  ),
676
  );
 
 
 
 
 
 
677
  }
678
 
679
  if( 'WebPage' === $schema_type){
@@ -712,6 +846,9 @@ function saswp_post_specific_schema_output() {
712
  if(!empty($aggregateRating)){
713
  $input1['mainEntity']['aggregateRating'] = $aggregateRating;
714
  }
 
 
 
715
  }
716
 
717
  if( 'Article' === $schema_type ){
@@ -782,6 +919,9 @@ function saswp_post_specific_schema_output() {
782
  if(!empty($aggregateRating)){
783
  $input1['aggregateRating'] = $aggregateRating;
784
  }
 
 
 
785
  }
786
 
787
  if( 'Product' === $schema_type){
@@ -797,10 +937,14 @@ function saswp_post_specific_schema_output() {
797
  if(!empty($aggregateRating)){
798
  $input1['aggregateRating'] = $aggregateRating;
799
  }
 
 
 
800
  }
801
 
802
  if( 'NewsArticle' === $schema_type ){
803
- $input1 = array(
 
804
  '@context' => 'http://schema.org',
805
  '@type' => $schema_type ,
806
  'mainEntityOfPage' => $all_post_meta['saswp_newsarticle_main_entity_of_page_'.$schema_id][0],
@@ -809,8 +953,12 @@ function saswp_post_specific_schema_output() {
809
  'datePublished' => $all_post_meta['saswp_newsarticle_date_published_'.$schema_id][0],
810
  'dateModified' => $all_post_meta['saswp_newsarticle_date_modified_'.$schema_id][0],
811
  'description' => $all_post_meta['saswp_newsarticle_description_'.$schema_id][0],
 
 
812
  'name' => $all_post_meta['saswp_newsarticle_name_'.$schema_id][0],
813
  'thumbnailUrl' => $all_post_meta['saswp_newsarticle_thumbnailurl_'.$schema_id][0],
 
 
814
  'mainEntity' => array(
815
  '@type' => 'WebPage',
816
  '@id' => $all_post_meta['saswp_newsarticle_main_entity_id_'.$schema_id][0],
@@ -837,7 +985,10 @@ function saswp_post_specific_schema_output() {
837
  ),
838
  );
839
  if(!empty($aggregateRating)){
840
- $input1['aggregateRating'] = $aggregateRating;
 
 
 
841
  }
842
  }
843
 
@@ -880,11 +1031,70 @@ function saswp_post_specific_schema_output() {
880
  ),
881
  );
882
  if(!empty($aggregateRating)){
883
- $input1['aggregateRating'] = $aggregateRating;
884
- }
 
 
 
885
 
886
  }
887
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
888
  if( 'local_business' === $schema_type){
889
 
890
  $business_sub_name ='';
@@ -924,6 +1134,9 @@ function saswp_post_specific_schema_output() {
924
  if(!empty($aggregateRating)){
925
  $input1['aggregateRating'] = $aggregateRating;
926
  }
 
 
 
927
  if(isset($all_post_meta['local_price_range_'.$schema_id][0])){
928
  $input1['priceRange'] = $all_post_meta['local_price_range_'.$schema_id][0];
929
  }
@@ -1056,11 +1269,7 @@ function saswp_list_items_generator(){
1056
  }
1057
 
1058
  function saswp_schema_breadcrumb_output($sd_data){
1059
- global $sd_data;
1060
-
1061
- if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
1062
- return ;
1063
- }
1064
 
1065
  if(isset($sd_data['saswp_breadcrumb_schema']) && $sd_data['saswp_breadcrumb_schema'] == 1){
1066
 
@@ -1081,10 +1290,7 @@ function saswp_schema_breadcrumb_output($sd_data){
1081
  }
1082
 
1083
  function saswp_kb_website_output(){
1084
- global $sd_data;
1085
- if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
1086
- return ;
1087
- }
1088
  $site_url = get_site_url();
1089
  $site_name = get_bloginfo();
1090
  $input = array(
@@ -1105,9 +1311,7 @@ function saswp_kb_website_output(){
1105
  // For Archive
1106
  function saswp_archive_output(){
1107
  global $query_string, $sd_data;
1108
- if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
1109
- return ;
1110
- }
1111
  if(isset($sd_data['saswp_archive_schema']) && $sd_data['saswp_archive_schema'] == 1){
1112
 
1113
  if ( is_category() ) {
@@ -1118,10 +1322,15 @@ function saswp_archive_output(){
1118
  $image_id = get_post_thumbnail_id();
1119
  $image_details = wp_get_attachment_image_src($image_id, 'full');
1120
  $publisher_info = array(
1121
- "type" => "Organization",
1122
  "name" => $sd_data['sd_name'],
1123
- "id" => $sd_data['sd_url'],
1124
- "logo" => $sd_data['sd_logo']['url'],
 
 
 
 
 
1125
  );
1126
  $publisher_info['name'] = get_bloginfo('name');
1127
  $publisher_info['id'] = get_the_permalink();
@@ -1152,7 +1361,7 @@ function saswp_archive_output(){
1152
  '@context' => 'http://schema.org/',
1153
  '@type' => "CollectionPage",
1154
  'headline' => $category_headline,
1155
- 'description' => strip_tags(category_description()),
1156
  'url' => $category_link,
1157
  'sameAs' => '',
1158
  'hasPart' => $category_posts
@@ -1331,4 +1540,88 @@ function saswp_contact_page_output()
1331
 
1332
  }
1333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1334
  }
2
  if (! defined('ABSPATH') ) exit;
3
 
4
  function saswp_kb_schema_output() {
5
+ global $sd_data;
 
 
 
6
  // social profile
7
  $sd_social_profile = array();
8
 
160
  return ( is_author() || is_category() || is_tag() || is_date() || is_home() || is_single() ) && 'post' == get_post_type();
161
  }
162
 
163
+ function saswp_schema_output() {
164
  global $sd_data;
165
 
166
  $Conditionals = saswp_get_all_schema_posts();
167
 
168
  if(!$Conditionals){
169
  return ;
170
+ }
 
 
 
171
  $all_schema_output = array();
172
  foreach($Conditionals as $schemaConditionals){
173
 
200
 
201
  $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
202
  $aggregateRating = array();
203
+ $kkstar_aggregateRating = array();
204
 
205
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
206
  $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
219
  "reviewCount" => $saswp_review_count
220
  );
221
  }
222
+
223
+ $kkstar_rating_data = saswp_extract_kk_star_ratings(get_the_ID());
224
+ if(!empty($kkstar_rating_data)){
225
+ $kkstar_aggregateRating = array(
226
+ "@type"=> "AggregateRating",
227
+ "bestRating" => $kkstar_rating_data['best'],
228
+ "ratingCount" => $kkstar_rating_data['votes'],
229
+ "ratingValue" => $kkstar_rating_data['avg']
230
+ );
231
+ }
232
 
233
  if(is_page()){
234
  $schema_type = $schema_type; //$sd_data['sd_page_type'];
264
  'name' => $sd_data['sd_name'],
265
  ),
266
  );
267
+ if(!empty($aggregateRating)){
268
+ $input1['aggregateRating'] = $aggregateRating;
269
+ }
270
+ if(!empty($kkstar_aggregateRating)){
271
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
272
+ }
273
+
274
+ if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
275
+ $input1['comment'] = saswp_get_comments(get_the_ID());
276
+ }
277
  // For WebPage
278
  if( 'WebPage' === $schema_type){
279
 
313
 
314
 
315
  );
316
+ if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
317
+ $input1['comment'] = saswp_get_comments(get_the_ID());
318
+ }
319
  if(!empty($aggregateRating)){
320
  $input1['mainEntity']['aggregateRating'] = $aggregateRating;
321
  }
322
+ if(!empty($kkstar_aggregateRating)){
323
+ $input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
324
+ }
325
  }
326
 
327
  // For Article
353
  ),
354
 
355
  );
356
+ if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
357
+ $input1['comment'] = saswp_get_comments(get_the_ID());
358
+ }
359
  }
360
 
361
  // Recipe
400
  ),
401
 
402
  );
403
+ if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
404
+ $input1['comment'] = saswp_get_comments(get_the_ID());
405
+ }
406
  if(!empty($aggregateRating)){
407
  $input1['aggregateRating'] = $aggregateRating;
408
  }
409
+ if(!empty($kkstar_aggregateRating)){
410
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
411
+ }
412
  }
413
 
414
  // Product
424
  'url' => get_permalink(),
425
  'name' => get_the_title(),
426
  'description' => get_the_excerpt(),
427
+ );
428
  if(!empty($aggregateRating)){
429
  $input1['aggregateRating'] = $aggregateRating;
430
  }
431
+ if(!empty($kkstar_aggregateRating)){
432
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
433
+ }
434
  }
435
 
436
+ if( 'NewsArticle' === $schema_type ){
437
+ $category_detail=get_the_category(get_the_ID());//$post->ID
438
+ $article_section = '';
439
+ foreach($category_detail as $cd){
440
+ $article_section = $cd->cat_name;
441
+ }
442
+ $word_count = saswp_reading_time_and_word_count();
443
+ $input1 = array(
444
  '@context' => 'http://schema.org',
445
+ '@type' => $schema_type ,
 
446
  'url' => get_permalink(),
447
  'headline' => get_the_title(),
448
+ 'mainEntityOfPage' => get_the_permalink(),
449
  'datePublished' => $date,
450
  'dateModified' => $modified_date,
451
  'description' => get_the_excerpt(),
452
+ 'articleSection' => $article_section,
453
+ 'articleBody' => get_the_content(),
454
  'name' => get_the_title(),
455
  'thumbnailUrl' => $image_details[0],
456
+ 'wordCount' => $word_count['word_count'],
457
+ 'timeRequired' => $word_count['timerequired'],
458
  'mainEntity' => array(
459
  '@type' => 'WebPage',
460
  '@id' => get_permalink(),
480
  'name' => $sd_data['sd_name'],
481
  ),
482
  );
483
+
484
+ if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
485
+ $input1['comment'] = saswp_get_comments(get_the_ID());
486
+ }
487
+
488
  if(!empty($aggregateRating)){
489
  $input1['aggregateRating'] = $aggregateRating;
490
  }
491
+ if(!empty($kkstar_aggregateRating)){
492
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
493
+ }
494
  }
495
+
496
+
497
+ if( 'Service' === $schema_type ){
498
+
499
+ $schema_data = saswp_get_schema_data($schema_post_id, 'saswp_service_schema_details');
500
+
501
+ $area_served_str = $schema_data['saswp_service_schema_area_served'];
502
+ $area_served_arr = explode(',', $area_served_str);
503
+
504
+ $service_offer_str = $schema_data['saswp_service_schema_service_offer'];
505
+ $service_offer_arr = explode(',', $service_offer_str);
506
+
507
+ $input1 = array(
508
+ '@context' => 'http://schema.org',
509
+ '@type' => $schema_type ,
510
+ 'name' => $schema_data['saswp_service_schema_name'],
511
+ 'serviceType' => $schema_data['saswp_service_schema_type'],
512
+ 'provider' => array(
513
+ '@type' => 'LocalBusiness',
514
+ 'name' => $schema_data['saswp_service_schema_provider_name'],
515
+ 'image' => $schema_data['saswp_service_schema_image']['url'],
516
+ '@id' => get_permalink(),
517
+ 'address' => array(
518
+ '@type' => 'PostalAddress',
519
+ 'addressLocality' => $schema_data['saswp_service_schema_locality'],
520
+ 'postalCode' => $schema_data['saswp_service_schema_postal_code'],
521
+ 'telephone' => $schema_data['saswp_service_schema_telephone']
522
+ ),
523
+ 'priceRange' => $schema_data['saswp_service_schema_price_range'],
524
+ ),
525
+ 'description' => $schema_data['saswp_service_schema_description'],
526
+ );
527
+ $areaServed = array();
528
+ foreach($area_served_arr as $area){
529
+ $areaServed[] = array(
530
+ '@type' => 'City',
531
+ 'name' => $area
532
+ );
533
+ }
534
+ $serviceOffer = array();
535
+ foreach($service_offer_arr as $offer){
536
+ $serviceOffer[] = array(
537
+ '@type' => 'Offer',
538
+ 'name' => $offer
539
+ );
540
+ }
541
+ $input1['areaServed'] = $areaServed;
542
+ $input1['hasOfferCatalog'] = array(
543
+ '@type' => 'OfferCatalog',
544
+ 'name' => $schema_data['saswp_service_schema_name'],
545
+ 'itemListElement' => $serviceOffer
546
+ );
547
+
548
+ if(!empty($aggregateRating)){
549
+ $input1['aggregateRating'] = $aggregateRating;
550
+ }
551
+ if(!empty($kkstar_aggregateRating)){
552
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
553
+ }
554
+ }
555
 
556
  // VideoObject
557
  if( 'VideoObject' === $schema_type){
597
  ),
598
 
599
  );
600
+ if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
601
+ $input1['comment'] = saswp_get_comments(get_the_ID());
602
+ }
603
  if(!empty($aggregateRating)){
604
  $input1['aggregateRating'] = $aggregateRating;
605
+ }
606
+ if(!empty($kkstar_aggregateRating)){
607
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
608
+ }
609
 
610
  }
611
 
649
  'closes'=> $business_details['local_closes_time'],
650
  ),
651
 
652
+ );
653
  if(!empty($aggregateRating)){
654
  $input1['aggregateRating'] = $aggregateRating;
655
  }
656
+ if(!empty($kkstar_aggregateRating)){
657
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
658
+ }
659
  if(isset($business_details['local_price_range'])){
660
  $input1['priceRange'] = $business_details['local_price_range'];
661
  }
765
  "reviewCount" => $saswp_review_count
766
  );
767
  }
768
+ $kkstar_rating_data = saswp_extract_kk_star_ratings(get_the_ID());
769
+ if(!empty($kkstar_rating_data)){
770
+ $kkstar_aggregateRating = array(
771
+ "@type"=> "AggregateRating",
772
+ "bestRating" => $kkstar_rating_data['best'],
773
+ "ratingCount" => $kkstar_rating_data['votes'],
774
+ "ratingValue" => $kkstar_rating_data['avg']
775
+ );
776
+ }
777
 
778
  if( 'Blogposting' === $schema_type){
779
  // Blogposting Schema
802
  'name' => $all_post_meta['saswp_blogposting_organization_name_'.$schema_id][0],
803
  ),
804
  );
805
+ if(!empty($aggregateRating)){
806
+ $input1['aggregateRating'] = $aggregateRating;
807
+ }
808
+ if(!empty($kkstar_aggregateRating)){
809
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
810
+ }
811
  }
812
 
813
  if( 'WebPage' === $schema_type){
846
  if(!empty($aggregateRating)){
847
  $input1['mainEntity']['aggregateRating'] = $aggregateRating;
848
  }
849
+ if(!empty($kkstar_aggregateRating)){
850
+ $input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
851
+ }
852
  }
853
 
854
  if( 'Article' === $schema_type ){
919
  if(!empty($aggregateRating)){
920
  $input1['aggregateRating'] = $aggregateRating;
921
  }
922
+ if(!empty($kkstar_aggregateRating)){
923
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
924
+ }
925
  }
926
 
927
  if( 'Product' === $schema_type){
937
  if(!empty($aggregateRating)){
938
  $input1['aggregateRating'] = $aggregateRating;
939
  }
940
+ if(!empty($kkstar_aggregateRating)){
941
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
942
+ }
943
  }
944
 
945
  if( 'NewsArticle' === $schema_type ){
946
+
947
+ $input1 = array(
948
  '@context' => 'http://schema.org',
949
  '@type' => $schema_type ,
950
  'mainEntityOfPage' => $all_post_meta['saswp_newsarticle_main_entity_of_page_'.$schema_id][0],
953
  'datePublished' => $all_post_meta['saswp_newsarticle_date_published_'.$schema_id][0],
954
  'dateModified' => $all_post_meta['saswp_newsarticle_date_modified_'.$schema_id][0],
955
  'description' => $all_post_meta['saswp_newsarticle_description_'.$schema_id][0],
956
+ 'articleSection' => $all_post_meta['saswp_newsarticle_section_'.$schema_id][0],
957
+ 'articleBody' => $all_post_meta['saswp_newsarticle_body_'.$schema_id][0],
958
  'name' => $all_post_meta['saswp_newsarticle_name_'.$schema_id][0],
959
  'thumbnailUrl' => $all_post_meta['saswp_newsarticle_thumbnailurl_'.$schema_id][0],
960
+ 'wordCount' => $all_post_meta['saswp_newsarticle_word_count_'.$schema_id][0],
961
+ 'timeRequired' => $all_post_meta['saswp_newsarticle_timerequired_'.$schema_id][0],
962
  'mainEntity' => array(
963
  '@type' => 'WebPage',
964
  '@id' => $all_post_meta['saswp_newsarticle_main_entity_id_'.$schema_id][0],
985
  ),
986
  );
987
  if(!empty($aggregateRating)){
988
+ $input1['aggregateRating'] = $aggregateRating;
989
+ }
990
+ if(!empty($kkstar_aggregateRating)){
991
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
992
  }
993
  }
994
 
1031
  ),
1032
  );
1033
  if(!empty($aggregateRating)){
1034
+ $input1['aggregateRating'] = $aggregateRating;
1035
+ }
1036
+ if(!empty($kkstar_aggregateRating)){
1037
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
1038
+ }
1039
 
1040
  }
1041
 
1042
+ if( 'Service' === $schema_type ){
1043
+ $area_served_str = $all_post_meta['saswp_service_schema_area_served_'.$schema_id][0];
1044
+ $area_served_arr = explode(',', $area_served_str);
1045
+
1046
+ $service_offer_str = $all_post_meta['saswp_service_schema_service_offer_'.$schema_id][0];
1047
+ $service_offer_arr = explode(',', $service_offer_str);
1048
+
1049
+ $input1 = array(
1050
+ '@context' => 'http://schema.org',
1051
+ '@type' => $schema_type ,
1052
+ 'name' => $all_post_meta['saswp_service_schema_name_'.$schema_id][0],
1053
+ 'serviceType' => $all_post_meta['saswp_service_schema_type_'.$schema_id][0],
1054
+ 'provider' => array(
1055
+ '@type' => 'LocalBusiness',
1056
+ 'name' => $all_post_meta['saswp_service_schema_provider_name_'.$schema_id][0],
1057
+ 'image' => $all_post_meta['saswp_service_schema_image_'.$schema_id][0],
1058
+ '@id' => get_permalink(),
1059
+ 'address' => array(
1060
+ '@type' => 'PostalAddress',
1061
+ 'addressLocality' => $all_post_meta['saswp_service_schema_locality_'.$schema_id][0],
1062
+ 'postalCode' => $all_post_meta['saswp_service_schema_postal_code_'.$schema_id][0],
1063
+ 'telephone' => $all_post_meta['saswp_service_schema_telephone_'.$schema_id][0]
1064
+ ),
1065
+ 'priceRange' => $all_post_meta['saswp_service_schema_price_range_'.$schema_id][0],
1066
+ ),
1067
+ 'description' => $all_post_meta['saswp_service_schema_description_'.$schema_id][0],
1068
+ );
1069
+ $areaServed = array();
1070
+ foreach($area_served_arr as $area){
1071
+ $areaServed[] = array(
1072
+ '@type' => 'City',
1073
+ 'name' => $area
1074
+ );
1075
+ }
1076
+ $serviceOffer = array();
1077
+ foreach($service_offer_arr as $offer){
1078
+ $serviceOffer[] = array(
1079
+ '@type' => 'Offer',
1080
+ 'name' => $offer
1081
+ );
1082
+ }
1083
+ $input1['areaServed'] = $areaServed;
1084
+ $input1['hasOfferCatalog'] = array(
1085
+ '@type' => 'OfferCatalog',
1086
+ 'name' => $schema_data['saswp_service_schema_name'],
1087
+ 'itemListElement' => $serviceOffer
1088
+ );
1089
+
1090
+ if(!empty($aggregateRating)){
1091
+ $input1['aggregateRating'] = $aggregateRating;
1092
+ }
1093
+ if(!empty($kkstar_aggregateRating)){
1094
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
1095
+ }
1096
+ }
1097
+
1098
  if( 'local_business' === $schema_type){
1099
 
1100
  $business_sub_name ='';
1134
  if(!empty($aggregateRating)){
1135
  $input1['aggregateRating'] = $aggregateRating;
1136
  }
1137
+ if(!empty($kkstar_aggregateRating)){
1138
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
1139
+ }
1140
  if(isset($all_post_meta['local_price_range_'.$schema_id][0])){
1141
  $input1['priceRange'] = $all_post_meta['local_price_range_'.$schema_id][0];
1142
  }
1269
  }
1270
 
1271
  function saswp_schema_breadcrumb_output($sd_data){
1272
+ global $sd_data;
 
 
 
 
1273
 
1274
  if(isset($sd_data['saswp_breadcrumb_schema']) && $sd_data['saswp_breadcrumb_schema'] == 1){
1275
 
1290
  }
1291
 
1292
  function saswp_kb_website_output(){
1293
+ global $sd_data;
 
 
 
1294
  $site_url = get_site_url();
1295
  $site_name = get_bloginfo();
1296
  $input = array(
1311
  // For Archive
1312
  function saswp_archive_output(){
1313
  global $query_string, $sd_data;
1314
+
 
 
1315
  if(isset($sd_data['saswp_archive_schema']) && $sd_data['saswp_archive_schema'] == 1){
1316
 
1317
  if ( is_category() ) {
1322
  $image_id = get_post_thumbnail_id();
1323
  $image_details = wp_get_attachment_image_src($image_id, 'full');
1324
  $publisher_info = array(
1325
+ "type" => "Organization",
1326
  "name" => $sd_data['sd_name'],
1327
+ "logo" => array(
1328
+ "@type" => "ImageObject",
1329
+ "name" => $sd_data['sd_name'],
1330
+ "width" => $sd_data['sd_logo']['width'],
1331
+ "height"=> $sd_data['sd_logo']['height'],
1332
+ "url"=> $sd_data['sd_logo']['url']
1333
+ )
1334
  );
1335
  $publisher_info['name'] = get_bloginfo('name');
1336
  $publisher_info['id'] = get_the_permalink();
1361
  '@context' => 'http://schema.org/',
1362
  '@type' => "CollectionPage",
1363
  'headline' => $category_headline,
1364
+ 'description' => strip_tags(category_description()),
1365
  'url' => $category_link,
1366
  'sameAs' => '',
1367
  'hasPart' => $category_posts
1540
 
1541
  }
1542
 
1543
+ }
1544
+
1545
+
1546
+ function saswp_get_comments($post_id){
1547
+
1548
+ $comment_count = get_comments_number( $post_id );
1549
+ if ( $comment_count < 1 ) {
1550
+ return array();
1551
+ }
1552
+ $comments = array();
1553
+
1554
+ $count = apply_filters( 'saswp_do_comments', '10'); // default = 10
1555
+
1556
+ $post_comments = get_comments( array(
1557
+ 'post_id' => $post_id,
1558
+ 'number' => $count,
1559
+ 'status' => 'approve',
1560
+ 'type' => 'comment'
1561
+ )
1562
+ );
1563
+
1564
+ if ( count( $post_comments ) ) {
1565
+ foreach ( $post_comments as $comment ) {
1566
+ $comments[] = array (
1567
+ '@type' => 'Comment',
1568
+ 'dateCreated' => $comment->comment_date,
1569
+ 'description' => $comment->comment_content,
1570
+ 'author' => array (
1571
+ '@type' => 'Person',
1572
+ 'name' => $comment->comment_author,
1573
+ 'url' => $comment->comment_author_url,
1574
+ ),
1575
+ );
1576
+ }
1577
+ return apply_filters( 'saswp_filter_comments', $comments );
1578
+ }
1579
+
1580
+ }
1581
+
1582
+ function saswp_get_schema_data($schema_id, $schema_key){
1583
+ $details = array();
1584
+ if($schema_id && $schema_key){
1585
+ $details = esc_sql ( get_post_meta($schema_id, $schema_key, true));
1586
+ }
1587
+ return $details;
1588
+ }
1589
+
1590
+ function saswp_extract_kk_star_ratings($id)
1591
+ {
1592
+ global $sd_data;
1593
+
1594
+ if(isset($sd_data['saswp-kk-star-raring']) && $sd_data['saswp-kk-star-raring'] ==1){
1595
+
1596
+ $best = get_option('kksr_stars');
1597
+ $score = get_post_meta($id, '_kksr_ratings', true) ? ((int) get_post_meta($id, '_kksr_ratings', true)) : 0;
1598
+ $votes = get_post_meta($id, '_kksr_casts', true) ? ((int) get_post_meta($id, '_kksr_casts', true)) : 0;
1599
+ $avg = $score && $votes ? round((float)(($score/$votes)*($best/5)), 1) : 0;
1600
+ $per = $score && $votes ? round((float)((($score/$votes)/5)*100), 2) : 0;
1601
+ if($votes>0){
1602
+ return compact('best', 'score', 'votes', 'avg', 'per');
1603
+ }else{
1604
+ return array();
1605
+ }
1606
+
1607
+ }else{
1608
+ return array();
1609
+ }
1610
+ }
1611
+
1612
+ function saswp_reading_time_and_word_count() {
1613
+
1614
+ // Predefined words-per-minute rate.
1615
+ $words_per_minute = 225;
1616
+ $words_per_second = $words_per_minute / 60;
1617
+
1618
+ // Count the words in the content.
1619
+ $word_count =0;
1620
+ $text = trim( strip_tags( get_the_content() ) );
1621
+ $word_count = substr_count( "$text ", ' ' );
1622
+
1623
+ // How many seconds (total)?
1624
+ $seconds = floor( $word_count / $words_per_second );
1625
+
1626
+ return array('word_count' => $word_count, 'timerequired' => $seconds);
1627
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 4.9.8
6
- Stable tag: 1.0.4.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -65,11 +65,24 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
 
68
  = 1.0.4.1 (17 November 2018) =
69
 
70
  * Bug Fixed: Load review css only when review is enable for that post. #67
71
  * Menified review css in amp to put under amp css limitation.
72
 
 
 
 
 
 
73
  = 1.0.4 (16 November 2018) =
74
  * Major Feature: Post Specific Meta boxes to override the schemas on posts
75
  * Major Feature: Rich Snippets for Reviews and Ratings
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 4.9.8
6
+ Stable tag: 1.0.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
65
 
66
  == Changelog ==
67
 
68
+ = 1.0.5 (30 November 2018) =
69
+
70
+ * New Feature: Service schema type add to the schema type list
71
+ * New Feature: Comments Markup, The comments on post will also appear in schema markup
72
+ * New Feature: WP SEO Structured Data Schema migration tool
73
+ * New Feature: Compatibility with kk Star Ratings plugin, Now the ratings will be indexed in google search and results will be appearing in the form of a rich snippet
74
+ * Bug Fixed: Some of the missing fields added in NewsArticle schema type markup( articleSection, articleBody, wordCount & timeRequired ).
75
+
76
  = 1.0.4.1 (17 November 2018) =
77
 
78
  * Bug Fixed: Load review css only when review is enable for that post. #67
79
  * Menified review css in amp to put under amp css limitation.
80
 
81
+ = 1.0.5 (26 November 2018) =
82
+ * Major Feature: Post Specific Meta boxes to override the schemas on posts
83
+ * Major Feature: Rich Snippets for Reviews and Ratings
84
+ * Security and other bug fixed
85
+
86
  = 1.0.4 (16 November 2018) =
87
  * Major Feature: Post Specific Meta boxes to override the schemas on posts
88
  * Major Feature: Rich Snippets for Reviews and Ratings
structured-data-for-wp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Schema & Structured Data for WP
4
  Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5
- Version: 1.0.4.1
6
  Text Domain: schema-and-structured-data-for-wp
7
  Author: Mohammed Kaludi, Ahmed Kaludi
8
  Author URI: http://structured-data-for-wp.com/
@@ -12,7 +12,7 @@ License: GPL2
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
 
15
- define('SASWP_VERSION', '1.0.4.1');
16
  define('SASWP_DIR_NAME_FILE', __FILE__ );
17
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
18
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
@@ -39,7 +39,8 @@ if ( ! function_exists('saswp_non_amp') ){
39
  $non_amp = true;
40
  if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
41
  $non_amp = false;
42
- }
 
43
  return $non_amp;
44
  }
45
  }
@@ -125,4 +126,29 @@ function saswp_admin_notice(){
125
  </script>
126
  <?php
127
  }
128
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /*
3
  Plugin Name: Schema & Structured Data for WP
4
  Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5
+ Version: 1.0.5
6
  Text Domain: schema-and-structured-data-for-wp
7
  Author: Mohammed Kaludi, Ahmed Kaludi
8
  Author URI: http://structured-data-for-wp.com/
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
 
15
+ define('SASWP_VERSION', '1.0.5');
16
  define('SASWP_DIR_NAME_FILE', __FILE__ );
17
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
18
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
39
  $non_amp = true;
40
  if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
41
  $non_amp = false;
42
+
43
+ }
44
  return $non_amp;
45
  }
46
  }
126
  </script>
127
  <?php
128
  }
129
+ }
130
+
131
+ add_filter('plugin_row_meta' , 'saswp_add_plugin_meta_links', 10, 2);
132
+
133
+ function saswp_add_plugin_meta_links($meta_fields, $file) {
134
+ if ( plugin_basename(__FILE__) == $file ) {
135
+ $plugin_url = "https://wordpress.org/support/plugin/schema-and-structured-data-for-wp";
136
+ $meta_fields[] = "<a href='" . esc_url($plugin_url) . "' target='_blank'>" . esc_html__('Support Forum', 'ads-for-wp') . "</a>";
137
+ $meta_fields[] = "<a href='" . esc_url($plugin_url) . "/reviews#new-post' target='_blank' title='" . esc_html__('Rate', 'ads-for-wp') . "'>
138
+ <i class='saswp-wdi-rate-stars'>"
139
+ . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
140
+ . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
141
+ . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
142
+ . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
143
+ . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
144
+ . "</i></a>";
145
+ echo "<style>"
146
+ . ".saswp-wdi-rate-stars{display:inline-block;color:#ffb900;position:relative;top:3px;}"
147
+ . ".saswp-wdi-rate-stars svg{fill:#ffb900;}"
148
+ . ".saswp-wdi-rate-stars svg:hover{fill:#ffb900}"
149
+ . ".saswp-wdi-rate-stars svg:hover ~ svg{fill:none;}"
150
+ . "</style>";
151
+ }
152
+
153
+ return $meta_fields;
154
+ }
view/post_specific.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  class saswp_post_specific {
3
  private $screen = array(
4
- 'post',
 
5
  );
6
  private $meta_fields = array(
7
 
@@ -695,7 +696,7 @@ class saswp_post_specific {
695
  array(
696
  'label' => 'Description',
697
  'id' => 'local_business_description_'.$schema_id,
698
- 'type' => 'text',
699
  'default' => $post->post_excerpt
700
  ),
701
  array(
@@ -794,7 +795,7 @@ class saswp_post_specific {
794
  array(
795
  'label' => 'Description',
796
  'id' => 'saswp_blogposting_description_'.$schema_id,
797
- 'type' => 'text',
798
  'default' => $post->post_excerpt,
799
  ),
800
  array(
@@ -843,6 +844,14 @@ class saswp_post_specific {
843
  break;
844
 
845
  case 'NewsArticle':
 
 
 
 
 
 
 
 
846
  $meta_field = array(
847
  array(
848
  'label' => 'Main Entity Of Page',
@@ -877,9 +886,21 @@ class saswp_post_specific {
877
  array(
878
  'label' => 'Description',
879
  'id' => 'saswp_newsarticle_description_'.$schema_id,
880
- 'type' => 'text',
881
  'default' => $post->post_excerpt
882
- ),
 
 
 
 
 
 
 
 
 
 
 
 
883
  array(
884
  'label' => 'Name',
885
  'id' => 'saswp_newsarticle_name_'.$schema_id,
@@ -892,6 +913,18 @@ class saswp_post_specific {
892
  'type' => 'text',
893
  'default' => $image_details[0]
894
  ),
 
 
 
 
 
 
 
 
 
 
 
 
895
  array(
896
  'label' => 'Main Entity Id',
897
  'id' => 'saswp_newsarticle_main_entity_id_'.$schema_id,
@@ -942,7 +975,7 @@ class saswp_post_specific {
942
  array(
943
  'label' => 'Description',
944
  'id' => 'saswp_webpage_description_'.$schema_id,
945
- 'type' => 'text',
946
  'default' => $post->post_excerpt
947
  ),
948
  array(
@@ -966,7 +999,7 @@ class saswp_post_specific {
966
  array(
967
  'label' => 'Description',
968
  'id' => 'saswp_webpage_description_'.$schema_id,
969
- 'type' => 'text',
970
  'default' => $post->post_excerpt
971
  ),
972
  array(
@@ -1090,7 +1123,7 @@ class saswp_post_specific {
1090
  array(
1091
  'label' => 'Description',
1092
  'id' => 'saswp_recipe_description_'.$schema_id,
1093
- 'type' => 'text',
1094
  'default' => $post->post_excerpt
1095
  ),
1096
  array(
@@ -1143,12 +1176,84 @@ class saswp_post_specific {
1143
  array(
1144
  'label' => 'Description',
1145
  'id' => 'saswp_product_description_'.$schema_id,
1146
- 'type' => 'text',
1147
  'default' => $post->post_excerpt
1148
  ),
1149
  );
1150
  break;
1151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1152
  case 'VideoObject':
1153
  $meta_field = array(
1154
  array(
@@ -1178,7 +1283,7 @@ class saswp_post_specific {
1178
  array(
1179
  'label' => 'Description',
1180
  'id' => 'saswp_video_object_description_'.$schema_id,
1181
- 'type' => 'text',
1182
  'default' => $post->post_excerpt
1183
  ),
1184
  array(
1
  <?php
2
  class saswp_post_specific {
3
  private $screen = array(
4
+ 'post',
5
+ 'page'
6
  );
7
  private $meta_fields = array(
8
 
696
  array(
697
  'label' => 'Description',
698
  'id' => 'local_business_description_'.$schema_id,
699
+ 'type' => 'textarea',
700
  'default' => $post->post_excerpt
701
  ),
702
  array(
795
  array(
796
  'label' => 'Description',
797
  'id' => 'saswp_blogposting_description_'.$schema_id,
798
+ 'type' => 'textarea',
799
  'default' => $post->post_excerpt,
800
  ),
801
  array(
844
  break;
845
 
846
  case 'NewsArticle':
847
+
848
+ $category_detail=get_the_category(get_the_ID());//$post->ID
849
+ $article_section = '';
850
+ foreach($category_detail as $cd){
851
+ $article_section = $cd->cat_name;
852
+ }
853
+ $word_count = saswp_reading_time_and_word_count();
854
+
855
  $meta_field = array(
856
  array(
857
  'label' => 'Main Entity Of Page',
886
  array(
887
  'label' => 'Description',
888
  'id' => 'saswp_newsarticle_description_'.$schema_id,
889
+ 'type' => 'textarea',
890
  'default' => $post->post_excerpt
891
+ ),
892
+ array(
893
+ 'label' => 'Article Section',
894
+ 'id' => 'saswp_newsarticle_section_'.$schema_id,
895
+ 'type' => 'text',
896
+ 'default' => $article_section
897
+ ),
898
+ array(
899
+ 'label' => 'Article Body',
900
+ 'id' => 'saswp_newsarticle_body_'.$schema_id,
901
+ 'type' => 'textarea',
902
+ 'default' => get_the_content()
903
+ ),
904
  array(
905
  'label' => 'Name',
906
  'id' => 'saswp_newsarticle_name_'.$schema_id,
913
  'type' => 'text',
914
  'default' => $image_details[0]
915
  ),
916
+ array(
917
+ 'label' => 'Word Count',
918
+ 'id' => 'saswp_newsarticle_word_count_'.$schema_id,
919
+ 'type' => 'text',
920
+ 'default' => $word_count['word_count']
921
+ ),
922
+ array(
923
+ 'label' => 'Time Required',
924
+ 'id' => 'saswp_newsarticle_timerequired_'.$schema_id,
925
+ 'type' => 'text',
926
+ 'default' => $word_count['timerequired']
927
+ ),
928
  array(
929
  'label' => 'Main Entity Id',
930
  'id' => 'saswp_newsarticle_main_entity_id_'.$schema_id,
975
  array(
976
  'label' => 'Description',
977
  'id' => 'saswp_webpage_description_'.$schema_id,
978
+ 'type' => 'textarea',
979
  'default' => $post->post_excerpt
980
  ),
981
  array(
999
  array(
1000
  'label' => 'Description',
1001
  'id' => 'saswp_webpage_description_'.$schema_id,
1002
+ 'type' => 'textarea',
1003
  'default' => $post->post_excerpt
1004
  ),
1005
  array(
1123
  array(
1124
  'label' => 'Description',
1125
  'id' => 'saswp_recipe_description_'.$schema_id,
1126
+ 'type' => 'textarea',
1127
  'default' => $post->post_excerpt
1128
  ),
1129
  array(
1176
  array(
1177
  'label' => 'Description',
1178
  'id' => 'saswp_product_description_'.$schema_id,
1179
+ 'type' => 'textarea',
1180
  'default' => $post->post_excerpt
1181
  ),
1182
  );
1183
  break;
1184
 
1185
+ case 'Service':
1186
+ $service_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_service_schema_details', true) );
1187
+ $meta_field = array(
1188
+ array(
1189
+ 'label' => 'Name',
1190
+ 'id' => 'saswp_service_schema_name_'.$schema_id,
1191
+ 'type' => 'text',
1192
+ 'default' => $service_schema_details['saswp_service_schema_name']
1193
+ ),
1194
+ array(
1195
+ 'label' => 'Service Type',
1196
+ 'id' => 'saswp_service_schema_type_'.$schema_id,
1197
+ 'type' => 'text',
1198
+ 'default' => $service_schema_details['saswp_service_schema_type']
1199
+ ),
1200
+ array(
1201
+ 'label' => 'Provider Name',
1202
+ 'id' => 'saswp_service_schema_provider_name_'.$schema_id,
1203
+ 'type' => 'text',
1204
+ 'default' => $service_schema_details['saswp_service_schema_provider_name']
1205
+ ),
1206
+ array(
1207
+ 'label' => 'Image',
1208
+ 'id' => 'saswp_service_schema_image_'.$schema_id,
1209
+ 'type' => 'media',
1210
+ 'default' => $service_schema_details['saswp_service_schema_image']['url']
1211
+ ),
1212
+ array(
1213
+ 'label' => 'Locality',
1214
+ 'id' => 'saswp_service_schema_locality_'.$schema_id,
1215
+ 'type' => 'text',
1216
+ 'default' => $service_schema_details['saswp_service_schema_locality']
1217
+ ),
1218
+ array(
1219
+ 'label' => 'Postal Code',
1220
+ 'id' => 'saswp_service_schema_postal_code_'.$schema_id,
1221
+ 'type' => 'text',
1222
+ 'default' => $service_schema_details['saswp_service_schema_postal_code']
1223
+ ),
1224
+ array(
1225
+ 'label' => 'Telephone',
1226
+ 'id' => 'saswp_service_schema_telephone_'.$schema_id,
1227
+ 'type' => 'text',
1228
+ 'default' => $service_schema_details['saswp_service_schema_telephone']
1229
+ ),
1230
+ array(
1231
+ 'label' => 'Price Range',
1232
+ 'id' => 'saswp_service_schema_price_range_'.$schema_id,
1233
+ 'type' => 'text',
1234
+ 'default' => $service_schema_details['saswp_service_schema_price_range']
1235
+ ),
1236
+ array(
1237
+ 'label' => 'Description',
1238
+ 'id' => 'saswp_service_schema_description_'.$schema_id,
1239
+ 'type' => 'textarea',
1240
+ 'default' => $service_schema_details['saswp_service_schema_description']
1241
+ ),
1242
+ array(
1243
+ 'label' => 'Area Served',
1244
+ 'id' => 'saswp_service_schema_area_served_'.$schema_id,
1245
+ 'type' => 'textarea',
1246
+ 'default' => $service_schema_details['saswp_service_schema_area_served']
1247
+ ),
1248
+ array(
1249
+ 'label' => 'Service Offer',
1250
+ 'id' => 'saswp_service_schema_service_offer_'.$schema_id,
1251
+ 'type' => 'textarea',
1252
+ 'default' => $service_schema_details['saswp_service_schema_service_offer']
1253
+ ),
1254
+ );
1255
+ break;
1256
+
1257
  case 'VideoObject':
1258
  $meta_field = array(
1259
  array(
1283
  array(
1284
  'label' => 'Description',
1285
  'id' => 'saswp_video_object_description_'.$schema_id,
1286
+ 'type' => 'textarea',
1287
  'default' => $post->post_excerpt
1288
  ),
1289
  array(
view/schema_type.php CHANGED
@@ -26,24 +26,29 @@
26
  function saswp_schema_type_meta_box_callback( $post) {
27
  wp_nonce_field( 'saswp_schema_type_nonce', 'saswp_schema_type_nonce' );
28
  $style_business_type ='';
29
- $style_business_name ='';
 
30
  $business_name ='';
31
  $schema_type ='';
32
  $business_type ='';
33
  $business_details ='';
34
  if($post){
35
- $schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
36
  $business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
37
  $business_name = esc_sql ( get_post_meta($post->ID, 'saswp_business_name', true) );
38
  $business_details = esc_sql ( get_post_meta($post->ID, 'saswp_local_business_details', true) );
 
39
 
40
  $custom_logo_id = get_theme_mod( 'custom_logo' );
41
  $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
42
-
43
  if($schema_type != 'local_business'){
44
  $style_business_type = 'style="display:none"';
45
  $style_business_name = 'style="display:none"';
46
  }
 
 
 
47
  }
48
 
49
  $all_dayofweek_array = array(
@@ -52,7 +57,7 @@
52
  'wednesday' => 'Wednesday',
53
  'thursday' => 'Thursday',
54
  'friday' => 'Friday',
55
- 'staturday' => 'Staturday',
56
  'sunday' => 'Sunday',
57
  );
58
 
@@ -64,6 +69,7 @@
64
  'Article' => 'Article',
65
  'Recipe' => 'Recipe',
66
  'Product' => 'Product',
 
67
  'VideoObject' => 'VideoObject',
68
  'local_business' => 'Local Business'
69
  );
@@ -494,14 +500,17 @@
494
  <select multiple id="saswp_dayofweek" name="saswp_dayofweek[]">
495
  <?php
496
 
497
- $selected_days = $business_details['saswp_dayofweek'];
498
-
499
  foreach ($all_dayofweek_array as $key => $value) {
500
  $sel = '';
501
- if(array_search($key, $selected_days)){
 
502
  $sel = 'selected';
503
- }
504
- echo "<option value='".esc_attr($key)."' ".esc_attr($sel).">".esc_html__($value, 'schema-and-structured-data-for-wp' )."</option>";
 
 
 
505
  }
506
  ?>
507
  </select>
@@ -519,6 +528,59 @@
519
  <td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
520
  <td><input value="<?php if(isset($business_details['local_price_range'])){echo esc_attr($business_details['local_price_range']); } ?>" type="text" name="local_price_range" placeholder="<?php echo esc_html__('$10-$50 or $$$ ', 'schema-and-structured-data-for-wp' ); ?>" ></td>
521
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  </table>
523
 
524
  </div>
@@ -590,6 +652,53 @@
590
  }
591
 
592
  update_post_meta( $post_id, 'saswp_local_business_details', $local_business_details );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
 
594
  }
595
 
26
  function saswp_schema_type_meta_box_callback( $post) {
27
  wp_nonce_field( 'saswp_schema_type_nonce', 'saswp_schema_type_nonce' );
28
  $style_business_type ='';
29
+ $style_business_name ='';
30
+ $style_service_name ='';
31
  $business_name ='';
32
  $schema_type ='';
33
  $business_type ='';
34
  $business_details ='';
35
  if($post){
36
+ $schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
37
  $business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
38
  $business_name = esc_sql ( get_post_meta($post->ID, 'saswp_business_name', true) );
39
  $business_details = esc_sql ( get_post_meta($post->ID, 'saswp_local_business_details', true) );
40
+ $service_details = esc_sql ( get_post_meta($post->ID, 'saswp_service_schema_details', true) );
41
 
42
  $custom_logo_id = get_theme_mod( 'custom_logo' );
43
  $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
44
+
45
  if($schema_type != 'local_business'){
46
  $style_business_type = 'style="display:none"';
47
  $style_business_name = 'style="display:none"';
48
  }
49
+ if($schema_type != 'Service'){
50
+ // $style_service_name = 'style="display:none"';
51
+ }
52
  }
53
 
54
  $all_dayofweek_array = array(
57
  'wednesday' => 'Wednesday',
58
  'thursday' => 'Thursday',
59
  'friday' => 'Friday',
60
+ 'saturday' => 'Saturday',
61
  'sunday' => 'Sunday',
62
  );
63
 
69
  'Article' => 'Article',
70
  'Recipe' => 'Recipe',
71
  'Product' => 'Product',
72
+ 'Service' => 'Service',
73
  'VideoObject' => 'VideoObject',
74
  'local_business' => 'Local Business'
75
  );
500
  <select multiple id="saswp_dayofweek" name="saswp_dayofweek[]">
501
  <?php
502
 
503
+ $selected_days = $business_details['saswp_dayofweek'];
 
504
  foreach ($all_dayofweek_array as $key => $value) {
505
  $sel = '';
506
+ if(isset($selected_days)){
507
+ if(in_array($key, $selected_days)){
508
  $sel = 'selected';
509
+ }
510
+ echo "<option value='".esc_attr($key)."' ".esc_attr($sel).">".esc_html__($value, 'schema-and-structured-data-for-wp' )."</option>";
511
+ }else{
512
+ echo "<option value='".esc_attr($key)."'>".esc_html__($value, 'schema-and-structured-data-for-wp' )."</option>";
513
+ }
514
  }
515
  ?>
516
  </select>
528
  <td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
529
  <td><input value="<?php if(isset($business_details['local_price_range'])){echo esc_attr($business_details['local_price_range']); } ?>" type="text" name="local_price_range" placeholder="<?php echo esc_html__('$10-$50 or $$$ ', 'schema-and-structured-data-for-wp' ); ?>" ></td>
530
  </tr>
531
+ <!-- Service Schema type starts here -->
532
+
533
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
534
+ <td><?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?></td>
535
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_name'])){echo esc_attr($service_details['saswp_service_schema_name']); } ?>" type="text" name="saswp_service_schema_name" placeholder="<?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?>" ></td>
536
+ </tr>
537
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
538
+ <td><?php echo esc_html__('Service Type', 'schema-and-structured-data-for-wp' ); ?></td>
539
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_type'])){echo esc_attr($service_details['saswp_service_schema_type']); } ?>" type="text" name="saswp_service_schema_type" placeholder="<?php echo esc_html__('Service Type', 'schema-and-structured-data-for-wp' ); ?>" ></td>
540
+ </tr>
541
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
542
+ <td><?php echo esc_html__('Provider Name', 'schema-and-structured-data-for-wp' ); ?></td>
543
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_provider_name'])){echo esc_attr($service_details['saswp_service_schema_provider_name']); } ?>" type="text" name="saswp_service_schema_provider_name" placeholder="<?php echo esc_html__('Provider Name', 'schema-and-structured-data-for-wp' ); ?>" ></td>
544
+ </tr>
545
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
546
+ <td><?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?></td>
547
+ <td style="display: flex; width: 97%">
548
+ <input value="<?php if(isset($service_details['saswp_service_schema_image'])) { echo esc_url($service_details['saswp_service_schema_image']['url']);} else { echo esc_url($logo[0]); } ?>" id="saswp_service_schema_image" type="text" name="saswp_service_schema_image[url]" placeholder="<?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?>" readonly="readonly" style="background: #FFF;">
549
+ <input value="<?php if(isset($service_details['saswp_service_schema_image'])) { echo esc_attr($service_details['saswp_service_schema_image']['id']);} else { echo esc_attr($custom_logo_id); }?>" data-id="saswp_service_schema_image_id" type="hidden" name="saswp_service_schema_image[id]">
550
+ <input value="<?php if(isset($service_details['saswp_service_schema_image'])) { echo esc_attr($service_details['saswp_service_schema_image']['width']);} else { echo esc_attr($logo[1]); } ?>" data-id="saswp_service_schema_image_width" type="hidden" name="saswp_service_schema_image[width]">
551
+ <input value="<?php if(isset($service_details['saswp_service_schema_image'])) { echo esc_attr($service_details['saswp_service_schema_image']['height']);} else { echo esc_attr($logo[2]); } ?>" data-id="saswp_service_schema_image_height" type="hidden" name="saswp_service_schema_image[height]">
552
+ <input data-id="media" class="button" id="saswp_service_schema_image_button" type="button" value="Upload"></td>
553
+ </tr>
554
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
555
+ <td><?php echo esc_html__('Locality', 'schema-and-structured-data-for-wp' ); ?></td>
556
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_locality'])){echo esc_attr($service_details['saswp_service_schema_locality']); } ?>" type="text" name="saswp_service_schema_locality" placeholder="<?php echo esc_html__('Locality', 'schema-and-structured-data-for-wp' ); ?>" ></td>
557
+ </tr>
558
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
559
+ <td><?php echo esc_html__('PostalCode', 'schema-and-structured-data-for-wp' ); ?></td>
560
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_postal_code'])){echo esc_attr($service_details['saswp_service_schema_postal_code']); } ?>" type="text" name="saswp_service_schema_postal_code" placeholder="<?php echo esc_html__('Postal Code', 'schema-and-structured-data-for-wp' ); ?>" ></td>
561
+ </tr>
562
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
563
+ <td><?php echo esc_html__('Telephone', 'schema-and-structured-data-for-wp' ); ?></td>
564
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_telephone'])){echo esc_attr($service_details['saswp_service_schema_telephone']); } ?>" type="text" name="saswp_service_schema_telephone" placeholder="<?php echo esc_html__('Telephone', 'schema-and-structured-data-for-wp' ); ?>" ></td>
565
+ </tr>
566
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
567
+ <td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
568
+ <td><input value="<?php if(isset($service_details['saswp_service_schema_price_range'])){echo esc_attr($service_details['saswp_service_schema_price_range']); } ?>" type="text" name="saswp_service_schema_price_range" placeholder="<?php echo esc_html__('$10-$50 or $$$ ', 'schema-and-structured-data-for-wp' ); ?>" ></td>
569
+ </tr>
570
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
571
+ <td><?php echo esc_html__('Description', 'schema-and-structured-data-for-wp' ); ?></td>
572
+ <td><textarea placeholder="Description" rows="3" cols="70" name="saswp_service_schema_description"><?php if(isset($service_details['saswp_service_schema_description'])){echo esc_attr($service_details['saswp_service_schema_description']); } ?></textarea></td>
573
+ </tr>
574
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
575
+ <td><?php echo esc_html__('Area Served (City)', 'schema-and-structured-data-for-wp' ); ?></td>
576
+ <td><textarea placeholder="New York, Los Angeles" rows="3" cols="70" name="saswp_service_schema_area_served"><?php if(isset($service_details['saswp_service_schema_area_served'])){echo esc_attr($service_details['saswp_service_schema_area_served']); } ?></textarea><p>Note: Enter all the City name in comma separated</p></td>
577
+ </tr>
578
+ <tr class="saswp-service-text-field-tr" <?php echo $style_service_name; ?>>
579
+ <td><?php echo esc_html__('Service Offer', 'schema-and-structured-data-for-wp' ); ?></td>
580
+ <td><textarea placeholder="Apartment light cleaning, Carpet cleaning" rows="3" cols="70" name="saswp_service_schema_service_offer"><?php if(isset($service_details['saswp_service_schema_service_offer'])){echo esc_attr($service_details['saswp_service_schema_service_offer']); } ?></textarea><p>Note: Enter all the service offer in comma separated</p></td>
581
+ </tr>
582
+
583
+ <!-- Service Schema type ends here -->
584
  </table>
585
 
586
  </div>
652
  }
653
 
654
  update_post_meta( $post_id, 'saswp_local_business_details', $local_business_details );
655
+
656
+ //Service schema details starts here
657
+ $service_schema_details = array();
658
+ $schema_type = $_POST['schema_type'];
659
+
660
+ if($schema_type =='Service'){
661
+ if ( isset( $_POST['saswp_service_schema_name'] ) ){
662
+ $service_schema_details['saswp_service_schema_name'] = $_POST['saswp_service_schema_name'];
663
+ }
664
+ if ( isset( $_POST['saswp_service_schema_type'] ) ){
665
+ $service_schema_details['saswp_service_schema_type'] = $_POST['saswp_service_schema_type'];
666
+ }
667
+ if ( isset( $_POST['saswp_service_schema_provider_name'] ) ){
668
+ $service_schema_details['saswp_service_schema_provider_name'] = $_POST['saswp_service_schema_provider_name'];
669
+ }
670
+ if ( isset( $_POST['saswp_service_schema_image'] ) ){
671
+ $service_schema_details['saswp_service_schema_image']['id'] = $_POST['saswp_service_schema_image']['id'];
672
+ $service_schema_details['saswp_service_schema_image']['url'] = $_POST['saswp_service_schema_image']['url'];
673
+ $service_schema_details['saswp_service_schema_image']['width'] = $_POST['saswp_service_schema_image']['width'];
674
+ $service_schema_details['saswp_service_schema_image']['height'] = $_POST['saswp_service_schema_image']['height'];
675
+ }
676
+ if ( isset( $_POST['saswp_service_schema_locality'] ) ){
677
+ $service_schema_details['saswp_service_schema_locality'] = $_POST['saswp_service_schema_locality'];
678
+ }
679
+ if ( isset( $_POST['saswp_service_schema_postal_code'] ) ){
680
+ $service_schema_details['saswp_service_schema_postal_code'] = $_POST['saswp_service_schema_postal_code'];
681
+ }
682
+ if ( isset( $_POST['saswp_service_schema_telephone'] ) ){
683
+ $service_schema_details['saswp_service_schema_telephone'] = $_POST['saswp_service_schema_telephone'];
684
+ }
685
+ if ( isset( $_POST['saswp_service_schema_price_range'] ) ){
686
+ $service_schema_details['saswp_service_schema_price_range'] = $_POST['saswp_service_schema_price_range'];
687
+ }
688
+ if ( isset( $_POST['saswp_service_schema_description'] ) ){
689
+ $service_schema_details['saswp_service_schema_description'] = $_POST['saswp_service_schema_description'];
690
+ }
691
+ if ( isset( $_POST['saswp_service_schema_area_served'] ) ){
692
+ $service_schema_details['saswp_service_schema_area_served'] = $_POST['saswp_service_schema_area_served'];
693
+ }
694
+ if ( isset( $_POST['saswp_service_schema_service_offer'] ) ){
695
+ $service_schema_details['saswp_service_schema_service_offer'] = $_POST['saswp_service_schema_service_offer'];
696
+ }
697
+ update_post_meta( $post_id, 'saswp_service_schema_details', $service_schema_details );
698
+ }
699
+
700
+ //Service schema details ends here
701
+
702
 
703
  }
704