Schema & Structured Data for WP & AMP - Version 1.9.74

Version Description

(15 May 2021) =

  • Fixed: Custom schema's data is not cleared when the post/page is updated. #1411
  • Fixed: php8.0.3 incompatability #1409
  • Fixed: Product ID Error: Added empty array which cause invalid Json-LD error #1407
  • Fixed: "Thumbnail URL" data is not fetched automatically in VideoObject schema #1405
  • Fixed: EmbedUrl property has error( value url) in the video object schema for specific content #1402
  • Fixed: Shortcode should be rendered its value when present in faq content #1404
  • Fixed: Fatal error: Uncaught Error: Call to a member function get_bookings() on null in event-schema-for-saswp/output/service.php:8 #1410
  • Added: A custom field on each page individually in the Woocommerce product categories to add custom Json-LD. #1400
  • Added: Compatability with YITH google product feed and product feed pro #1408
Download this release

Release Info

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

Code changes from version 1.9.73 to 1.9.74

admin_section/common-function.php CHANGED
@@ -1874,7 +1874,7 @@ if ( ! defined('ABSPATH') ) exit;
1874
 
1875
  }
1876
 
1877
- if($sd_data['saswp-review-module']== 1 && $saswp_rv_item_enable == 1){
1878
 
1879
  $rating_module_css = SASWP_PLUGIN_DIR_PATH . 'admin_section/css/amp/rating-module.css';
1880
  echo @file_get_contents($rating_module_css);
@@ -3254,6 +3254,7 @@ function saswp_get_capability_by_role($role){
3254
  function saswp_current_user_allowed(){
3255
 
3256
  global $sd_data;
 
3257
 
3258
  if(!function_exists('wp_get_current_user')) {
3259
  require_once( ABSPATH . '/wp-includes/pluggable.php' );
@@ -3269,7 +3270,7 @@ function saswp_current_user_allowed(){
3269
  if($currentUser->roles){
3270
  $currentuserrole = (array) $currentUser->roles;
3271
  }else{
3272
- if($currentUser->caps['administrator']){
3273
  $currentuserrole = array('administrator');
3274
  }
3275
  }
@@ -3472,13 +3473,13 @@ function saswp_get_video_metadata($content = ''){
3472
 
3473
  }
3474
 
3475
- preg_match_all( '/src\=\"(.*?)youtube\.com(.*?)\"/s', $content, $matches, PREG_SET_ORDER );
3476
 
3477
  if($matches){
3478
 
3479
  foreach($matches as $match){
3480
 
3481
- $vurl = 'https://youtube.com'.$match[2];
3482
  $metadata = array();
3483
  if(isset($sd_data['saswp-youtube-api']) && $sd_data['saswp-youtube-api'] != ''){
3484
 
1874
 
1875
  }
1876
 
1877
+ if( ( isset($sd_data['saswp-review-module']) && $sd_data['saswp-review-module'] == 1 ) && $saswp_rv_item_enable == 1){
1878
 
1879
  $rating_module_css = SASWP_PLUGIN_DIR_PATH . 'admin_section/css/amp/rating-module.css';
1880
  echo @file_get_contents($rating_module_css);
3254
  function saswp_current_user_allowed(){
3255
 
3256
  global $sd_data;
3257
+ $currentuserrole = array();
3258
 
3259
  if(!function_exists('wp_get_current_user')) {
3260
  require_once( ABSPATH . '/wp-includes/pluggable.php' );
3270
  if($currentUser->roles){
3271
  $currentuserrole = (array) $currentUser->roles;
3272
  }else{
3273
+ if( isset($currentUser->caps['administrator']) ){
3274
  $currentuserrole = array('administrator');
3275
  }
3276
  }
3473
 
3474
  }
3475
 
3476
+ @preg_match_all( '@(https?://)?(?:www\.)?(youtu(?:\.be/([-\w]+)|be\.com/watch\?v=([-\w]+)))\S*@im', $content, $matches, PREG_SET_ORDER );
3477
 
3478
  if($matches){
3479
 
3480
  foreach($matches as $match){
3481
 
3482
+ $vurl = $match[0];
3483
  $metadata = array();
3484
  if(isset($sd_data['saswp-youtube-api']) && $sd_data['saswp-youtube-api'] != ''){
3485
 
admin_section/structure_admin.php CHANGED
@@ -642,7 +642,7 @@ function saswp_comparison_logic_checker($input, $post){
642
 
643
  }else{
644
 
645
- if($input['key_4'] == 'all'){
646
 
647
  if ( $comparison == 'equal' ) {
648
  if ( $post_terms ) {
642
 
643
  }else{
644
 
645
+ if( isset($input['key_4']) && $input['key_4'] == 'all' ) {
646
 
647
  if ( $comparison == 'equal' ) {
648
  if ( $post_terms ) {
output/function.php CHANGED
@@ -252,14 +252,16 @@ function saswp_get_all_schema_markup_output() {
252
  $kb_schema_output = saswp_kb_schema_output();
253
  }
254
 
255
- if(is_singular()){
 
 
256
  $custom_markup = get_post_meta($post->ID, 'saswp_custom_schema_field', true);
257
  }
258
 
259
- $schema_output = saswp_schema_output();
260
 
261
  if(saswp_global_option()) {
262
-
263
  if(!empty($contact_page_output)){
264
 
265
  $output .= saswp_json_print_format($contact_page_output);
252
  $kb_schema_output = saswp_kb_schema_output();
253
  }
254
 
255
+ $custom_markup = saswp_taxonomy_schema_output();
256
+
257
+ if(is_singular()){
258
  $custom_markup = get_post_meta($post->ID, 'saswp_custom_schema_field', true);
259
  }
260
 
261
+ $schema_output = saswp_schema_output();
262
 
263
  if(saswp_global_option()) {
264
+
265
  if(!empty($contact_page_output)){
266
 
267
  $output .= saswp_json_print_format($contact_page_output);
output/gutenberg.php CHANGED
@@ -784,7 +784,7 @@ function saswp_gutenberg_faq_schema(){
784
  $supply_data['@type'] = 'Question';
785
  $supply_data['name'] = htmlspecialchars($val['title'], ENT_QUOTES, 'UTF-8');
786
  $supply_data['acceptedAnswer']['@type'] = 'Answer';
787
- $supply_data['acceptedAnswer']['text'] = htmlspecialchars($val['description'], ENT_QUOTES, 'UTF-8');
788
 
789
  if(isset($val['imageId']) && $val['imageId'] !=''){
790
 
784
  $supply_data['@type'] = 'Question';
785
  $supply_data['name'] = htmlspecialchars($val['title'], ENT_QUOTES, 'UTF-8');
786
  $supply_data['acceptedAnswer']['@type'] = 'Answer';
787
+ $supply_data['acceptedAnswer']['text'] = htmlspecialchars(do_shortcode($val['description']), ENT_QUOTES, 'UTF-8');
788
 
789
  if(isset($val['imageId']) && $val['imageId'] !=''){
790
 
output/markup.php CHANGED
@@ -870,18 +870,18 @@ function saswp_product_schema_markup($schema_id, $schema_post_id, $all_post_meta
870
  )
871
  );
872
 
873
- if( isset($all_post_meta['saswp_product_schema_brand_url_'.$schema_id]) && $all_post_meta['saswp_product_schema_brand_url_'.$schema_id] != '' ){
874
- $input1['brand']['url'] = $all_post_meta['saswp_product_schema_brand_url_'.$schema_id];
875
  }
876
- if( isset($all_post_meta['saswp_product_schema_brand_image_'.$schema_id]) && $all_post_meta['saswp_product_schema_brand_image_'.$schema_id] != '' ){
877
- $input1['brand']['image'] = $all_post_meta['saswp_product_schema_brand_image_'.$schema_id];
878
  }
879
- if( isset($all_post_meta['saswp_product_schema_brand_logo_'.$schema_id]) && $all_post_meta['saswp_product_schema_brand_logo_'.$schema_id] != '' ){
880
- $input1['brand']['logo'] = $all_post_meta['saswp_product_schema_brand_logo_'.$schema_id];
881
  }
882
 
883
- if( isset($all_post_meta['saswp_product_schema_id_'.$schema_id]) && $all_post_meta['saswp_product_schema_id_'.$schema_id] != '' ){
884
- $input1['@id'] = $all_post_meta['saswp_product_schema_id_'.$schema_id];
885
  }
886
 
887
  $input1 = saswp_get_modified_image('saswp_product_schema_image_'.$schema_id.'_detail', $input1);
@@ -1963,7 +1963,7 @@ function saswp_faq_schema_markup($schema_id, $schema_post_id, $all_post_meta){
1963
  $supply_data['@type'] = 'Question';
1964
  $supply_data['name'] = $val['saswp_faq_question_name'];
1965
  $supply_data['acceptedAnswer']['@type'] = 'Answer';
1966
- $supply_data['acceptedAnswer']['text'] = $val['saswp_faq_question_answer'];
1967
 
1968
  $faq_question_arr[] = $supply_data;
1969
  }
@@ -3937,11 +3937,15 @@ function saswp_video_object_schema_markup($schema_id, $schema_post_id, $all_post
3937
  $input1['author']['description'] = saswp_remove_warnings($all_post_meta, 'saswp_video_object_author_description_'.$schema_id, 'saswp_array');
3938
  $input1['author']['url'] = saswp_remove_warnings($all_post_meta, 'saswp_video_object_author_url_'.$schema_id, 'saswp_array');
3939
 
3940
- $input1['author']['image']['@type'] = 'ImageObject';
3941
- $input1['author']['image']['url'] = saswp_remove_warnings($all_post_meta, 'saswp_video_object_author_image_'.$schema_id, 'saswp_array');
3942
- $input1['author']['image']['height'] = $author_image['height'];
3943
- $input1['author']['image']['width'] = $author_image['width'];
3944
-
 
 
 
 
3945
  if(isset($all_post_meta['saswp_video_object_duration_'.$schema_id][0]) ) {
3946
  $input1['duration'] = $all_post_meta['saswp_video_object_duration_'.$schema_id][0];
3947
  }
870
  )
871
  );
872
 
873
+ if( isset($all_post_meta['saswp_product_schema_brand_url_'.$schema_id][0]) && $all_post_meta['saswp_product_schema_brand_url_'.$schema_id][0] != '' ){
874
+ $input1['brand']['url'] = $all_post_meta['saswp_product_schema_brand_url_'.$schema_id][0];
875
  }
876
+ if( isset($all_post_meta['saswp_product_schema_brand_image_'.$schema_id][0]) && $all_post_meta['saswp_product_schema_brand_image_'.$schema_id][0] != '' ){
877
+ $input1['brand']['image'] = $all_post_meta['saswp_product_schema_brand_image_'.$schema_id][0];
878
  }
879
+ if( isset($all_post_meta['saswp_product_schema_brand_logo_'.$schema_id][0]) && $all_post_meta['saswp_product_schema_brand_logo_'.$schema_id][0] != '' ){
880
+ $input1['brand']['logo'] = $all_post_meta['saswp_product_schema_brand_logo_'.$schema_id][0];
881
  }
882
 
883
+ if( isset($all_post_meta['saswp_product_schema_id_'.$schema_id][0]) && $all_post_meta['saswp_product_schema_id_'.$schema_id][0] != '' ){
884
+ $input1['@id'] = $all_post_meta['saswp_product_schema_id_'.$schema_id][0];
885
  }
886
 
887
  $input1 = saswp_get_modified_image('saswp_product_schema_image_'.$schema_id.'_detail', $input1);
1963
  $supply_data['@type'] = 'Question';
1964
  $supply_data['name'] = $val['saswp_faq_question_name'];
1965
  $supply_data['acceptedAnswer']['@type'] = 'Answer';
1966
+ $supply_data['acceptedAnswer']['text'] = do_shortcode($val['saswp_faq_question_answer']);
1967
 
1968
  $faq_question_arr[] = $supply_data;
1969
  }
3937
  $input1['author']['description'] = saswp_remove_warnings($all_post_meta, 'saswp_video_object_author_description_'.$schema_id, 'saswp_array');
3938
  $input1['author']['url'] = saswp_remove_warnings($all_post_meta, 'saswp_video_object_author_url_'.$schema_id, 'saswp_array');
3939
 
3940
+ if(!empty($author_image) && is_array($author_image)){
3941
+
3942
+ $input1['author']['image']['@type'] = 'ImageObject';
3943
+ $input1['author']['image']['url'] = saswp_remove_warnings($all_post_meta, 'saswp_video_object_author_image_'.$schema_id, 'saswp_array');
3944
+ $input1['author']['image']['height'] = $author_image['height'];
3945
+ $input1['author']['image']['width'] = $author_image['width'];
3946
+
3947
+ }
3948
+
3949
  if(isset($all_post_meta['saswp_video_object_duration_'.$schema_id][0]) ) {
3950
  $input1['duration'] = $all_post_meta['saswp_video_object_duration_'.$schema_id][0];
3951
  }
output/output.php CHANGED
@@ -2434,6 +2434,21 @@ function saswp_woocommerce_shop_page(){
2434
 
2435
  }
2436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2437
  /**
2438
  * Function generates archive page schema markup in the form of CollectionPage schema type
2439
  * @global type $query_string
2434
 
2435
  }
2436
 
2437
+ function saswp_taxonomy_schema_output(){
2438
+
2439
+ $input1 = array();
2440
+
2441
+ if( is_category() || is_tag() || is_tax() || ( function_exists('is_product_category') && is_product_category() ) ){
2442
+
2443
+ $term_id = get_queried_object_id();
2444
+ $input1 = get_term_meta( $term_id, 'saswp_custom_schema_field', true );
2445
+
2446
+ }
2447
+
2448
+ return $input1;
2449
+
2450
+ }
2451
+
2452
  /**
2453
  * Function generates archive page schema markup in the form of CollectionPage schema type
2454
  * @global type $query_string
output/service.php CHANGED
@@ -2697,7 +2697,15 @@ Class saswp_output_service{
2697
  $input1['uploadDate'] = $custom_fields['saswp_video_object_upload_date'];
2698
  }
2699
  if(isset($custom_fields['saswp_video_object_thumbnail_url'])){
2700
- $input1['thumbnailUrl'] = saswp_validate_url($custom_fields['saswp_video_object_thumbnail_url']);
 
 
 
 
 
 
 
 
2701
  }
2702
  if(isset($custom_fields['saswp_video_object_content_url']) && wp_http_validate_url($custom_fields['saswp_video_object_content_url']) ){
2703
  $input1['contentUrl'] = saswp_validate_url($custom_fields['saswp_video_object_content_url']);
2697
  $input1['uploadDate'] = $custom_fields['saswp_video_object_upload_date'];
2698
  }
2699
  if(isset($custom_fields['saswp_video_object_thumbnail_url'])){
2700
+
2701
+ if(is_array($custom_fields['saswp_video_object_thumbnail_url'])){
2702
+ $input1['thumbnailUrl'] = $custom_fields['saswp_video_object_thumbnail_url']['url'];
2703
+ }
2704
+
2705
+ if(is_string($custom_fields['saswp_video_object_thumbnail_url'])){
2706
+ $input1['thumbnailUrl'] = $custom_fields['saswp_video_object_thumbnail_url'];
2707
+ }
2708
+
2709
  }
2710
  if(isset($custom_fields['saswp_video_object_content_url']) && wp_http_validate_url($custom_fields['saswp_video_object_content_url']) ){
2711
  $input1['contentUrl'] = saswp_validate_url($custom_fields['saswp_video_object_content_url']);
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.7
6
- Stable tag: 1.9.73
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -120,6 +120,18 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
120
 
121
  == Changelog ==
122
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  = 1.9.73 (07 May 2021) =
124
 
125
  * Added: ID property in the product schema. #1376
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
+ Stable tag: 1.9.74
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
120
 
121
  == Changelog ==
122
 
123
+ = 1.9.74 (15 May 2021) =
124
+
125
+ * Fixed: Custom schema's data is not cleared when the post/page is updated. #1411
126
+ * Fixed: php8.0.3 incompatability #1409
127
+ * Fixed: Product ID Error: Added empty array which cause invalid Json-LD error #1407
128
+ * Fixed: "Thumbnail URL" data is not fetched automatically in VideoObject schema #1405
129
+ * Fixed: EmbedUrl property has error( value url) in the video object schema for specific content #1402
130
+ * Fixed: Shortcode should be rendered its value when present in faq content #1404
131
+ * Fixed: Fatal error: Uncaught Error: Call to a member function get_bookings() on null in event-schema-for-saswp/output/service.php:8 #1410
132
+ * Added: A custom field on each page individually in the Woocommerce product categories to add custom Json-LD. #1400
133
+ * Added: Compatability with YITH google product feed and product feed pro #1408
134
+
135
  = 1.9.73 (07 May 2021) =
136
 
137
  * Added: ID property in the product schema. #1376
structured-data-for-wp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Schema & Structured Data for WP & AMP
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.9.73
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.9.73');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
@@ -78,6 +78,7 @@ require_once SASWP_DIR_NAME.'/admin_section/fields-generator.php';
78
  require_once SASWP_DIR_NAME.'/admin_section/newsletter.php';
79
  require_once SASWP_DIR_NAME.'/admin_section/plugin-installer/install.php';
80
  //Loading View files
 
81
  require_once SASWP_DIR_NAME.'/view/help.php';
82
  require_once SASWP_DIR_NAME.'/view/schema_type.php';
83
  require_once SASWP_DIR_NAME.'/view/paywall.php';
2
  /*
3
  Plugin Name: Schema & Structured Data for WP & AMP
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.9.74
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.9.74');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
78
  require_once SASWP_DIR_NAME.'/admin_section/newsletter.php';
79
  require_once SASWP_DIR_NAME.'/admin_section/plugin-installer/install.php';
80
  //Loading View files
81
+ require_once SASWP_DIR_NAME.'/view/taxonomy.php';
82
  require_once SASWP_DIR_NAME.'/view/help.php';
83
  require_once SASWP_DIR_NAME.'/view/schema_type.php';
84
  require_once SASWP_DIR_NAME.'/view/paywall.php';
view/post_specific.php CHANGED
@@ -561,6 +561,8 @@ class saswp_post_specific {
561
 
562
  if(!empty($custom_schema)){
563
  update_post_meta( $post_id, 'saswp_custom_schema_field', $custom_schema );
 
 
564
  }
565
 
566
  $this->_common_view->saswp_save_common_view($post_id, $this->all_schema);
561
 
562
  if(!empty($custom_schema)){
563
  update_post_meta( $post_id, 'saswp_custom_schema_field', $custom_schema );
564
+ }else{
565
+ delete_post_meta( $post_id, 'saswp_custom_schema_field');
566
  }
567
 
568
  $this->_common_view->saswp_save_common_view($post_id, $this->all_schema);
view/schema_type.php CHANGED
@@ -146,9 +146,11 @@ function saswp_schema_type_meta_box_callback( $post) {
146
  $item_list_custom = '';
147
  $append_reviews = '';
148
  $event_type = '';
 
149
 
150
  if($post){
151
 
 
152
  $schema_options = get_post_meta($post->ID, 'schema_options', true);
153
  $meta_list = get_post_meta($post->ID, 'saswp_meta_list_val', true);
154
  $fixed_text = get_post_meta($post->ID, 'saswp_fixed_text', true);
@@ -546,10 +548,11 @@ function saswp_schema_type_meta_box_callback( $post) {
546
  <td><?php echo saswp_t_string('Item Type' ); ?></td>
547
  <td>
548
 
549
- <select data-id="<?php if(is_object($post)){ echo esc_attr($post->ID); } ?>" name="saswp_itemlist_item_type" class="saswp-itemlist-item-type-list">
550
  <?php
551
 
552
- $item = get_post_meta($post->ID, 'saswp_itemlist_item_type', true);
 
553
  foreach ($item_list_item as $key => $value) {
554
  $sel = '';
555
  if($item == $key){
@@ -568,10 +571,10 @@ function saswp_schema_type_meta_box_callback( $post) {
568
  <td><?php echo saswp_t_string('Item Reviewed Type' ); ?></td>
569
  <td>
570
 
571
- <select data-id="<?php if(is_object($post)){ echo esc_attr($post->ID); } ?>" name="saswp_review_item_reviewed_<?php echo $post->ID; ?>" class="saswp-item-reivewed-list">
572
  <?php
573
 
574
- $item = get_post_meta($post->ID, 'saswp_review_item_reviewed_'.$post->ID, true);
575
  foreach ($item_reviewed as $key => $value) {
576
  $sel = '';
577
  if($item == $key){
@@ -664,13 +667,13 @@ function saswp_schema_type_meta_box_callback( $post) {
664
  <?php
665
 
666
  $attached_rv_json = '';
667
- $attached_rv = get_post_meta($post->ID, 'saswp_attahced_reviews', true);
668
  if($attached_rv){
669
  $attached_rv_json = json_encode($attached_rv);
670
  }
671
 
672
  $attached_col_json = '';
673
- $attached_col = get_post_meta($post->ID, 'saswp_attached_collection', true);
674
  if($attached_col){
675
  $attached_col_json = json_encode($attached_col);
676
  }
@@ -757,7 +760,7 @@ function saswp_schema_type_meta_box_callback( $post) {
757
  </div>
758
 
759
  <div class="saswp-global-container" id="saswp-add-rv-collection">
760
- <div class="saswp-add-rv-note"><strong>Note:</strong> <span><?php echo saswp_t_string( 'The attached collection will only be added in Json-ld' );?></span> </div>
761
  <div data-type="collection" class="saswp-add-rv-automatic-list">
762
 
763
  <?php
@@ -1081,19 +1084,19 @@ function saswp_schema_type_meta_box_callback( $post) {
1081
  $output = '';
1082
  $common_obj = new saswp_view_common_class();
1083
 
1084
- $schema_type = get_post_meta($post->ID, 'schema_type', true);
1085
 
1086
- $schema_fields = saswp_get_fields_by_schema_type($post->ID, null, $schema_type, 'manual');
1087
- $output = $common_obj->saswp_saswp_post_specific($schema_type, $schema_fields, $post->ID, $post->ID, null, null, 1);
1088
 
1089
  if($schema_type == 'Review'){
1090
 
1091
- $item_reviewed = get_post_meta($post->ID, 'saswp_review_item_reviewed_'.$post->ID, true);
1092
  if(!$item_reviewed){
1093
  $item_reviewed = 'Book';
1094
  }
1095
- $response = saswp_get_fields_by_schema_type($post->ID, null, $item_reviewed);
1096
- $output .= $common_obj->saswp_saswp_post_specific($schema_type, $response, $post->ID, $post->ID ,$item_reviewed, null, 1);
1097
 
1098
  }
1099
 
@@ -1204,9 +1207,19 @@ function saswp_schema_type_add_meta_box_save( $post_id ) {
1204
  if ( ! isset( $_POST['saswp_schema_type_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_schema_type_nonce'], 'saswp_schema_type_nonce' ) ) return;
1205
  if ( ! current_user_can( 'edit_post', $post_id ) ) return;
1206
 
1207
- update_post_meta( $post_id, 'schema_type', sanitize_text_field( $_POST['schema_type'] ) );
1208
- update_post_meta( $post_id, 'saswp_business_type', sanitize_text_field( $_POST['saswp_business_type'] ) );
1209
- update_post_meta( $post_id, 'saswp_event_type', sanitize_text_field( $_POST['saswp_event_type'] ) );
 
 
 
 
 
 
 
 
 
 
1210
 
1211
  if(isset($_POST['saswp_business_name'])){
1212
  update_post_meta( $post_id, 'saswp_business_name', sanitize_text_field( $_POST['saswp_business_name'] ) );
@@ -1235,12 +1248,28 @@ function saswp_schema_type_add_meta_box_save( $post_id ) {
1235
  }else{
1236
  delete_post_meta( $post_id, 'saswp_enable_itemlist_schema');
1237
  }
1238
-
1239
- update_post_meta( $post_id, 'saswp_item_list_tags', sanitize_text_field($_POST['saswp_item_list_tags']) );
1240
- update_post_meta( $post_id, 'saswp_item_list_custom', sanitize_text_field($_POST['saswp_item_list_custom']) );
1241
- update_post_meta( $post_id, 'saswp_review_item_reviewed_'.$post_id, sanitize_text_field($_POST['saswp_review_item_reviewed_'.$post_id]) );
1242
- update_post_meta( $post_id, 'saswp_itemlist_item_type', sanitize_text_field($_POST['saswp_itemlist_item_type']) );
1243
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1244
  update_post_meta( $post_id, 'saswp_attahced_reviews', json_decode(wp_unslash($_POST['saswp_attahced_reviews'])) );
1245
  update_post_meta( $post_id, 'saswp_attached_collection', json_decode(wp_unslash($_POST['saswp_attached_collection'])) );
1246
 
146
  $item_list_custom = '';
147
  $append_reviews = '';
148
  $event_type = '';
149
+ $post_id = null;
150
 
151
  if($post){
152
 
153
+ $post_id = $post->ID;
154
  $schema_options = get_post_meta($post->ID, 'schema_options', true);
155
  $meta_list = get_post_meta($post->ID, 'saswp_meta_list_val', true);
156
  $fixed_text = get_post_meta($post->ID, 'saswp_fixed_text', true);
548
  <td><?php echo saswp_t_string('Item Type' ); ?></td>
549
  <td>
550
 
551
+ <select data-id="<?php echo esc_attr($post_id); ?>" name="saswp_itemlist_item_type" class="saswp-itemlist-item-type-list">
552
  <?php
553
 
554
+ $item = get_post_meta($post_id, 'saswp_itemlist_item_type', true);
555
+
556
  foreach ($item_list_item as $key => $value) {
557
  $sel = '';
558
  if($item == $key){
571
  <td><?php echo saswp_t_string('Item Reviewed Type' ); ?></td>
572
  <td>
573
 
574
+ <select data-id="<?php echo esc_attr($post_id); ?>" name="saswp_review_item_reviewed_<?php echo $post_id; ?>" class="saswp-item-reivewed-list">
575
  <?php
576
 
577
+ $item = get_post_meta($post_id, 'saswp_review_item_reviewed_'.$post_id, true);
578
  foreach ($item_reviewed as $key => $value) {
579
  $sel = '';
580
  if($item == $key){
667
  <?php
668
 
669
  $attached_rv_json = '';
670
+ $attached_rv = get_post_meta($post_id, 'saswp_attahced_reviews', true);
671
  if($attached_rv){
672
  $attached_rv_json = json_encode($attached_rv);
673
  }
674
 
675
  $attached_col_json = '';
676
+ $attached_col = get_post_meta($post_id, 'saswp_attached_collection', true);
677
  if($attached_col){
678
  $attached_col_json = json_encode($attached_col);
679
  }
760
  </div>
761
 
762
  <div class="saswp-global-container" id="saswp-add-rv-collection">
763
+ <div class="saswp-add-rv-note"><strong><?php echo saswp_t_string( 'Note:' );?></strong> <span><?php echo saswp_t_string( 'The attached collection will only be added in Json-ld' );?></span> </div>
764
  <div data-type="collection" class="saswp-add-rv-automatic-list">
765
 
766
  <?php
1084
  $output = '';
1085
  $common_obj = new saswp_view_common_class();
1086
 
1087
+ $schema_type = get_post_meta($post_id, 'schema_type', true);
1088
 
1089
+ $schema_fields = saswp_get_fields_by_schema_type($post_id, null, $schema_type, 'manual');
1090
+ $output = $common_obj->saswp_saswp_post_specific($schema_type, $schema_fields, $post_id, $post_id, null, null, 1);
1091
 
1092
  if($schema_type == 'Review'){
1093
 
1094
+ $item_reviewed = get_post_meta($post_id, 'saswp_review_item_reviewed_'.$post_id, true);
1095
  if(!$item_reviewed){
1096
  $item_reviewed = 'Book';
1097
  }
1098
+ $response = saswp_get_fields_by_schema_type($post_id, null, $item_reviewed);
1099
+ $output .= $common_obj->saswp_saswp_post_specific($schema_type, $response, $post_id, $post_id ,$item_reviewed, null, 1);
1100
 
1101
  }
1102
 
1207
  if ( ! isset( $_POST['saswp_schema_type_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_schema_type_nonce'], 'saswp_schema_type_nonce' ) ) return;
1208
  if ( ! current_user_can( 'edit_post', $post_id ) ) return;
1209
 
1210
+ update_post_meta( $post_id, 'schema_type', sanitize_text_field( $_POST['schema_type'] ) );
1211
+
1212
+ if(isset($_POST['saswp_business_type'])){
1213
+ update_post_meta( $post_id, 'saswp_business_type', sanitize_text_field( $_POST['saswp_business_type'] ) );
1214
+ }else{
1215
+ delete_post_meta( $post_id, 'saswp_business_type');
1216
+ }
1217
+
1218
+ if(isset($_POST['saswp_event_type'])){
1219
+ update_post_meta( $post_id, 'saswp_event_type', sanitize_text_field( $_POST['saswp_event_type'] ) );
1220
+ }else{
1221
+ delete_post_meta( $post_id, 'saswp_event_type');
1222
+ }
1223
 
1224
  if(isset($_POST['saswp_business_name'])){
1225
  update_post_meta( $post_id, 'saswp_business_name', sanitize_text_field( $_POST['saswp_business_name'] ) );
1248
  }else{
1249
  delete_post_meta( $post_id, 'saswp_enable_itemlist_schema');
1250
  }
1251
+
1252
+ if(isset($_POST['saswp_item_list_tags'])){
1253
+ update_post_meta( $post_id, 'saswp_item_list_tags', sanitize_text_field($_POST['saswp_item_list_tags']) );
1254
+ }else{
1255
+ delete_post_meta( $post_id, 'saswp_item_list_tags');
1256
+ }
1257
+ if(isset($_POST['saswp_item_list_custom'])){
1258
+ update_post_meta( $post_id, 'saswp_item_list_custom', sanitize_text_field($_POST['saswp_item_list_custom']) );
1259
+ }else{
1260
+ delete_post_meta( $post_id, 'saswp_item_list_custom');
1261
+ }
1262
+ if(isset($_POST['saswp_review_item_reviewed_'.$post_id])){
1263
+ update_post_meta( $post_id, 'saswp_review_item_reviewed_'.$post_id, sanitize_text_field($_POST['saswp_review_item_reviewed_'.$post_id]) );
1264
+ }else{
1265
+ delete_post_meta( $post_id, 'saswp_review_item_reviewed_'.$post_id);
1266
+ }
1267
+ if(isset($_POST['saswp_itemlist_item_type'])){
1268
+ update_post_meta( $post_id, 'saswp_itemlist_item_type', sanitize_text_field($_POST['saswp_itemlist_item_type']) );
1269
+ }else{
1270
+ delete_post_meta( $post_id, 'saswp_itemlist_item_type');
1271
+ }
1272
+
1273
  update_post_meta( $post_id, 'saswp_attahced_reviews', json_decode(wp_unslash($_POST['saswp_attahced_reviews'])) );
1274
  update_post_meta( $post_id, 'saswp_attached_collection', json_decode(wp_unslash($_POST['saswp_attached_collection'])) );
1275
 
view/taxonomy.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exit if accessed directly.
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class SASWP_View_Taxonomy
6
+ {
7
+ /**
8
+ * The unique instance of the plugin.
9
+ *
10
+ * @var SASWP_View_Taxonomy
11
+ */
12
+ private static $instance;
13
+ private $_taxonomy = array(
14
+ 'category',
15
+ 'post_tag',
16
+ 'product_cat',
17
+ 'product_tag'
18
+ );
19
+
20
+ /**
21
+ * Gets an instance of our plugin.
22
+ *
23
+ * @return SASWP_View_Taxonomy
24
+ */
25
+ public static function get_instance()
26
+ {
27
+ if (null === self::$instance) {
28
+ self::$instance = new self();
29
+ }
30
+
31
+ return self::$instance;
32
+ }
33
+
34
+ /**
35
+ * Constructor.
36
+ */
37
+ private function __construct()
38
+ {
39
+
40
+ if(!empty($this->_taxonomy)){
41
+
42
+ foreach ($this->_taxonomy as $value) {
43
+ add_action( "{$value}_edit_form_fields", array($this, "saswp_edit_term_fields"), 10, 2);
44
+ add_action( "created_{$value}", array($this, "saswp_save_term_fields" ));
45
+ add_action( "edited_{$value}", array($this, "saswp_save_term_fields" ));
46
+ }
47
+
48
+ }
49
+
50
+ }
51
+
52
+ public function saswp_edit_term_fields( $term, $taxonomy ) {
53
+
54
+ $value = get_term_meta( $term->term_id, 'saswp_custom_schema_field', true );
55
+
56
+ ?>
57
+
58
+ <tr class="form-field">
59
+ <th>
60
+ <label for="saswp_custom_schema_field"><?php echo saswp_t_string('Custom Schema') ?></label>
61
+ </th>
62
+ <td>
63
+ <textarea rows="4" cols="50" name="saswp_custom_schema_field" id="saswp_custom_schema_field" placeholder="JSON-LD" type="text" ><?php echo esc_html( $value ); ?></textarea>
64
+ <p class="description"><?php echo saswp_t_string('Please provide a valid JSON-LD') ?></p>
65
+ </td>
66
+ </tr>
67
+
68
+ <?php
69
+
70
+ }
71
+
72
+
73
+ public function saswp_save_term_fields( $term_id ) {
74
+
75
+ if(isset($_POST['saswp_custom_schema_field'])){
76
+
77
+ $allowed_html = saswp_expanded_allowed_tags();
78
+
79
+ $custom_schema = wp_kses(wp_unslash($_POST['saswp_custom_schema_field']), $allowed_html);
80
+
81
+ update_term_meta( $term_id, 'saswp_custom_schema_field', $custom_schema );
82
+
83
+ }else{
84
+
85
+ delete_term_meta( $term_id, 'saswp_custom_schema_field');
86
+
87
+ }
88
+
89
+ }
90
+
91
+ }
92
+ SASWP_View_Taxonomy::get_instance();