Schema & Structured Data for WP & AMP - Version 1.7

Version Description

(24 April 2019) =

  • Added: Option to enable and disable website schema markup #225
  • Added: Option to enable and disable Sitelinks Search Box in website schema markup #196
  • Bug Fixed: Event Time and date is not changing as per the option #227
  • Bug Fixed: Two images url are null from three different image sizes in amp article schema #222
  • Bug Fixed: number_format() Debug error #213
  • Bug Fixed: Undefined offset errors #214, #232, #229
Download this release

Release Info

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

Code changes from version 1.6 to 1.7

admin_section/common-function.php CHANGED
@@ -1266,11 +1266,11 @@ function saswp_defaultSettings(){
1266
  'sd_alt_name' => $sd_name,
1267
  'sd_url' => $current_url,
1268
  'sd_logo' => array(
1269
- 'url' => $logo[0],
1270
  'id' => $custom_logo_id,
1271
- 'height' => $logo[2],
1272
- 'width' => $logo[1],
1273
- 'thumbnail' => $logo[0]
1274
  ),
1275
  'sd-person-name' => $username,
1276
  'sd-person-job-title'=> '',
@@ -1300,11 +1300,11 @@ function saswp_defaultSettings(){
1300
 
1301
  'sd-data-logo-ampforwp' => array(
1302
 
1303
- 'url' => $logo[0],
1304
  'id' => $custom_logo_id,
1305
- 'height' => $logo[2],
1306
- 'width' => $logo[1],
1307
- 'thumbnail' => $logo[0]
1308
 
1309
  ),
1310
 
@@ -1315,14 +1315,14 @@ function saswp_defaultSettings(){
1315
  'saswp-logo-height' => '60',
1316
 
1317
  'sd_default_image' => array(
1318
- 'url' => $logo[0],
1319
  'id' => $custom_logo_id,
1320
- 'height' => $logo[2],
1321
- 'width' => $logo[1],
1322
- 'thumbnail' => $logo[0]
1323
  ),
1324
- 'sd_default_image_width' => $logo[1],
1325
- 'sd_default_image_height' => $logo[2],
1326
  'sd_initial_wizard_status' => 1,
1327
 
1328
  );
1266
  'sd_alt_name' => $sd_name,
1267
  'sd_url' => $current_url,
1268
  'sd_logo' => array(
1269
+ 'url' => array_key_exists(0, $logo)? $logo[0]:'',
1270
  'id' => $custom_logo_id,
1271
+ 'height' => array_key_exists(2, $logo)? $logo[2]:'',
1272
+ 'width' => array_key_exists(1, $logo)? $logo[1]:'',
1273
+ 'thumbnail' => array_key_exists(0, $logo)? $logo[0]:''
1274
  ),
1275
  'sd-person-name' => $username,
1276
  'sd-person-job-title'=> '',
1300
 
1301
  'sd-data-logo-ampforwp' => array(
1302
 
1303
+ 'url' => array_key_exists(0, $logo)? $logo[0]:'',
1304
  'id' => $custom_logo_id,
1305
+ 'height' => array_key_exists(2, $logo)? $logo[2]:'',
1306
+ 'width' => array_key_exists(1, $logo)? $logo[1]:'',
1307
+ 'thumbnail' => array_key_exists(0, $logo)? $logo[0]:''
1308
 
1309
  ),
1310
 
1315
  'saswp-logo-height' => '60',
1316
 
1317
  'sd_default_image' => array(
1318
+ 'url' => array_key_exists(0, $logo)? $logo[0]:'',
1319
  'id' => $custom_logo_id,
1320
+ 'height' => array_key_exists(2, $logo)? $logo[2]:'',
1321
+ 'width' => array_key_exists(1, $logo)? $logo[1]:'',
1322
+ 'thumbnail' => array_key_exists(0, $logo)? $logo[0]:''
1323
  ),
1324
+ 'sd_default_image_width' => array_key_exists(1, $logo)? $logo[1]:'',
1325
+ 'sd_default_image_height' => array_key_exists(2, $logo)? $logo[2]:'',
1326
  'sd_initial_wizard_status' => 1,
1327
 
1328
  );
admin_section/fields-generator.php CHANGED
@@ -200,7 +200,7 @@ class saswp_fields_generator {
200
  if($note =='' || $proversion == 1){
201
  $output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p data-id="'.esc_attr($proversion).'">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
202
  }else{
203
- $output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p class="saswp_hide">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
204
  }
205
 
206
  }
200
  if($note =='' || $proversion == 1){
201
  $output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p data-id="'.esc_attr($proversion).'">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
202
  }else{
203
+ $output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p class="">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
204
  }
205
 
206
  }
admin_section/js/main-script.js CHANGED
@@ -280,6 +280,25 @@ jQuery(document).ready(function($){
280
  $(".saswp_archive_schema_type_class").parent().parent().hide();
281
  }
282
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  case 'saswp_breadcrumb_schema_checkbox':
284
 
285
  if ($(this).is(':checked')) {
280
  $(".saswp_archive_schema_type_class").parent().parent().hide();
281
  }
282
  break;
283
+
284
+ case 'saswp_website_schema_checkbox':
285
+
286
+ if ($(this).is(':checked')) {
287
+ $("#saswp_website_schema").val(1);
288
+ }else{
289
+ $("#saswp_website_schema").val(0);
290
+ }
291
+ break;
292
+
293
+ case 'saswp_search_box_schema_checkbox':
294
+
295
+ if ($(this).is(':checked')) {
296
+ $("#saswp_search_box_schema").val(1);
297
+ }else{
298
+ $("#saswp_search_box_schema").val(0);
299
+ }
300
+ break;
301
+
302
  case 'saswp_breadcrumb_schema_checkbox':
303
 
304
  if ($(this).is(':checked')) {
admin_section/settings.php CHANGED
@@ -378,6 +378,29 @@ function saswp_general_page_callback(){
378
  $settings = saswp_defaultSettings();
379
 
380
  $meta_fields_default = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  array(
382
  'label' => 'Archive',
383
  'id' => 'saswp_archive_schema_checkbox',
378
  $settings = saswp_defaultSettings();
379
 
380
  $meta_fields_default = array(
381
+ array(
382
+ 'label' => 'Website',
383
+ 'id' => 'saswp_website_schema_checkbox',
384
+ 'name' => 'saswp_website_schema_checkbox',
385
+ 'type' => 'checkbox',
386
+ 'class' => 'checkbox saswp-checkbox',
387
+ 'hidden' => array(
388
+ 'id' => 'saswp_website_schema',
389
+ 'name' => 'sd_data[saswp_website_schema]',
390
+ )
391
+ ),
392
+ array(
393
+ 'label' => 'Sitelinks Search Box',
394
+ 'id' => 'saswp_search_box_schema_checkbox',
395
+ 'name' => 'saswp_search_box_schema_checkbox',
396
+ 'type' => 'checkbox',
397
+ 'class' => 'checkbox saswp-checkbox',
398
+ 'note' => 'To use this feature, Firstly enable website schema',
399
+ 'hidden' => array(
400
+ 'id' => 'saswp_search_box_schema',
401
+ 'name' => 'sd_data[saswp_search_box_schema]',
402
+ )
403
+ ),
404
  array(
405
  'label' => 'Archive',
406
  'id' => 'saswp_archive_schema_checkbox',
output/output.php CHANGED
@@ -455,8 +455,8 @@ function saswp_schema_output() {
455
  '@type' => $schema_type ,
456
  'name' => saswp_remove_warnings($schema_data, 'saswp_event_schema_name', 'saswp_string'),
457
  'description' => saswp_remove_warnings($schema_data, 'saswp_event_schema_description', 'saswp_string'),
458
- 'startDate' => isset($schema_data['saswp_event_schema_start_date']) && $schema_data['saswp_event_schema_start_date'] !='' ? date('Y-m-d\TH:i:s\Z',$schema_data['saswp_event_schema_start_date']):'',
459
- 'endDate' => isset($schema_data['saswp_event_schema_end_date']) && $schema_data['saswp_event_schema_end_date'] !='' ? date('Y-m-d\TH:i:s\Z',$schema_data['saswp_event_schema_end_date']):'',
460
  'image' => array(
461
  '@type' =>'ImageObject',
462
  'url' => isset($schema_data['saswp_event_schema_image']) ? esc_url($schema_data['saswp_event_schema_image']['url']):'' ,
@@ -480,7 +480,7 @@ function saswp_schema_output() {
480
  'price' => saswp_remove_warnings($schema_data, 'saswp_event_schema_price', 'saswp_string'),
481
  'priceCurrency' => saswp_remove_warnings($schema_data, 'saswp_event_schema_price_currency', 'saswp_string'),
482
  'availability' => saswp_remove_warnings($schema_data, 'saswp_event_schema_availability', 'saswp_string'),
483
- 'validFrom' => isset($schema_data['saswp_event_schema_validfrom']) && $schema_data['saswp_event_schema_validfrom'] !='' ? date('Y-m-d\TH:i:s\Z',$schema_data['saswp_event_schema_validfrom']):'',
484
  ),
485
  'performer' => array(
486
  '@type' => 'PerformingGroup',
@@ -2707,26 +2707,34 @@ function saswp_schema_breadcrumb_output(){
2707
  */
2708
  function saswp_kb_website_output(){
2709
 
 
 
2710
  $input = array();
2711
 
2712
- $site_url = get_site_url();
 
 
2713
  $site_name = get_bloginfo();
2714
 
2715
  if($site_url && $site_name){
2716
 
2717
  $input = array(
2718
- '@context' => 'http://schema.org',
2719
- '@type' => 'WebSite',
2720
- 'id' => '#website',
2721
- 'url' => $site_url,
2722
- 'name' => $site_name,
2723
- 'potentialAction' => array(
2724
- '@type' => 'SearchAction',
2725
- 'target' => esc_url($site_url).'/?s={search_term_string}',
2726
- 'query-input' => 'required name=search_term_string',
2727
- )
2728
- );
2729
- }
 
 
 
 
2730
 
2731
  return apply_filters('saswp_modify_website_output', $input);
2732
  }
455
  '@type' => $schema_type ,
456
  'name' => saswp_remove_warnings($schema_data, 'saswp_event_schema_name', 'saswp_string'),
457
  'description' => saswp_remove_warnings($schema_data, 'saswp_event_schema_description', 'saswp_string'),
458
+ 'startDate' => isset($schema_data['saswp_event_schema_start_date']) && $schema_data['saswp_event_schema_start_date'] !='' ? date('Y-m-d\TH:i:s\Z',strtotime($schema_data['saswp_event_schema_start_date'])):'',
459
+ 'endDate' => isset($schema_data['saswp_event_schema_end_date']) && $schema_data['saswp_event_schema_end_date'] !='' ? date('Y-m-d\TH:i:s\Z',strtotime($schema_data['saswp_event_schema_end_date'])):'',
460
  'image' => array(
461
  '@type' =>'ImageObject',
462
  'url' => isset($schema_data['saswp_event_schema_image']) ? esc_url($schema_data['saswp_event_schema_image']['url']):'' ,
480
  'price' => saswp_remove_warnings($schema_data, 'saswp_event_schema_price', 'saswp_string'),
481
  'priceCurrency' => saswp_remove_warnings($schema_data, 'saswp_event_schema_price_currency', 'saswp_string'),
482
  'availability' => saswp_remove_warnings($schema_data, 'saswp_event_schema_availability', 'saswp_string'),
483
+ 'validFrom' => isset($schema_data['saswp_event_schema_validfrom']) && $schema_data['saswp_event_schema_validfrom'] !='' ? date('Y-m-d\TH:i:s\Z',strtotime($schema_data['saswp_event_schema_validfrom'])):'',
484
  ),
485
  'performer' => array(
486
  '@type' => 'PerformingGroup',
2707
  */
2708
  function saswp_kb_website_output(){
2709
 
2710
+ global $sd_data;
2711
+
2712
  $input = array();
2713
 
2714
+ if(isset($sd_data['saswp_website_schema']) && $sd_data['saswp_website_schema'] == 1 || !isset($sd_data['saswp_website_schema'])){
2715
+
2716
+ $site_url = get_site_url();
2717
  $site_name = get_bloginfo();
2718
 
2719
  if($site_url && $site_name){
2720
 
2721
  $input = array(
2722
+ '@context' => 'http://schema.org',
2723
+ '@type' => 'WebSite',
2724
+ 'id' => '#website',
2725
+ 'url' => $site_url,
2726
+ 'name' => $site_name,
2727
+ );
2728
+
2729
+ if(isset($sd_data['saswp_search_box_schema']) && $sd_data['saswp_search_box_schema'] == 1 || !isset($sd_data['saswp_search_box_schema'])){
2730
+
2731
+ $input['potentialAction']['@type'] = 'SearchAction';
2732
+ $input['potentialAction']['target'] = esc_url($site_url).'/?s={search_term_string}';
2733
+ $input['potentialAction']['query-input'] = 'required name=search_term_string';
2734
+
2735
+ }
2736
+ }
2737
+ }
2738
 
2739
  return apply_filters('saswp_modify_website_output', $input);
2740
  }
output/review-output.php CHANGED
@@ -126,14 +126,16 @@ Class saswp_review_output{
126
  </td>
127
  <td>
128
  <div class="saswp-rvw-ov">
129
- <div class="saswp-rvw-fs">'.isset($saswp_over_all_rating)? esc_attr(number_format($saswp_over_all_rating, 2, '.', '')):''.'</div>';
130
 
131
  if($saswp_over_all_rating !=''){
132
 
133
  $boxdata.='<div class="tvw-fnl-str saswp-rvw-str">';
134
  $explod = explode('.', $saswp_over_all_rating);
135
 
136
- for($x=0;$x<5;$x++) {
 
 
137
 
138
  if(isset($explod[1])){
139
 
@@ -155,7 +157,10 @@ Class saswp_review_output{
155
  $boxdata.='<span class="df-clr"></span>';
156
  }
157
  }
158
- }
 
 
 
159
  $boxdata.='</div><span class="ovs">'.esc_html__('OVERALL SCORE', 'schema-and-structured-data-for-wp').'</span>';
160
  }
161
  $boxdata.=' </div>
126
  </td>
127
  <td>
128
  <div class="saswp-rvw-ov">
129
+ <div class="saswp-rvw-fs">'.isset($saswp_over_all_rating)? esc_attr(number_format((float)$saswp_over_all_rating, 2, '.', '')):''.'</div>';
130
 
131
  if($saswp_over_all_rating !=''){
132
 
133
  $boxdata.='<div class="tvw-fnl-str saswp-rvw-str">';
134
  $explod = explode('.', $saswp_over_all_rating);
135
 
136
+ if(!empty($explod)){
137
+
138
+ for($x=0;$x<5;$x++) {
139
 
140
  if(isset($explod[1])){
141
 
157
  $boxdata.='<span class="df-clr"></span>';
158
  }
159
  }
160
+ }
161
+
162
+ }
163
+
164
  $boxdata.='</div><span class="ovs">'.esc_html__('OVERALL SCORE', 'schema-and-structured-data-for-wp').'</span>';
165
  }
166
  $boxdata.=' </div>
output/service.php CHANGED
@@ -1635,7 +1635,7 @@ Class saswp_output_service{
1635
 
1636
  $resize_image = ampforwp_aq_resize( $image_details[0], $width[$i], $height[$i], true, false, true );
1637
 
1638
- if(!empty($resize_image)){
1639
 
1640
  $input2['image'][$i]['@type'] = 'ImageObject';
1641
  $input2['image'][$i]['url'] = esc_url($resize_image[0]);
@@ -1646,7 +1646,13 @@ Class saswp_output_service{
1646
 
1647
 
1648
  }
1649
-
 
 
 
 
 
 
1650
  }else{
1651
 
1652
  $input2['image']['@type'] = 'ImageObject';
1635
 
1636
  $resize_image = ampforwp_aq_resize( $image_details[0], $width[$i], $height[$i], true, false, true );
1637
 
1638
+ if(isset($resize_image[0]) && isset($resize_image[1]) && isset($resize_image[2]) ){
1639
 
1640
  $input2['image'][$i]['@type'] = 'ImageObject';
1641
  $input2['image'][$i]['url'] = esc_url($resize_image[0]);
1646
 
1647
 
1648
  }
1649
+
1650
+ if(!empty($input2)){
1651
+ foreach($input2 as $arr){
1652
+ $input2['image'] = array_values($arr);
1653
+ }
1654
+ }
1655
+
1656
  }else{
1657
 
1658
  $input2['image']['@type'] = 'ImageObject';
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: magazine3
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 5.1
6
- Stable tag: 1.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -66,6 +66,16 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
66
  == Changelog ==
67
 
68
 
 
 
 
 
 
 
 
 
 
 
69
  = 1.6 (12 April 2019) =
70
 
71
  * Added : Option to use URL rather than phone number for contact type in Knowledge Graph #199
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 5.1
6
+ Stable tag: 1.7
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
66
  == Changelog ==
67
 
68
 
69
+ = 1.7 (24 April 2019) =
70
+
71
+ * Added: Option to enable and disable website schema markup #225
72
+ * Added: Option to enable and disable Sitelinks Search Box in website schema markup #196
73
+ * Bug Fixed: Event Time and date is not changing as per the option #227
74
+ * Bug Fixed: Two images url are null from three different image sizes in amp article schema #222
75
+ * Bug Fixed: number_format() Debug error #213
76
+ * Bug Fixed: Undefined offset errors #214, #232, #229
77
+
78
+
79
  = 1.6 (12 April 2019) =
80
 
81
  * Added : Option to use URL rather than phone number for contact type in Knowledge Graph #199
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.6
6
  Text Domain: schema-and-structured-data-for-wp
7
  Domain Path: /languages
8
  Author: Magazine3
@@ -13,7 +13,7 @@ License: GPL2
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
- define('SASWP_VERSION', '1.6');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
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.7
6
  Text Domain: schema-and-structured-data-for-wp
7
  Domain Path: /languages
8
  Author: Magazine3
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
+ define('SASWP_VERSION', '1.7');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));