Schema & Structured Data for WP & AMP - Version 1.9.3

Version Description

(30 Aug 2019) =

  • New Feature: ACF meta fields inside Modify Schema Output #216
  • Added: Compatibility with Squirrly Seo ( https://wordpress.org/plugins/squirrly-seo/ ) #426
  • Added: Compatibility with WP Recipe maker ( https://wordpress.org/plugins/wp-recipe-maker/ ) #323
  • Added: bbPress support with "Q&A Schema" #391
  • Added: WPSSO Core importer #85
  • Bug Fixed: Upgrade to pro message should not be there, if any pro extension is activated #450
  • Bug Fixed: Notice: Undefined index: professionalservice in /schema-and-structured-data-for-wp/output/output.php on line 3731 #448
Download this release

Release Info

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

Code changes from version 1.9.2 to 1.9.3

admin_section/common-function.php CHANGED
@@ -273,7 +273,7 @@ if ( ! defined('ABSPATH') ) exit;
273
  function saswp_import_schema_plugin_data(){
274
 
275
  $schema_post = array();
276
- $errorDesc = array();
277
  global $wpdb;
278
  $user_id = get_current_user_id();
279
 
@@ -476,7 +476,106 @@ if ( ! defined('ABSPATH') ) exit;
476
  }
477
 
478
  }
479
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  function saswp_import_seo_pressor_plugin_data(){
481
 
482
  global $wpdb;
@@ -501,11 +600,7 @@ if ( ! defined('ABSPATH') ) exit;
501
  $social_fields['saswp-twitter-enable'] = 1;
502
  $social_fields['sd_twitter'] = $social['social'];
503
 
504
- break;
505
- case 'Google+':
506
- $social_fields['saswp-google-plus-enable'] = 1;
507
- $social_fields['sd_google_plus'] = $social['social'];
508
- break;
509
  case 'Instagram':
510
  $social_fields['saswp-instagram-enable'] = 1;
511
  $social_fields['sd_instagram'] = $social['social'];
@@ -1658,7 +1753,7 @@ if ( ! defined('ABSPATH') ) exit;
1658
  <?php
1659
  }
1660
 
1661
- if((has_shortcode( get_the_content(), 'saswp_google_review') || is_active_widget( false, false, 'saswp_google_review_widget',true )) &&
1662
  ((isset($sd_data['saswp-google-review']) && $sd_data['saswp-google-review'] == 1) || (isset($sd_data['saswp-shopper-approved-review']) && $sd_data['saswp-shopper-approved-review'] == 1))
1663
  ){
1664
  ?>
@@ -1950,6 +2045,24 @@ if ( ! defined('ABSPATH') ) exit;
1950
 
1951
  }
1952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1953
  if(saswp_remove_warnings($sd_data, 'saswp-the-seo-framework', 'saswp_string') == 1){
1954
 
1955
  $c_excerpt = get_post_meta($post->ID, '_genesis_description', true);
@@ -1982,7 +2095,7 @@ if ( ! defined('ABSPATH') ) exit;
1982
  }
1983
  return '';
1984
  }
1985
-
1986
  /**
1987
  * since @1.8.7
1988
  * Here we are modifying the default title
@@ -1994,7 +2107,26 @@ if ( ! defined('ABSPATH') ) exit;
1994
  global $post;
1995
  global $sd_data;
1996
 
1997
- $title = get_the_title();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1998
 
1999
  //SEOPress
2000
  if(saswp_remove_warnings($sd_data, 'saswp-seo-press', 'saswp_string') == 1){
@@ -2203,7 +2335,16 @@ function saswp_check_plugin_active_status($pname){
2203
  ),
2204
  'aiosp' => array(
2205
  'free' => 'all-in-one-seo-pack/all_in_one_seo_pack.php',
2206
- ),
 
 
 
 
 
 
 
 
 
2207
 
2208
  );
2209
 
273
  function saswp_import_schema_plugin_data(){
274
 
275
  $schema_post = array();
276
+ $errorDesc = array();
277
  global $wpdb;
278
  $user_id = get_current_user_id();
279
 
476
  }
477
 
478
  }
479
+ function saswp_import_wpsso_core_plugin_data(){
480
+
481
+ global $wpdb;
482
+
483
+ $wpsso_option = get_option('wpsso_options');
484
+
485
+ $saswp_option = array();
486
+
487
+ if(isset($wpsso_option['schema_home_person_id'])){
488
+ $user_info = get_userdata($wpsso_option['schema_home_person_id']);
489
+ $saswp_option['sd-person-name'] = $user_info->user_login;
490
+ }
491
+ $saswp_option['sd_name'] = $wpsso_option['site_name'];
492
+ $saswp_option['sd_logo']['url'] = $wpsso_option['schema_logo_url'];
493
+ $saswp_option['saswp_website_schema'] = $wpsso_option['schema_add_home_website'];
494
+
495
+ if(isset($wpsso_option['fb_publisher_url'])){
496
+ $saswp_option['saswp-facebook-enable'] = 1;
497
+ $saswp_option['sd_facebook'] = $wpsso_option['fb_publisher_url'];
498
+ }
499
+ if(isset($wpsso_option['instgram_publisher_url'])){
500
+ $saswp_option['saswp-instagram-enable'] = 1;
501
+ $saswp_option['sd_instagram'] = $wpsso_option['instgram_publisher_url'];
502
+ }
503
+ if(isset($wpsso_option['linkedin_publisher_url'])){
504
+ $saswp_option['saswp-linkedin-enable'] = 1;
505
+ $saswp_option['sd_linkedin'] = $wpsso_option['linkedin_publisher_url'];
506
+ }
507
+ if(isset($wpsso_option['p_publisher_url'])){
508
+ $saswp_option['saswp-pinterest-enable'] = 1;
509
+ $saswp_option['sd_pinterest'] = $wpsso_option['p_publisher_url'];
510
+ }
511
+ if(isset($wpsso_option['sc_publisher_url'])){
512
+ $saswp_option['saswp-soundcloud-enable'] = 1;
513
+ $saswp_option['sd_soundcloud'] = $wpsso_option['sc_publisher_url'];
514
+ }
515
+ if(isset($wpsso_option['tumblr_publisher_url'])){
516
+ $saswp_option['saswp-tumblr-enable'] = 1;
517
+ $saswp_option['sd_tumblr'] = $wpsso_option['tumblr_publisher_url'];
518
+ }
519
+ if(isset($wpsso_option['tc_site'])){
520
+ $saswp_option['saswp-twitter-enable'] = 1;
521
+ $saswp_option['sd_twitter'] = $wpsso_option['tc_site'];
522
+ }
523
+ if(isset($wpsso_option['yt_publisher_url'])){
524
+ $saswp_option['saswp-youtube-enable'] = 1;
525
+ $saswp_option['sd_youtube'] = $wpsso_option['yt_publisher_url'];
526
+ }
527
+
528
+ $schema_post = array(
529
+ 'post_title' => $wpsso_option['schema_type_for_home_index'],
530
+ 'post_status' => 'publish',
531
+ 'post_type' => 'saswp',
532
+ );
533
+
534
+ $data_group_array = array();
535
+
536
+ $data_group_array['group-0'] =array(
537
+ 'data_array' => array(
538
+ array(
539
+ 'key_1' => 'post_type',
540
+ 'key_2' => 'equal',
541
+ 'key_3' => 'post',
542
+ )
543
+ )
544
+ );
545
+
546
+ $saswp_meta_key = array(
547
+ 'schema_type' => $wpsso_option['schema_type_for_home_index'],
548
+ 'data_group_array' => $data_group_array,
549
+ 'imported_from' => 'wpsso_core',
550
+ );
551
+
552
+ if(isset($saswp_option)){
553
+
554
+ $wpdb->query('START TRANSACTION');
555
+ $errorDesc = array();
556
+
557
+ $get_options = get_option('sd_data');
558
+ $merge_options = array_merge($get_options, $saswp_option);
559
+ update_option('sd_data', $merge_options);
560
+
561
+ $post_id = wp_insert_post($schema_post);
562
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
563
+ $wpdb->query("UPDATE ".$wpdb->prefix."posts SET guid ='".esc_sql($guid)."' WHERE ID ='".esc_sql($post_id)."'");
564
+
565
+ foreach ($saswp_meta_key as $key => $val){
566
+ update_post_meta($post_id, $key, $val);
567
+ }
568
+
569
+ if ( count($errorDesc) ){
570
+ echo implode("\n<br/>", $errorDesc);
571
+ $wpdb->query('ROLLBACK');
572
+ }else{
573
+ $wpdb->query('COMMIT');
574
+ return true;
575
+ }
576
+ }
577
+
578
+ }
579
  function saswp_import_seo_pressor_plugin_data(){
580
 
581
  global $wpdb;
600
  $social_fields['saswp-twitter-enable'] = 1;
601
  $social_fields['sd_twitter'] = $social['social'];
602
 
603
+ break;
 
 
 
 
604
  case 'Instagram':
605
  $social_fields['saswp-instagram-enable'] = 1;
606
  $social_fields['sd_instagram'] = $social['social'];
1753
  <?php
1754
  }
1755
 
1756
+ if((has_shortcode( @get_the_content(), 'saswp_google_review') || is_active_widget( false, false, 'saswp_google_review_widget',true )) &&
1757
  ((isset($sd_data['saswp-google-review']) && $sd_data['saswp-google-review'] == 1) || (isset($sd_data['saswp-shopper-approved-review']) && $sd_data['saswp-shopper-approved-review'] == 1))
1758
  ){
1759
  ?>
2045
 
2046
  }
2047
 
2048
+ //SEOPress
2049
+ if(saswp_remove_warnings($sd_data, 'saswp-squirrly-seo', 'saswp_string') == 1 && class_exists('SQ_Models_Abstract_Seo')){
2050
+
2051
+ global $wpdb;
2052
+
2053
+ $query = "SELECT * FROM " . $wpdb->prefix . "qss where post_id=".$post->ID;
2054
+
2055
+ if ($rows = $wpdb->get_results($query, OBJECT)) {
2056
+
2057
+ $seo_data = unserialize($rows[0]->seo) ;
2058
+
2059
+ if(isset($seo_data['description']) && $seo_data['description'] <>''){
2060
+ $excerpt = $seo_data['description'];
2061
+ }
2062
+ }
2063
+ }
2064
+
2065
+
2066
  if(saswp_remove_warnings($sd_data, 'saswp-the-seo-framework', 'saswp_string') == 1){
2067
 
2068
  $c_excerpt = get_post_meta($post->ID, '_genesis_description', true);
2095
  }
2096
  return '';
2097
  }
2098
+
2099
  /**
2100
  * since @1.8.7
2101
  * Here we are modifying the default title
2107
  global $post;
2108
  global $sd_data;
2109
 
2110
+ $title = @get_the_title();
2111
+
2112
+ //SEOPress
2113
+ if(saswp_remove_warnings($sd_data, 'saswp-squirrly-seo', 'saswp_string') == 1 && class_exists('SQ_Models_Abstract_Seo')){
2114
+
2115
+ global $wpdb;
2116
+
2117
+ $query = "SELECT * FROM " . $wpdb->prefix . "qss where post_id=".$post->ID;
2118
+
2119
+ if ($rows = $wpdb->get_results($query, OBJECT)) {
2120
+
2121
+ $seo_data = unserialize($rows[0]->seo) ;
2122
+
2123
+ if(isset($seo_data['title']) && $seo_data['title'] <>''){
2124
+ $title = $seo_data['title'];
2125
+ }
2126
+
2127
+ }
2128
+
2129
+ }
2130
 
2131
  //SEOPress
2132
  if(saswp_remove_warnings($sd_data, 'saswp-seo-press', 'saswp_string') == 1){
2335
  ),
2336
  'aiosp' => array(
2337
  'free' => 'all-in-one-seo-pack/all_in_one_seo_pack.php',
2338
+ ),
2339
+ 'squirrly_seo' => array(
2340
+ 'free' => 'squirrly-seo/squirrly.php',
2341
+ ),
2342
+ 'wpsso_core' => array(
2343
+ 'free' => 'wpsso/wpsso.php',
2344
+ ),
2345
+ 'wp_recipe_maker' => array(
2346
+ 'free' => 'wp-recipe-maker/wp-recipe-maker.php',
2347
+ ),
2348
 
2349
  );
2350
 
admin_section/fields-generator.php CHANGED
@@ -249,7 +249,7 @@ class saswp_fields_generator {
249
  <span class="saswp_cmpny">Google Reviews (Unlimited)</span>
250
  </li>
251
  <li class="check-img"><img src="'.SASWP_PLUGIN_URL.'/admin_section/images/reviews_platform_icon/shopper-approved-img.png">
252
- <span class="saswp_cmpny">Shopper Approved (Unlimited)</span>
253
  </li>
254
  </ul>
255
  <span class="saswp_lst">Integrations Coming soon</span>
249
  <span class="saswp_cmpny">Google Reviews (Unlimited)</span>
250
  </li>
251
  <li class="check-img"><img src="'.SASWP_PLUGIN_URL.'/admin_section/images/reviews_platform_icon/shopper-approved-img.png">
252
+ <span class="saswp_cmpny">Shopper Approved</span>
253
  </li>
254
  </ul>
255
  <span class="saswp_lst">Integrations Coming soon</span>
admin_section/js/main-script.min.js CHANGED
@@ -1 +1,1928 @@
1
- var saswp_meta_list=[],saswp_meta_fields=[],saswp_meta_list_fields=null;function getParameterByName(e,s){s||(s=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var a=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(s);return a?a[2]?decodeURIComponent(a[2].replace(/\+/g," ")):"":null}function saswp_schema_datepicker(){jQuery(".saswp-datepicker-picker").datepicker({dateFormat:"yy-mm-dd",minDate:0})}function saswp_meta_list_html(e,s,a,t){var i="";if(i+='<select class="saswp-custom-meta-list" name="saswp_meta_list_val['+a+']">',$.each(e,function(e,s){i+='<optgroup label="'+s.label+'">',$.each(s["meta-list"],function(e,s){i+='<option value="'+e+'">'+s+"</option>"}),i+="</optgroup>"}),i+="</select>",s){var n="<tr>";n+="<td>",n+='<select class="saswp-custom-fields-name">',$.each(s,function(e,s){n+='<option value="'+e+'">'+s+"</option>"}),n+="</select>",n+="</td>",n+="<td>",n+=i,n+="</td>",n+="</tr>",$(".saswp-custom-fields-table").append(n)}else $(t).html(i)}function saswp_get_meta_list(e,s,a,t){saswp_meta_list[e]?saswp_meta_list_html(saswp_meta_list[e],s,t,a):$.get(ajaxurl,{action:"saswp_get_meta_list",saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(i){saswp_meta_list[e]=i[e],saswp_meta_list_html(saswp_meta_list[e],s,t,a)},"json")}function saswp_get_post_specific_schema_fields(e,s,a,t,i){if(saswp_meta_fields[i]){var n=saswp_fields_html_generator(e,t,i,a,saswp_meta_fields[i]);n&&($(".saswp-"+a+'-section[data-id="'+t+'"]').append(n),saswp_schema_datepicker())}else $.get(ajaxurl,{action:"saswp_get_schema_dynamic_fields_ajax",meta_name:s,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(s){saswp_meta_fields[i]=s,console.log(saswp_meta_fields);var n=saswp_fields_html_generator(e,t,i,a,s);n&&($(".saswp-"+a+'-section[data-id="'+t+'"]').append(n),saswp_schema_datepicker())},"json")}function saswp_fields_html_generator(e,s,a,t,i){var n="";return n+='<div class="saswp-'+t+'-table-div" data-id="'+e+'"><a class="saswp-table-close">X</a><table class="form-table saswp-'+t+'-table">',$.each(i,function(t,i){var o="";switch("saswp_tvseries_season_published_date"==i.name&&(o="saswp-datepicker-picker"),i.type){case"text":n+="<tr><th>"+i.label+'</th><td><input class="'+o+'" style="width:100%" type="text" id="'+i.name+"_"+e+"_"+s+'" name="'+a+s+"["+e+"]["+i.name+']"></td></tr>';break;case"textarea":n+="<tr><th>"+i.label+'</th><td><textarea style="width: 100%" id="'+i.name+"_"+e+"_"+s+'" name="'+a+s+"["+e+"]["+i.name+']" rows="5"></textarea></td></tr>';break;case"select":var p="";$.each(i.options,function(e,s){p+='<option value="'+e+'">'+s+"</option>"}),n+="<tr><th>"+i.label+'</th><td><select id="'+i.name+"_"+e+"_"+s+'" name="'+a+s+"["+e+"]["+i.name+']">'+p+"</select></td></tr>";break;case"media":n+="<tr><th>"+i.label+'</th><td><fieldset><input style="width:80%" type="text" id="'+i.name+"_"+e+"_"+s+'" name="'+i.name+"_"+e+"_"+s+'"><input type="hidden" data-id="'+i.name+"_"+e+"_"+s+'_id" name="'+a+s+"["+e+"]["+i.name+'_id]" id="'+i.name+"_"+e+"_"+s+'_id"><input data-id="media" style="width: 19%" class="button" id="'+i.name+"_"+e+"_"+s+'_button" name="'+i.name+"_"+e+"_"+s+'_button" type="button" value="Upload"><div class="saswp_image_div_'+i.name+"_"+e+"_"+s+'"></div></fieldset></td></tr>'}}),n+="</table></div>"}jQuery(document).ready(function(e){if(saswp_localize_data.do_tour){var s,a="<h3>Thanks for using Structured Data!</h3>";a+="<p>Do you want the latest on <b>Structured Data update</b> before others and some best resources on monetization in a single email? - Free just for users of Structured Data!</p>",a+='<style type="text/css">',a+=".wp-pointer-buttons{ padding:0; overflow: hidden; }",a+=".wp-pointer-content .button-secondary{ left: -25px;background: transparent;top: 5px; border: 0;position: relative; padding: 0; box-shadow: none;margin: 0;color: #0085ba;} .wp-pointer-content .button-primary{ display:none}\t#afw_mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }",a+="</style>",a+='<div id="afw_mc_embed_signup">',a+='<form action="//app.mailerlite.com/webforms/submit/o1s7u3" data-id="258182" data-code="o1s7u3" method="POST" target="_blank">',a+='<div id="afw_mc_embed_signup_scroll">',a+='<div class="afw-mc-field-group" style=" margin-left: 15px; width: 195px; float: left;">',a+='<input type="text" name="fields[name]" class="form-control" placeholder="Name" hidden value="'+saswp_localize_data.current_user_name+'" style="display:none">',a+='<input type="text" value="'+saswp_localize_data.current_user_email+'" name="fields[email]" class="form-control" placeholder="Email*" style=" width: 180px; padding: 6px 5px;">',a+='<input type="text" name="fields[company]" class="form-control" placeholder="Website" hidden style=" display:none; width: 168px; padding: 6px 5px;" value="'+saswp_localize_data.get_home_url+'">',a+='<input type="hidden" name="ml-submit" value="1" />',a+="</div>",a+='<div id="mce-responses">',a+='<div class="response" id="mce-error-response" style="display:none"></div>',a+='<div class="response" id="mce-success-response" style="display:none"></div>',a+="</div>",a+='<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_a631df13442f19caede5a5baf_c9a71edce6" tabindex="-1" value=""></div>',a+='<input type="submit" value="Subscribe" name="subscribe" id="pointer-close" class="button mc-newsletter-sent" style=" background: #0085ba; border-color: #006799; padding: 0px 16px; text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799; height: 30px; margin-top: 1px; color: #fff; box-shadow: 0 1px 0 #006799;">',a+="</div>",a+="</form>";var t={content:a+="</div>",position:{edge:"top",align:"left"}};s=function(){e(saswp_localize_data.displayID).pointer(t).pointer("open"),saswp_localize_data.button2&&(jQuery("#pointer-close").after('<a id="pointer-primary" class="button-primary">'+saswp_localize_data.button2+"</a>"),jQuery("#pointer-primary").click(function(){saswp_localize_data.function_name}),jQuery("#pointer-close").click(function(){e.post(saswp_localize_data.ajax_url,{pointer:"saswp_subscribe_pointer222",action:"dismiss-wp-pointer"})}))},(t=e.extend(t,{buttons:function(e,s){return button=jQuery('<a id="pointer-close" class="button-secondary">'+saswp_localize_data.button1+"</a>"),button_2=jQuery("#pointer-close.button"),button.bind("click.pointer",function(){s.element.pointer("close")}),button_2.on("click",function(){s.element.pointer("close")}),button},close:function(){e.post(saswp_localize_data.ajax_url,{pointer:"saswp_subscribe_pointer222",action:"dismiss-wp-pointer"})},show:function(e,s){s.pointer.css({left:"170px",top:"160px"})}})).position&&t.position.defer_loading?e(window).bind("load.wp-pointers",s):s()}function i(s,a){var t=a.replace("-checkbox",""),i=e("#"+t).next("p").text();s.is(":checked")&&""!==i?e("#"+t).next("p").removeClass("saswp_hide"):1==e("#"+t).next("p").attr("data-id")?e("#"+t).next("p").text("This feature is only available in pro version"):e("#"+t).next("p").addClass("saswp_hide")}function n(){e(".saswp-item-reviewed").change(function(s){s.preventDefault();var a="";if(e("select#schema_type option:selected").val()&&(a=e("select#schema_type option:selected").val()),e(".saswp-tab-links.selected").attr("saswp-schema-type")&&(a=e(".saswp-tab-links.selected").attr("saswp-schema-type")),"Review"===a){var t=e(this),i=e(this).val(),n=saswp_localize_data.post_id,o=e(t).attr("data-id"),p=e(t).attr("post-specific");e.get(ajaxurl,{action:"saswp_get_item_reviewed_fields",schema_id:o,post_specific:p,item:i,post_id:n,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(s){e(t).parent().parent().nextAll().remove(".saswp-review-tr"),e(t).parent().parent().after(s)})}}).change()}function o(){"saswp"!=saswp_localize_data.post_type&&"saswp"!=saswp_localize_data.page_now||"saswp_page_structured_data_options"==saswp_localize_data.page_now||e(".saswp-custom-fields-select2").select2({ajax:{type:"POST",url:ajaxurl,dataType:"json",delay:250,data:function(e){return{saswp_security_nonce:saswp_localize_data.saswp_security_nonce,q:e.term,action:"saswp_get_custom_meta_fields"}},processResults:function(e){return{results:e}},cache:!0},minimumInputLength:2})}function p(){var s="";e("select#schema_type option:selected").val()&&(s=e("select#schema_type option:selected").val()),e(".saswp-tab-links.selected").attr("saswp-schema-type")&&(s=e(".saswp-tab-links.selected").attr("saswp-schema-type")),s&&e(".saswp-enable-rating-review-"+s.toLowerCase()).change(function(){e(this).is(":checked")?e(this).parent().parent().siblings(".saswp-rating-review-"+s.toLowerCase()).show():e(this).parent().parent().siblings(".saswp-rating-review-"+s.toLowerCase()).hide()}).change()}function c(s,a,t,i,n,o,p){s.addClass("updating-message"),e.get(ajaxurl,{action:"saswp_add_s_approved_reviews",site_id:a,token:t,limit:i,api_key:n,page:o,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(l){s.removeClass("updating-message"),console.log(l),l.status?(s.parent().parent().find(".saswp-rv-fetched-msg").text(l.message),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","green")):(s.parent().parent().find(".saswp-rv-fetched-msg").text(l.message),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","#988f1b")),++o<p?c(s,a,t,i,n,o):function(s){s.addClass("updating-message"),e.get(ajaxurl,{action:"saswp_fetch_s_approved_reviews",saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(e){s.removeClass("updating-message"),console.log(e),e.status?(s.parent().parent().find(".saswp-rv-fetched-msg").text(e.message),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","green")):(s.parent().parent().find(".saswp-rv-fetched-msg").text(e.message),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","#988f1b"))},"json")}(s)},"json")}e(".saswp-tabs a").click(function(s){var a=e(this).attr("href"),t=getParameterByName("tab",a);return t||(t="general"),e(this).siblings().removeClass("nav-tab-active"),e(this).addClass("nav-tab-active"),e(".form-wrap").find(".saswp-"+t).siblings().hide(),e(".form-wrap .saswp-"+t).show(),window.history.pushState("","",a),!1}),e(".saswp-schame-type-select").change(function(){e(".saswp-custom-fields-table").html("");var s=e(this).val();e(".saswp-option-table-class tr").each(function(s,a){s>0&&(e(this).hide(),e(this).find("select").attr("disabled",!0))}),"TechArticle"==s||"Article"==s||"Blogposting"==s||"NewsArticle"==s||"WebPage"==s?e(".saswp-enable-speakable").parent().parent().show():e(".saswp-enable-speakable").parent().parent().hide(),"local_business"==s&&(e(".saswp-option-table-class tr").eq(1).show(),e(".saswp-business-text-field-tr").show(),e(".saswp-option-table-class tr").find("select").attr("disabled",!1),e(".select-post-type").val("show_globally").trigger("change")),"Service"==s&&(e(".saswp-service-text-field-tr").show(),e(".saswp-option-table-class tr").find("select").attr("disabled",!1)),"Review"==s&&(e(".saswp-review-text-field-tr").show(),e(".saswp-option-table-class tr").find("select").attr("disabled",!1),n()),"Product"==s&&(e(".saswp-product-text-field-tr").show(),e(".saswp-option-table-class tr").find("select").attr("disabled",!1)),"Event"==s&&(e(".saswp-event-text-field-tr").show(),e(".saswp-option-table-class tr").find("select").attr("disabled",!1)),"AudioObject"==s&&e(".saswp-audio-text-field-tr").show(),"SoftwareApplication"==s&&e(".saswp-softwareapplication-text-field-tr").show(),e(".saswp-schem-type-note").addClass("saswp_hide"),"qanda"==s&&e(".saswp-schem-type-note").removeClass("saswp_hide"),e(".saswp-job-posting-note").addClass("saswp_hide"),p()}),e("#saswp_business_type").change(function(){var s=e(this).val(),a=e(".saswp-schame-type-select").val();e(".saswp-option-table-class tr").each(function(s,a){s>1&&(e(this).hide(),e(this).find("select").attr("disabled",!0))}),"TechArticle"==a||"Article"==a||"Blogposting"==a||"NewsArticle"==a||"WebPage"==a?e(".saswp-enable-speakable").parent().parent().show():e(".saswp-enable-speakable").parent().parent().hide(),"local_business"==a&&(e(".saswp-"+s+"-tr").show(),e(".saswp-business-text-field-tr").show(),e(".saswp-"+s+"-tr").find("select").attr("disabled",!1)),"Service"==a&&(e(".saswp-service-text-field-tr").show(),e(".saswp-service-text-field-tr").find("select").attr("disabled",!1)),"Product"==a&&(e(".saswp-product-text-field-tr").show(),e(".saswp-product-text-field-tr").find("select").attr("disabled",!1)),"AudioObject"==a&&e(".saswp-audio-text-field-tr").show(),"SoftwareApplication"==a&&e(".saswp-softwareapplication-text-field-tr").show(),"Review"==a&&(e(".saswp-review-text-field-tr").show(),e(".saswp-review-text-field-tr").find("select").attr("disabled",!1)),"Event"==a&&(e(".saswp-event-text-field-tr").show(),e(".saswp-event-text-field-tr").find("select").attr("disabled",!1)),p()}).change(),e(".saswp-checkbox").change(function(){var s=e(this).attr("id"),a=e(this);switch(s){case"saswp-the-seo-framework-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-the-seo-framework").val(1):e("#saswp-the-seo-framework").val(0);break;case"saswp-seo-press-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-seo-press").val(1):e("#saswp-seo-press").val(0);break;case"saswp-aiosp-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-aiosp").val(1):e("#saswp-aiosp").val(0);break;case"saswp-smart-crawl-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-smart-crawl").val(1):e("#saswp-smart-crawl").val(0);break;case"saswp-for-wordpress-checkbox":e(this).is(":checked")?e("#saswp-for-wordpress").val(1):e("#saswp-for-wordpress").val(0);break;case"saswp-facebook-enable-checkbox":e(this).is(":checked")?(e("#saswp-facebook-enable").val(1),e("#sd_facebook").show()):(e("#saswp-facebook-enable").val(0),e("#sd_facebook").hide());break;case"saswp-twitter-enable-checkbox":e(this).is(":checked")?(e("#saswp-twitter-enable").val(1),e("#sd_twitter").show()):(e("#saswp-twitter-enable").val(0),e("#sd_twitter").hide());break;case"saswp-google-plus-enable-checkbox":e(this).is(":checked")?(e("#saswp-google-plus-enable").val(1),e("#sd_google_plus").show()):(e("#saswp-google-plus-enable").val(0),e("#sd_google_plus").hide());break;case"saswp-instagram-enable-checkbox":e(this).is(":checked")?(e("#saswp-instagram-enable").val(1),e("#sd_instagram").show()):(e("#saswp-instagram-enable").val(0),e("#sd_instagram").hide());break;case"saswp-youtube-enable-checkbox":e(this).is(":checked")?(e("#sd_youtube").show(),e("#saswp-youtube-enable").val(1)):(e("#saswp-youtube-enable").val(0),e("#sd_youtube").hide());break;case"saswp-linkedin-enable-checkbox":e(this).is(":checked")?(e("#saswp-linkedin-enable").val(1),e("#sd_linkedin").show()):(e("#saswp-linkedin-enable").val(0),e("#sd_linkedin").hide());break;case"saswp-pinterest-enable-checkbox":e(this).is(":checked")?(e("#saswp-pinterest-enable").val(1),e("#sd_pinterest").show()):(e("#saswp-pinterest-enable").val(0),e("#sd_pinterest").hide());break;case"saswp-soundcloud-enable-checkbox":e(this).is(":checked")?(e("#saswp-soundcloud-enable").val(1),e("#sd_soundcloud").show()):(e("#saswp-soundcloud-enable").val(0),e("#sd_soundcloud").hide());break;case"saswp-tumblr-enable-checkbox":e(this).is(":checked")?(e("#saswp-tumblr-enable").val(1),e("#sd_tumblr").show()):(e("#saswp-tumblr-enable").val(0),e("#sd_tumblr").hide());break;case"saswp-for-amp-checkbox":e(this).is(":checked")?e("#saswp-for-amp").val(1):e("#saswp-for-amp").val(0);break;case"saswp_kb_contact_1_checkbox":e(this).is(":checked")?(e("#saswp_kb_contact_1").val(1),e("#saswp_kb_telephone, #saswp_contact_type").parent().parent("li").removeClass("saswp-display-none")):(e("#saswp_kb_contact_1").val(0),e("#saswp_kb_telephone, #saswp_contact_type").parent().parent("li").addClass("saswp-display-none"));break;case"saswp-logo-dimensions-check":e(this).is(":checked")?(e("#saswp-logo-dimensions").val(1),e("#saswp-logo-width, #saswp-logo-height").parent().parent("li").show()):(e("#saswp-logo-dimensions").val(0),e("#saswp-logo-width, #saswp-logo-height").parent().parent("li").hide());break;case"saswp_archive_schema_checkbox":e(this).is(":checked")?(e("#saswp_archive_schema").val(1),e(".saswp_archive_schema_type_class").parent().parent().show()):(e("#saswp_archive_schema").val(0),e(".saswp_archive_schema_type_class").parent().parent().hide());break;case"saswp_website_schema_checkbox":e(this).is(":checked")?(e("#saswp_website_schema").val(1),e("#saswp_search_box_schema").parent().parent().show()):(e("#saswp_website_schema").val(0),e("#saswp_search_box_schema").parent().parent().hide());break;case"saswp_search_box_schema_checkbox":e(this).is(":checked")?e("#saswp_search_box_schema").val(1):e("#saswp_search_box_schema").val(0);break;case"saswp_breadcrumb_schema_checkbox":e(this).is(":checked")?e("#saswp_breadcrumb_schema").val(1):e("#saswp_breadcrumb_schema").val(0);break;case"saswp_comments_schema_checkbox":e(this).is(":checked")?e("#saswp_comments_schema").val(1):e("#saswp_comments_schema").val(0);break;case"saswp-compativility-checkbox":e(this).is(":checked")?e("#saswp-flexmlx-compativility").val(1):e("#saswp-flexmlx-compativility").val(0);break;case"saswp-review-module-checkbox":e(this).is(":checked")?e("#saswp-review-module").val(1):e("#saswp-review-module").val(0);break;case"saswp-kk-star-raring-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-kk-star-raring").val(1):e("#saswp-kk-star-raring").val(0);break;case"saswp-woocommerce-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-woocommerce").val(1):e("#saswp-woocommerce").val(0);break;case"saswp-extra-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-extra").val(1):e("#saswp-extra").val(0);break;case"saswp-dw-question-answer-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-dw-question-answer").val(1):e("#saswp-dw-question-answer").val(0);break;case"saswp-wp-job-manager-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-wp-job-manager").val(1):e("#saswp-wp-job-manager").val(0);break;case"saswp-yoast-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-yoast").val(1):e("#saswp-yoast").val(0);break;case"saswp-rankmath-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-rankmath").val(1):e("#saswp-rankmath").val(0);break;case"saswp-tagyeem-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-tagyeem").val(1):e("#saswp-tagyeem").val(0);break;case"saswp-the-events-calendar-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-the-events-calendar").val(1):e("#saswp-the-events-calendar").val(0);break;case"saswp-woocommerce-booking-checkbox":i(a,s),e(this).is(":checked")?(e("#saswp-woocommerce-booking").val(1),e("#saswp-woocommerce-booking-main").val(1)):(e("#saswp-woocommerce-booking").val(0),e("#saswp-woocommerce-booking-main").val(0));break;case"saswp-woocommerce-booking-main-checkbox":i(a,s),e(this).is(":checked")?(e("#saswp-woocommerce-booking-main").val(1),e("#saswp-woocommerce-booking").val(1)):(e("#saswp-woocommerce-booking-main").val(0),e("#saswp-woocommerce-booking").val(0));break;case"saswp-woocommerce-membership-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-woocommerce-membership").val(1):e("#saswp-woocommerce-membership").val(0);break;case"saswp-defragment-checkbox":e(this).is(":checked")?e("#saswp-defragment").val(1):e("#saswp-defragment").val(0);break;case"saswp-cooked-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-cooked").val(1):e("#saswp-cooked").val(0);break;case"saswp-flexmlx-compativility-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-flexmlx-compativility").val(1):e("#saswp-flexmlx-compativility").val(0);break;case"saswp-shopper-approved-review-checkbox":i(a,s),e(this).is(":checked")?(e("#saswp-shopper-approved-review").val(1),e(".saswp-s-reviews-settings-table").parent().parent().parent().show()):(e("#saswp-shopper-approved-review").val(0),e(".saswp-s-reviews-settings-table").parent().parent().parent().hide());break;case"saswp-google-review-checkbox":e(this).is(":checked")?(e("#saswp-google-review").val(1),e("#saswp-google-rv-free-checkbox").length?(e("#saswp-google-review-free").parent().parent().show(),e("#saswp-google-rv-free-checkbox").is(":checked")?e("#saswp_google_place_api_key").parent().parent().show():e("#saswp_google_place_api_key").parent().parent().hide()):e("#saswp_google_place_api_key").parent().parent().show(),e(".saswp-g-reviews-settings-table").parent().parent().parent().show()):(e("#saswp-google-review").val(0),e("#saswp_google_place_api_key").parent().parent().hide(),e(".saswp-g-reviews-settings-table").parent().parent().parent().hide(),e("#saswp-google-rv-free-checkbox").length&&e("#saswp-google-review-free").parent().parent().hide());break;case"saswp-google-rv-free-checkbox":e("#saswp-google-review-checkbox").is(":checked")&&e(this).is(":checked")?(e("#saswp-google-review-free").val(1),e("#saswp_google_place_api_key").parent().parent().show()):(e("#saswp-google-review-free").val(0),e("#saswp_google_place_api_key").parent().parent().hide());break;case"saswp-markup-footer-checkbox":e(this).is(":checked")?e("#saswp-markup-footer").val(1):e("#saswp-markup-footer").val(0);break;case"saswp-pretty-print-checkbox":e(this).is(":checked")?e("#saswp-pretty-print").val(1):e("#saswp-pretty-print").val(0);break;case"saswp-wppostratings-raring-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-wppostratings-raring").val(1):e("#saswp-wppostratings-raring").val(0);break;case"saswp-bbpress-checkbox":i(a,s),e(this).is(":checked")?e("#saswp-bbpress").val(1):e("#saswp-bbpress").val(0);break;case"saswp-microdata-cleanup-checkbox":e(this).is(":checked")?e("#saswp-microdata-cleanup").val(1):e("#saswp-microdata-cleanup").val(0)}}).change(),e("#saswp_kb_type").change(function(){var s=e(this).val();e(".saswp_org_fields, .saswp_person_fields").parent().parent().addClass("saswp_hide"),e(".saswp_kg_logo").parent().parent().parent().addClass("saswp_hide"),e("#sd-person-image").parent().parent().parent().addClass("saswp_hide"),"Organization"==s&&(e(".saswp_org_fields").parent().parent().removeClass("saswp_hide"),e(".saswp_person_fields").parent().parent().addClass("saswp_hide"),e(".saswp_kg_logo").parent().parent().parent().removeClass("saswp_hide"),e("#sd-person-image").parent().parent().parent().addClass("saswp_hide")),"Person"==s&&(e(".saswp_org_fields").parent().parent().addClass("saswp_hide"),e(".saswp_person_fields").parent().parent().removeClass("saswp_hide"),e(".saswp_kg_logo").parent().parent().parent().removeClass("saswp_hide"),e("#sd-person-image").parent().parent().parent().removeClass("saswp_hide"))}).change(),e(document).on("click","input[data-id=media]",function(s){s.preventDefault();var a=e(this),t=a.attr("id").replace("_button",""),i=wp.media({title:"Application Icon",button:{text:"Select Icon"},multiple:!1,library:{type:"image"}}).on("select",function(){var s=i.state().get("selection").first().toJSON();e("#"+t).val(s.url),e("input[data-id='"+t+"_id']").val(s.id),e("input[data-id='"+t+"_height']").val(s.height),e("input[data-id='"+t+"_width']").val(s.width),e("input[data-id='"+t+"_thumbnail']").val(s.url),"sd_default_image_button"===a.attr("id")&&(e("#sd_default_image_width").val(s.width),e("#sd_default_image_height").val(s.height));var n="";"saswp_image_div_"+t=="saswp_image_div_sd_default_image"&&s.height<1200&&(n='<p class="saswp_warning">Image size is smaller than recommended size</p>'),e(".saswp_image_div_"+t).html('<div class="saswp_image_thumbnail"><img class="saswp_image_prev" src="'+s.url+'"/><a data-id="'+t+'" href="#" class="saswp_prev_close">X</a></div>'+n)}).open()}),e(document).on("click",".saswp_prev_close",function(s){s.preventDefault();var a=e(this).attr("data-id");console.log(a),e(this).parent().remove(),e("#"+a).val(""),e("input[data-id='"+a+"_id']").val(""),e("input[data-id='"+a+"_height']").val(""),e("input[data-id='"+a+"_width']").val(""),e("input[data-id='"+a+"_thumbnail']").val(""),"sd_default_image"===a&&(e("#sd_default_image_width").val(""),e("#sd_default_image_height").val(""))}),e(document).on("change",".saswp-schema-type-toggle",function(s){var a=e(this).attr("data-schema-id"),t=e(this).attr("data-post-id");if(e(this).is(":checked"))var i=1;else i=0;e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_enable_disable_schema_on_post",status:i,schema_id:a,post_id:t,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(e){},error:function(e){console.log(e)}})}),e(document).on("click",".saswp-reset-data",function(s){s.preventDefault(),1==confirm("Are you sure?")&&e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_reset_all_settings",saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(e){setTimeout(function(){location.reload()},1e3)},error:function(e){console.log(e)}})}),e(document).on("click",".saswp_license_activation",function(s){s.preventDefault();var a=e(this);a.addClass("updating-message");var t=e(this).attr("license-status"),i=e(this).attr("add-on"),n=e("#"+i+"_addon_license_key").val();t&&i&&n?e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_license_status_check",license_key:n,license_status:t,add_on:i,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(s){e("#"+i+"_addon_license_key_status").val(s.status),"active"==s.status?(e(".saswp-"+i+"-dashicons").addClass("dashicons-yes"),e(".saswp-"+i+"-dashicons").removeClass("dashicons-no-alt"),e(".saswp-"+i+"-dashicons").css("color","green"),e(".saswp_license_activation[add-on='"+i+"']").attr("license-status","inactive"),e(".saswp_license_activation[add-on='"+i+"']").text("Deactivate"),e(".saswp_license_status_msg[add-on='"+i+"']").text("Activated"),e(".saswp_license_status_msg[add-on='"+i+"']").css("color","green"),e(".saswp_license_status_msg[add-on='"+i+"']").text(s.message)):(e(".saswp-"+i+"-dashicons").addClass("dashicons-no-alt"),e(".saswp-"+i+"-dashicons").removeClass("dashicons-yes"),e(".saswp-"+i+"-dashicons").css("color","red"),e(".saswp_license_activation[add-on='"+i+"']").attr("license-status","active"),e(".saswp_license_activation[add-on='"+i+"']").text("Activate"),e(".saswp_license_status_msg[add-on='"+i+"']").css("color","red"),e(".saswp_license_status_msg[add-on='"+i+"']").text(s.message)),a.removeClass("updating-message")},error:function(e){console.log(e)}}):(alert("Please enter value license key"),a.removeClass("updating-message"))}),e(".saswp-send-query").on("click",function(s){s.preventDefault();var a=e("#saswp_query_message").val();""!=e.trim(a)?e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_send_query_message",message:a,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(s){"t"==s.status?(e(".saswp-query-success").show(),e(".saswp-query-error").hide()):(console.log("dd"),e(".saswp-query-success").hide(),e(".saswp-query-error").show())},error:function(e){console.log(e)}}):alert("Please enter the message")}),e(".saswp-import-plugins").on("click",function(s){s.preventDefault();var a=e(this);a.addClass("updating-message");var t=e(this).attr("data-id");e.get(ajaxurl,{action:"saswp_import_plugin_data",plugin_name:t,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(s){"t"==s.status?(e(a).parent().find(".saswp-imported-message").text(s.message),e(a).parent().find(".saswp-imported-message").removeClass("saswp-error"),setTimeout(function(){location.reload()},2e3)):(e(a).parent().find(".saswp-imported-message").addClass("saswp-error"),e(a).parent().find(".saswp-imported-message").text(s.message)),a.removeClass("updating-message")},"json")}),e(".saswp-feedback-no-thanks").on("click",function(s){s.preventDefault(),e.get(ajaxurl,{action:"saswp_feeback_no_thanks"},function(s){"t"==s.status&&e(".saswp-feedback-notice").hide()},"json")}),e(".saswp-feedback-remindme").on("click",function(s){s.preventDefault(),e.get(ajaxurl,{action:"saswp_feeback_remindme"},function(s){"t"==s.status&&e(".saswp-feedback-notice").hide()},"json")}),e(document).on("change",".saswp-local-business-type-select",function(s){s.preventDefault();var a=e(this),t=e(this).val();e.get(ajaxurl,{action:"saswp_get_sub_business_ajax",business_type:t,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(s){if("t"==s.status){e(".saswp-local-business-name-select").parents("tr").remove();var t=a.parents(".saswp-post-specific-wrapper").attr("data-id"),i='<tr><th><label for="saswp_business_name_'+t+'">Sub Business Type</label></th>';i+='<td><select class="saswp-local-business-name-select" id="saswp_business_name_'+t+'" name="saswp_business_name_'+t+'">',e.each(s.result,function(e,s){i+='<option value="'+e+'">'+s+"</option>"}),i+="</select></td>",i+="</tr>",a.parents(".form-table tr:first").after(i)}else e(".saswp-local-business-name-select").parents("tr").remove()},"json")}),n(),e(".saswp-local-schema-time-picker").timepicker({timeFormat:"H:i:s"}),e(document).on("click",".saswp-add-custom-schema",function(s){s.preventDefault(),e(".saswp-add-custom-schema-field").removeClass("saswp_hide"),e(this).hide()}),e(document).on("click",".saswp-delete-custom-schema",function(s){s.preventDefault(),e("#saswp_custom_schema_field").val(""),e(".saswp-add-custom-schema-field").addClass("saswp_hide"),e(".saswp-add-custom-schema").show()}),e(".saswp-modify_schema_post_enable").on("click",function(s){var a=e(this);a.addClass("updating-message"),s.preventDefault(),e.get(ajaxurl,{action:"saswp_modify_schema_post_enable",post_id:saswp_localize_data.post_id,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(s){a.remove(),e(".saswp-add-custom-schema-div").remove(),e("#post_specific .inside").append(s),a.removeClass("updating-message"),e(".saswp-local-schema-time-picker").timepicker({timeFormat:"H:i:s"}),saswp_schema_datepicker(),p(),n()})}),saswp_schema_datepicker(),e(".saswp-reviews-datepicker-picker").datepicker({dateFormat:"yy-mm-dd"}),e(document).on("click",".saswp-add-more-item",function(s){s.preventDefault();var a=e(".saswp-review-item-list-table tr").length;console.log(a);e(".saswp-review-item-list-table").append('<tr class="saswp-review-item-tr"><td>Review Item Feature</td><td><input type="text" name="saswp-review-item-feature[]"></td><td>Rating</td><td><input step="0.1" min="0" max="5" type="number" name="saswp-review-item-star-rating[]"></td><td><a type="button" class="saswp-remove-review-item button">x</a></td></tr>')}),e(document).on("click",".saswp-remove-review-item",function(s){s.preventDefault(),e(this).parent().parent("tr").remove()}),e(document).on("focusout",".saswp-review-item-tr input[type=number]",function(s){s.preventDefault();var a=0,t=e(".saswp-review-item-tr input[type=number]").length;e(".saswp-review-item-tr input[type=number]").each(function(s,t){""==e(t).val()?a+=parseFloat(0):a+=parseFloat(e(t).val())});var i=a/t;e("#saswp-review-item-over-all").val(i)}),e("#saswp-review-location").change(function(){var s=e(this).val();e(".saswp-review-shortcode").addClass("saswp_hide"),3==s&&e(".saswp-review-shortcode").removeClass("saswp_hide")}).change(),e("#saswp-review-item-enable").change(function(){e(this).is(":checked")?e(".saswp-review-fields").show():e(".saswp-review-fields").hide()}).change(),e(document).on("click",".saswp-restore-post-schema",function(s){s.preventDefault();var a=e(this);if(a.addClass("updating-message"),e(".saswp-post-specific-schema-ids").val())var t=JSON.parse(e(".saswp-post-specific-schema-ids").val());e.post(ajaxurl,{action:"saswp_restore_schema",schema_ids:t,post_id:saswp_localize_data.post_id,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(e){"t"==e.status?setTimeout(function(){location.reload()},1e3):(alert(e.msg),setTimeout(function(){location.reload()},1e3)),a.removeClass("updating-message")},"json")}),e(document).on("click","div.saswp-tab ul.saswp-tab-nav a",function(s){s.preventDefault();var a=e(this).attr("data-id");e(".saswp-post-specific-wrapper").hide(),e("#"+a).show(),e("div.saswp-tab ul.saswp-tab-nav a").removeClass("selected"),e("div.saswp-tab ul.saswp-tab-nav li").removeClass("selected"),e(this).addClass("selected"),e(this).parent().addClass("selected"),p()}),e("#saswp-global-tabs a:first").addClass("saswp-global-selected"),e(".saswp-global-container").hide(),"#saswp-default-container"==window.location.hash?e(".saswp-global-container:eq(2)").show():e(".saswp-global-container:first").show(),e("#saswp-global-tabs a").click(function(){var s=e(this).attr("data-id");e(this).hasClass("saswp-global-selected")||(e("#saswp-global-tabs a").removeClass("saswp-global-selected"),e(this).addClass("saswp-global-selected"),e(".saswp-global-container").hide(),e("#"+s).show())}),e("#saswp-tools-tabs a:first").addClass("saswp-global-selected"),e(".saswp-tools-container").hide(),e(".saswp-tools-container:first").show(),e("#saswp-tools-tabs a").click(function(){var s=e(this).attr("data-id");e(this).hasClass("saswp-global-selected")||(e("#saswp-tools-tabs a").removeClass("saswp-global-selected"),e(this).addClass("saswp-global-selected"),e(".saswp-tools-container").hide(),e("#"+s).show())}),e("#saswp-review-tabs a:first").addClass("saswp-global-selected"),e(".saswp-review-container").hide(),e(".saswp-review-container:first").show(),e("#saswp-review-tabs a").click(function(){var s=e(this).attr("data-id");e(this).hasClass("saswp-global-selected")||(e("#saswp-review-tabs a").removeClass("saswp-global-selected"),e(this).addClass("saswp-global-selected"),e(".saswp-review-container").hide(),e("#"+s).show())}),e('a[href="'+saswp_localize_data.new_url_selector+'"]').attr("href",saswp_localize_data.new_url_href),e("#saswp_enable_custom_field").change(function(){e(this).is(":checked")?e(".saswp-custom-fields-div").show():e(".saswp-custom-fields-div").hide()}),e(document).on("change",".saswp-custom-fields-name",function(){var s="text",a=e(this).val();-1!=a.indexOf("image")&&(s="image"),saswp_get_meta_list(s,null,e(this).parent().parent("tr").find("td:eq(1)"),a),e(this).parent().parent("tr").find("td:gt(1)").remove()}),e(document).on("click",".saswp-skip-button",function(s){s.preventDefault(),e(this).parent().parent().hide(),e.post(ajaxurl,{action:"saswp_skip_wizard",saswp_security_nonce:saswp_localize_data.saswp_security_nonce},function(e){},"json")}),e(document).on("click",".saswp_add_schema_fields_on_fly",function(s){s.preventDefault();var a=e(this).attr("data-id"),t=e(this).attr("fields_type"),i=e(this).attr("div_type"),n=e(".saswp-"+i+"-table-div").length,o=e(".saswp-"+i+"-table-div:nth-child("+n+")").attr("data-id");(o=++o)||(o=0),saswp_get_post_specific_schema_fields(o,t,i,a,t+"_")}),e(document).on("click",".saswp-table-close",function(){e(this).parent().remove()}),e(document).on("change",".saswp-custom-meta-list",function(){var s=e(this).val(),a=e(this).parent().parent("tr").find(".saswp-custom-fields-name").val(),t="";"manual_text"==s&&(t='<td><input type="text" name="saswp_fixed_text['+a+']"></td>'),"custom_field"==s&&(t+='<td><select class="saswp-custom-fields-select2" name="saswp_custom_meta_field['+a+']">',t+="</select></td>"),e(this).parent().parent("tr").find("td:gt(1)").remove(),e(this).parent().parent("tr").append(t),o()}),e(document).on("click",".saswp-add-custom-fields",function(){var s=e("select#schema_type option:selected").val(),a=e("#post_ID").val();""!=s&&(saswp_meta_list_fields?saswp_get_meta_list("text",saswp_meta_list_fields,null,null):e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_get_schema_type_fields",post_id:a,schema_type:s,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(e){saswp_get_meta_list("text",saswp_meta_list_fields=e,null,null)},error:function(e){console.log(e)}}))}),o(),p(),e('a[href="'+saswp_localize_data.collection_post_add_url+'"]').attr("href",saswp_localize_data.collection_post_add_new_url),e(document).on("click",".saswp_coonect_google_place",function(){var s=e("#saswp_google_place_id").val(),a=e("#saswp_language_list").val(),t=e("#saswp_googel_api").val();""!=s&&e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_connect_google_place",place_id:s,language:a,google_api:t,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(e){console.log(e.status)},error:function(e){console.log(e)}})}),"saswp"==saswp_localize_data.post_type&&"edit.php"==saswp_localize_data.page_now&&jQuery(jQuery(".wrap a")[0]).after("<a href='"+saswp_localize_data.saswp_settings_url+"' id='' class='page-title-action'>Settings</a>"),"undefined"!=typeof saswp_reviews_data&&e(".saswp-rating-div").rateYo({rating:saswp_reviews_data.rating_val,halfStar:!0,readOnly:saswp_reviews_data.readonly,onSet:function(s,a){e(this).next().val(s),console.log(s)}}),e(document).on("click",".saswp-add-g-location-btn",function(s){var a="";a=e("#saswp_google_place_api_key").length?'<input class="saswp-g-blocks-field" name="sd_data[saswp_reviews_location_blocks][]" type="number" min="5" step="5" placeholder="5" disabled="disabled">':'<input class="saswp-g-blocks-field" name="sd_data[saswp_reviews_location_blocks][]" type="number" min="10" step="10" placeholder="10">',s.preventDefault();var t="";(t+='<tr><td style="width:12%;"><strong>Place Id</strong></td><td style="width:20%;"><input class="saswp-g-location-field" name="sd_data[saswp_reviews_location_name][]" type="text" value=""></td><td style="width:10%;"><strong>Reviews</strong></td><td style="width:10%;">'+a+'</td><td style="width:10%;"><a class="button button-default saswp-fetch-g-reviews">Fetch</a></td><td style="width:10%;"><a type="button" class="saswp-remove-review-item button">x</a></td><td style="width:10%;"><p class="saswp-rv-fetched-msg"></p></td></tr>')&&e(".saswp-g-reviews-settings-table").append(t)}),e(document).on("click",".saswp-fetch-s-approved-reviews",function(s){s.preventDefault();var a=e(this);a.addClass("updating-message");var t=e("#saswp_s_approved_site_id").val(),i=e("#saswp_s_approved_token").val(),n=e("#saswp_s_approved_reviews").val(),o=e("#reviews_addon_license_key").val(),p=1;n>100&&(p=n/100,n%100&&p++);t&&i&&o?c(a,t,i,n,o,0,p):(a.removeClass("updating-message"),alert("Fill the site id and token with valid api key"))}),e(document).on("click",".saswp-fetch-g-reviews",function(){var s=e(this),a="free";s.addClass("updating-message");var t=e(this).parent().parent().find(".saswp-g-location-field").val(),i=e(this).parent().parent().find(".saswp-g-blocks-field").val(),n=e("#saswp_google_place_api_key").val(),o=e("#reviews_addon_license_key").val(),p=e("#reviews_addon_license_key_status").val();if("premium"==(a=e("#saswp_google_place_api_key").length?"free":"premium")){if(!(i>0))return alert("Blocks value is zero"),s.removeClass("updating-message"),!1;if(0!=i%10)return s.parent().parent().find(".saswp-rv-fetched-msg").text("Reviews count should be in step of 10"),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","#988f1b"),s.removeClass("updating-message"),!1}""!=t&&(o||n)?e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"saswp_fetch_google_reviews",reviews_api_status:p,reviews_api:o,location:t,blocks:i,g_api:n,premium_status:a,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},success:function(e){"t"==e.status?(s.parent().parent().find(".saswp-rv-fetched-msg").text("Success"),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","green")):(s.parent().parent().find(".saswp-rv-fetched-msg").text(e.message),s.parent().parent().find(".saswp-rv-fetched-msg").css("color","#988f1b")),s.removeClass("updating-message")},error:function(e){console.log(e)}}):(""==t&&alert("Please enter place id"),""==n&&alert("Please enter api key"),""==o&&alert("Please enter reviews api key"),s.removeClass("updating-message"))}),e("#sd-person-phone-number, #saswp_kb_telephone").focusout(function(){var s=e(this);s.parent().find(".saswp-phone-validation").remove();var a=e(this).val();/^\+([0-9]{1,3})\)?[-. ]?([0-9]{2,4})[-. ]?([0-9]{2,4})[-. ]?([0-9]{2,4})$/.test(a)?s.parent().find(".saswp-phone-validation").remove():s.after('<span style="color:red;" class="saswp-phone-validation">Invalid Phone Number</span>')})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var saswp_meta_list = [];
2
+ var saswp_meta_fields = [];
3
+ var saswp_meta_list_fields = null;
4
+
5
+ function getParameterByName(name, url) {
6
+ if (!url){
7
+ url = window.location.href;
8
+ }
9
+ name = name.replace(/[\[\]]/g, "\\$&");
10
+ var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
11
+ results = regex.exec(url);
12
+ if (!results) return null;
13
+ if (!results[2]) return "";
14
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
15
+ }
16
+
17
+ function saswp_schema_datepicker(){
18
+
19
+ jQuery('.saswp-datepicker-picker').datepicker({
20
+ dateFormat: "yy-mm-dd",
21
+ minDate: 0
22
+ });
23
+
24
+ }
25
+
26
+
27
+ function saswp_meta_list_html(response, fields, field_name, id){
28
+
29
+ var re_html = '';
30
+ re_html += '<select class="saswp-custom-meta-list" name="saswp_meta_list_val['+field_name+']">';
31
+ $.each(response, function(key,value){
32
+
33
+ re_html += '<optgroup label="'+value['label']+'">';
34
+
35
+ $.each(value['meta-list'], function(key, value){
36
+ re_html += '<option value="'+key+'">'+value+'</option>';
37
+ });
38
+ re_html += '</optgroup>';
39
+
40
+ });
41
+ re_html += '</select>';
42
+
43
+ if(fields){
44
+ var html = '<tr>';
45
+ html += '<td>';
46
+ html += '<select class="saswp-custom-fields-name">';
47
+ $.each(fields, function(key,value){
48
+ html += '<option value="'+key+'">'+value+'</option>';
49
+ });
50
+ html += '</select>';
51
+ html += '</td>';
52
+ html += '<td>';
53
+ html += re_html;
54
+ html += '</td>';
55
+ html += '</tr>';
56
+ $(".saswp-custom-fields-table").append(html);
57
+
58
+ }else{
59
+ $(id).html(re_html);
60
+ }
61
+
62
+ }
63
+
64
+
65
+
66
+
67
+ function saswp_get_meta_list(type, fields, id, fields_name){
68
+ if (!saswp_meta_list[type]) {
69
+
70
+ $.get(ajaxurl,
71
+ { action:"saswp_get_meta_list", saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
72
+ function(response){
73
+ saswp_meta_list[type] = response[type];
74
+ saswp_meta_list_html(saswp_meta_list[type], fields, fields_name, id);
75
+
76
+ },'json');
77
+
78
+ }else{
79
+ saswp_meta_list_html(saswp_meta_list[type], fields, fields_name, id);
80
+ }
81
+
82
+ }
83
+
84
+ function saswp_get_post_specific_schema_fields(index, meta_name, div_type, schema_id, fields_type){
85
+
86
+ if (!saswp_meta_fields[fields_type]) {
87
+
88
+ $.get(ajaxurl,
89
+ { action:"saswp_get_schema_dynamic_fields_ajax",meta_name:meta_name, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
90
+ function(response){
91
+ saswp_meta_fields[fields_type] = response;
92
+ console.log(saswp_meta_fields);
93
+ var html = saswp_fields_html_generator(index, schema_id, fields_type, div_type, response);
94
+
95
+ if(html){
96
+ $('.saswp-'+div_type+'-section[data-id="'+schema_id+'"]').append(html);
97
+ saswp_schema_datepicker();
98
+ }
99
+
100
+ },'json');
101
+
102
+ }else{
103
+
104
+ var html = saswp_fields_html_generator(index, schema_id, fields_type, div_type, saswp_meta_fields[fields_type]);
105
+
106
+ if(html){
107
+ $('.saswp-'+div_type+'-section[data-id="'+schema_id+'"]').append(html);
108
+ saswp_schema_datepicker();
109
+ }
110
+
111
+ }
112
+
113
+
114
+ }
115
+
116
+ function saswp_fields_html_generator(index, schema_id, fields_type, div_type, schema_fields){
117
+
118
+ var html = '';
119
+
120
+ html += '<div class="saswp-'+div_type+'-table-div" data-id="'+index+'">'
121
+ + '<a class="saswp-table-close">X</a>'
122
+ + '<table class="form-table saswp-'+div_type+'-table">'
123
+
124
+ $.each(schema_fields, function(eachindex, element){
125
+
126
+ var meta_class = "";
127
+ if(element.name == 'saswp_tvseries_season_published_date'){
128
+ meta_class = "saswp-datepicker-picker";
129
+ }
130
+
131
+ switch(element.type) {
132
+
133
+ case "text":
134
+
135
+ html += '<tr>'
136
+ + '<th>'+element.label+'</th><td><input class="'+meta_class+'" style="width:100%" type="text" id="'+element.name+'_'+index+'_'+schema_id+'" name="'+fields_type+schema_id+'['+index+']['+element.name+']"></td>'
137
+ + '</tr>';
138
+
139
+ break;
140
+
141
+ case "textarea":
142
+
143
+ html += '<tr>'
144
+ + '<th>'+element.label+'</th><td><textarea style="width: 100%" id="'+element.name+'_'+index+'_'+schema_id+'" name="'+fields_type+schema_id+'['+index+']['+element.name+']" rows="5"></textarea></td>'
145
+ + '</tr>';
146
+
147
+ break;
148
+ case "select":
149
+
150
+ var options_html = "";
151
+ $.each(element.options, function(opt_index, opt_element){
152
+ options_html += '<option value="'+opt_index+'">'+opt_element+'</option>';
153
+ });
154
+
155
+ html += '<tr>'
156
+ + '<th>'+element.label+'</th>'
157
+ + '<td>'
158
+
159
+ + '<select id="'+element.name+'_'+index+'_'+schema_id+'" name="'+fields_type+schema_id+'['+index+']['+element.name+']">'
160
+ + options_html
161
+ + '</select>'
162
+
163
+ + '</td>'
164
+ + '</tr>';
165
+
166
+ break;
167
+
168
+ case "media":
169
+
170
+ html += '<tr>'
171
+ + '<th>'+element.label+'</th>'
172
+ + '<td>'
173
+ + '<fieldset>'
174
+ + '<input style="width:80%" type="text" id="'+element.name+'_'+index+'_'+schema_id+'" name="'+element.name+'_'+index+'_'+schema_id+'">'
175
+ + '<input type="hidden" data-id="'+element.name+'_'+index+'_'+schema_id+'_id" name="'+fields_type+schema_id+'['+index+']['+element.name+'_id]" id="'+element.name+'_'+index+'_'+schema_id+'_id">'
176
+ + '<input data-id="media" style="width: 19%" class="button" id="'+element.name+'_'+index+'_'+schema_id+'_button" name="'+element.name+'_'+index+'_'+schema_id+'_button" type="button" value="Upload">'
177
+ + '<div class="saswp_image_div_'+element.name+'_'+index+'_'+schema_id+'">'
178
+ + '</div>'
179
+ + '</fieldset>'
180
+ + '</td>'
181
+ + '</tr>';
182
+
183
+ break;
184
+ default:
185
+ // code block
186
+ }
187
+
188
+ });
189
+ html += '</table>'
190
+ + '</div>';
191
+
192
+ return html;
193
+
194
+ }
195
+
196
+ jQuery(document).ready(function($){
197
+
198
+ /* Newletters js starts here */
199
+
200
+ if(saswp_localize_data.do_tour){
201
+
202
+ var content = '<h3>Thanks for using Structured Data!</h3>';
203
+ content += '<p>Do you want the latest on <b>Structured Data update</b> before others and some best resources on monetization in a single email? - Free just for users of Structured Data!</p>';
204
+ content += '<style type="text/css">';
205
+ content += '.wp-pointer-buttons{ padding:0; overflow: hidden; }';
206
+ content += '.wp-pointer-content .button-secondary{ left: -25px;background: transparent;top: 5px; border: 0;position: relative; padding: 0; box-shadow: none;margin: 0;color: #0085ba;} .wp-pointer-content .button-primary{ display:none} #afw_mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }';
207
+ content += '</style>';
208
+ content += '<div id="afw_mc_embed_signup">';
209
+ content += '<form action="//app.mailerlite.com/webforms/submit/o1s7u3" data-id="258182" data-code="o1s7u3" method="POST" target="_blank">';
210
+ content += '<div id="afw_mc_embed_signup_scroll">';
211
+ content += '<div class="afw-mc-field-group" style=" margin-left: 15px; width: 195px; float: left;">';
212
+ content += '<input type="text" name="fields[name]" class="form-control" placeholder="Name" hidden value="'+saswp_localize_data.current_user_name+'" style="display:none">';
213
+ content += '<input type="text" value="'+saswp_localize_data.current_user_email+'" name="fields[email]" class="form-control" placeholder="Email*" style=" width: 180px; padding: 6px 5px;">';
214
+ content += '<input type="text" name="fields[company]" class="form-control" placeholder="Website" hidden style=" display:none; width: 168px; padding: 6px 5px;" value="'+saswp_localize_data.get_home_url+'">';
215
+ content += '<input type="hidden" name="ml-submit" value="1" />';
216
+ content += '</div>';
217
+ content += '<div id="mce-responses">';
218
+ content += '<div class="response" id="mce-error-response" style="display:none"></div>';
219
+ content += '<div class="response" id="mce-success-response" style="display:none"></div>';
220
+ content += '</div>';
221
+ content += '<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_a631df13442f19caede5a5baf_c9a71edce6" tabindex="-1" value=""></div>';
222
+ content += '<input type="submit" value="Subscribe" name="subscribe" id="pointer-close" class="button mc-newsletter-sent" style=" background: #0085ba; border-color: #006799; padding: 0px 16px; text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799; height: 30px; margin-top: 1px; color: #fff; box-shadow: 0 1px 0 #006799;">';
223
+ content += '</div>';
224
+ content += '</form>';
225
+ content += '</div>';
226
+
227
+ var setup;
228
+ var wp_pointers_tour_opts = {
229
+ content:content,
230
+ position:{
231
+ edge:"top",
232
+ align:"left"
233
+ }
234
+ };
235
+
236
+ wp_pointers_tour_opts = $.extend (wp_pointers_tour_opts, {
237
+ buttons: function (event, t) {
238
+ button= jQuery ('<a id="pointer-close" class="button-secondary">' + saswp_localize_data.button1 + '</a>');
239
+ button_2= jQuery ('#pointer-close.button');
240
+ button.bind ('click.pointer', function () {
241
+ t.element.pointer ('close');
242
+ });
243
+ button_2.on('click', function() {
244
+ t.element.pointer ('close');
245
+ } );
246
+ return button;
247
+ },
248
+ close: function () {
249
+ $.post (saswp_localize_data.ajax_url, {
250
+ pointer: 'saswp_subscribe_pointer222',
251
+ action: 'dismiss-wp-pointer'
252
+ });
253
+ },
254
+ show: function(event, t){
255
+ t.pointer.css({'left':'170px', 'top':'160px'});
256
+ }
257
+ });
258
+ setup = function () {
259
+ $(saswp_localize_data.displayID).pointer(wp_pointers_tour_opts).pointer('open');
260
+ if (saswp_localize_data.button2) {
261
+ jQuery ('#pointer-close').after ('<a id="pointer-primary" class="button-primary">' + saswp_localize_data.button2+ '</a>');
262
+ jQuery ('#pointer-primary').click (function () {
263
+ saswp_localize_data.function_name;
264
+ });
265
+ jQuery ('#pointer-close').click (function () {
266
+ $.post (saswp_localize_data.ajax_url, {
267
+ pointer: 'saswp_subscribe_pointer222',
268
+ action: 'dismiss-wp-pointer'
269
+ });
270
+ });
271
+ }
272
+ };
273
+ if (wp_pointers_tour_opts.position && wp_pointers_tour_opts.position.defer_loading) {
274
+ $(window).bind('load.wp-pointers', setup);
275
+ }
276
+ else {
277
+ setup ();
278
+ }
279
+
280
+ }
281
+
282
+ /* Newletters js ends here */
283
+
284
+
285
+ $(".saswp-tabs a").click(function(e){
286
+ var href = $(this).attr('href');
287
+ var currentTab = getParameterByName('tab',href);
288
+ if(!currentTab){
289
+ currentTab = "general";
290
+ }
291
+ $(this).siblings().removeClass("nav-tab-active");
292
+ $(this).addClass("nav-tab-active");
293
+ $(".form-wrap").find(".saswp-"+currentTab).siblings().hide();
294
+ $(".form-wrap .saswp-"+currentTab).show();
295
+ window.history.pushState("", "", href);
296
+ return false;
297
+ });
298
+
299
+ $(".saswp-schame-type-select").change(function(){
300
+ $(".saswp-custom-fields-table").html('');
301
+ var schematype = $ (this).val();
302
+
303
+ $(".saswp-option-table-class tr").each(function(index,value){
304
+ if(index>0){
305
+ $(this).hide();
306
+ $(this).find('select').attr('disabled', true);
307
+ }
308
+ });
309
+ if(schematype == 'TechArticle' || schematype == 'Article' || schematype == 'Blogposting' || schematype == 'NewsArticle' || schematype == 'WebPage'){
310
+
311
+ $(".saswp-enable-speakable").parent().parent().show();
312
+ }else{
313
+ $(".saswp-enable-speakable").parent().parent().hide();
314
+ }
315
+
316
+ if(schematype == 'local_business'){
317
+ $(".saswp-option-table-class tr").eq(1).show();
318
+ $(".saswp-business-text-field-tr").show();
319
+ $(".saswp-option-table-class tr").find('select').attr('disabled', false);
320
+ // $("#saswp_dayofweek").attr('disabled', false);
321
+ $('.select-post-type').val('show_globally').trigger('change');
322
+ }
323
+ if(schematype == 'Service'){
324
+ $(".saswp-service-text-field-tr").show();
325
+ $(".saswp-option-table-class tr").find('select').attr('disabled', false);
326
+ }
327
+ if(schematype == 'Review'){
328
+ $(".saswp-review-text-field-tr").show();
329
+ $(".saswp-option-table-class tr").find('select').attr('disabled', false);
330
+ saswp_item_reviewed_call();
331
+ }
332
+ if(schematype == 'Product'){
333
+ $(".saswp-product-text-field-tr").show();
334
+ $(".saswp-option-table-class tr").find('select').attr('disabled', false);
335
+ }
336
+ if(schematype == 'Event'){
337
+ $(".saswp-event-text-field-tr").show();
338
+ $(".saswp-option-table-class tr").find('select').attr('disabled', false);
339
+ }
340
+ if(schematype == 'AudioObject'){
341
+ $(".saswp-audio-text-field-tr").show();
342
+ }
343
+ if(schematype == 'SoftwareApplication'){
344
+ $(".saswp-softwareapplication-text-field-tr").show();
345
+ }
346
+
347
+ $(".saswp-schem-type-note").addClass('saswp_hide');
348
+ if(schematype == 'qanda'){
349
+ $(".saswp-schem-type-note").removeClass('saswp_hide');
350
+ }
351
+
352
+ $(".saswp-job-posting-note").addClass('saswp_hide');
353
+
354
+ // if(schematype == 'JobPosting'){
355
+ // $(".saswp-job-posting-note").removeClass('saswp_hide');
356
+ // }
357
+
358
+ saswp_enable_rating_review();
359
+ });
360
+
361
+ $("#saswp_business_type").change(function(){
362
+ var businesstype = $ (this).val();
363
+ var schematype = $(".saswp-schame-type-select").val();
364
+
365
+ $(".saswp-option-table-class tr").each(function(index,value){
366
+ if(index>1){
367
+ $(this).hide();
368
+ $(this).find('select').attr('disabled', true);
369
+ }
370
+ });
371
+
372
+ if(schematype == 'TechArticle' || schematype == 'Article' || schematype == 'Blogposting' || schematype == 'NewsArticle' || schematype == 'WebPage'){
373
+
374
+ $(".saswp-enable-speakable").parent().parent().show();
375
+ }else{
376
+ $(".saswp-enable-speakable").parent().parent().hide();
377
+ }
378
+
379
+ if(schematype == 'local_business'){
380
+ $(".saswp-"+businesstype+'-tr').show();
381
+ $(".saswp-business-text-field-tr").show();
382
+ $(".saswp-"+businesstype+'-tr').find('select').attr('disabled', false);
383
+ // $("#saswp_dayofweek").attr('disabled', false);
384
+ }
385
+ if(schematype == 'Service'){
386
+ $(".saswp-service-text-field-tr").show();
387
+ $(".saswp-service-text-field-tr").find('select').attr('disabled', false);
388
+ }
389
+ if(schematype == 'Product'){
390
+ $(".saswp-product-text-field-tr").show();
391
+ $(".saswp-product-text-field-tr").find('select').attr('disabled', false);
392
+ }
393
+ if(schematype == 'AudioObject'){
394
+ $(".saswp-audio-text-field-tr").show();
395
+ }
396
+ if(schematype == 'SoftwareApplication'){
397
+ $(".saswp-softwareapplication-text-field-tr").show();
398
+ }
399
+
400
+ if(schematype == 'Review'){
401
+ $(".saswp-review-text-field-tr").show();
402
+ $(".saswp-review-text-field-tr").find('select').attr('disabled', false);
403
+ }
404
+ if(schematype == 'Event'){
405
+ $(".saswp-event-text-field-tr").show();
406
+ $(".saswp-event-text-field-tr").find('select').attr('disabled', false);
407
+ }
408
+ saswp_enable_rating_review();
409
+ }).change();
410
+
411
+
412
+ //Settings page jquery starts here
413
+
414
+
415
+ function saswp_compatibliy_notes(current, id){
416
+
417
+ var plugin_name = id.replace('-checkbox','');
418
+ var text = $("#"+plugin_name).next('p').text();
419
+
420
+ if (current.is(':checked') && text !=='') {
421
+ $("#"+plugin_name).next('p').removeClass('saswp_hide');
422
+ }else{
423
+
424
+ if($("#"+plugin_name).next('p').attr('data-id') == 1){
425
+ $("#"+plugin_name).next('p').text('This feature is only available in pro version');
426
+ }else{
427
+ $("#"+plugin_name).next('p').addClass('saswp_hide');
428
+ }
429
+ }
430
+
431
+ }
432
+
433
+
434
+ $(".saswp-checkbox").change(function(){
435
+
436
+ var id = $(this).attr("id");
437
+ var current = $(this);
438
+
439
+
440
+ switch(id){
441
+
442
+ case 'saswp-the-seo-framework-checkbox':
443
+ saswp_compatibliy_notes(current, id);
444
+ if ($(this).is(':checked')) {
445
+ $("#saswp-the-seo-framework").val(1);
446
+ }else{
447
+ $("#saswp-the-seo-framework").val(0);
448
+ }
449
+ break;
450
+
451
+ case 'saswp-seo-press-checkbox':
452
+ saswp_compatibliy_notes(current, id);
453
+ if ($(this).is(':checked')) {
454
+ $("#saswp-seo-press").val(1);
455
+ }else{
456
+ $("#saswp-seo-press").val(0);
457
+ }
458
+ break;
459
+
460
+ case 'saswp-aiosp-checkbox':
461
+ saswp_compatibliy_notes(current, id);
462
+ if ($(this).is(':checked')) {
463
+ $("#saswp-aiosp").val(1);
464
+ }else{
465
+ $("#saswp-aiosp").val(0);
466
+ }
467
+ break;
468
+
469
+ case 'saswp-smart-crawl-checkbox':
470
+ saswp_compatibliy_notes(current, id);
471
+ if ($(this).is(':checked')) {
472
+ $("#saswp-smart-crawl").val(1);
473
+ }else{
474
+ $("#saswp-smart-crawl").val(0);
475
+ }
476
+ break;
477
+
478
+ case 'saswp-squirrly-seo-checkbox':
479
+ saswp_compatibliy_notes(current, id);
480
+ if ($(this).is(':checked')) {
481
+ $("#saswp-squirrly-seo").val(1);
482
+ }else{
483
+ $("#saswp-squirrly-seo").val(0);
484
+ }
485
+ break;
486
+
487
+ case 'saswp-wp-recipe-maker-checkbox':
488
+ saswp_compatibliy_notes(current, id);
489
+ if ($(this).is(':checked')) {
490
+ $("#saswp-wp-recipe-maker").val(1);
491
+ }else{
492
+ $("#saswp-wp-recipe-maker").val(0);
493
+ }
494
+ break;
495
+
496
+ case 'saswp-wpsso-core-checkbox':
497
+ saswp_compatibliy_notes(current, id);
498
+ if ($(this).is(':checked')) {
499
+ $("#saswp-wpsso-core").val(1);
500
+ }else{
501
+ $("#saswp-wpsso-core").val(0);
502
+ }
503
+ break;
504
+
505
+ case 'saswp-for-wordpress-checkbox':
506
+
507
+ if ($(this).is(':checked')) {
508
+ $("#saswp-for-wordpress").val(1);
509
+ }else{
510
+ $("#saswp-for-wordpress").val(0);
511
+ }
512
+ break;
513
+ case 'saswp-facebook-enable-checkbox':
514
+
515
+ if ($(this).is(':checked')) {
516
+ $("#saswp-facebook-enable").val(1);
517
+ $("#sd_facebook").show();
518
+ }else{
519
+ $("#saswp-facebook-enable").val(0);
520
+ $("#sd_facebook").hide();
521
+ }
522
+ break;
523
+ case 'saswp-twitter-enable-checkbox':
524
+
525
+ if ($(this).is(':checked')) {
526
+ $("#saswp-twitter-enable").val(1);
527
+ $("#sd_twitter").show();
528
+ }else{
529
+ $("#saswp-twitter-enable").val(0);
530
+ $("#sd_twitter").hide();
531
+ }
532
+ break;
533
+ case 'saswp-google-plus-enable-checkbox':
534
+
535
+ if ($(this).is(':checked')) {
536
+ $("#saswp-google-plus-enable").val(1);
537
+ $("#sd_google_plus").show();
538
+ }else{
539
+ $("#saswp-google-plus-enable").val(0);
540
+ $("#sd_google_plus").hide();
541
+ }
542
+ break;
543
+ case 'saswp-instagram-enable-checkbox':
544
+
545
+ if ($(this).is(':checked')) {
546
+ $("#saswp-instagram-enable").val(1);
547
+ $("#sd_instagram").show();
548
+ }else{
549
+ $("#saswp-instagram-enable").val(0);
550
+ $("#sd_instagram").hide();
551
+ }
552
+ break;
553
+ case 'saswp-youtube-enable-checkbox':
554
+
555
+ if ($(this).is(':checked')) {
556
+ $("#sd_youtube").show();
557
+ $("#saswp-youtube-enable").val(1);
558
+ }else{
559
+ $("#saswp-youtube-enable").val(0);
560
+ $("#sd_youtube").hide();
561
+ }
562
+ break;
563
+ case 'saswp-linkedin-enable-checkbox':
564
+
565
+ if ($(this).is(':checked')) {
566
+ $("#saswp-linkedin-enable").val(1);
567
+ $("#sd_linkedin").show();
568
+ }else{
569
+ $("#saswp-linkedin-enable").val(0);
570
+ $("#sd_linkedin").hide();
571
+ }
572
+ break;
573
+ case 'saswp-pinterest-enable-checkbox':
574
+
575
+ if ($(this).is(':checked')) {
576
+ $("#saswp-pinterest-enable").val(1);
577
+ $("#sd_pinterest").show();
578
+ }else{
579
+ $("#saswp-pinterest-enable").val(0);
580
+ $("#sd_pinterest").hide();
581
+ }
582
+ break;
583
+ case 'saswp-soundcloud-enable-checkbox':
584
+
585
+ if ($(this).is(':checked')) {
586
+ $("#saswp-soundcloud-enable").val(1);
587
+ $("#sd_soundcloud").show();
588
+ }else{
589
+ $("#saswp-soundcloud-enable").val(0);
590
+ $("#sd_soundcloud").hide();
591
+ }
592
+ break;
593
+ case 'saswp-tumblr-enable-checkbox':
594
+
595
+ if ($(this).is(':checked')) {
596
+ $("#saswp-tumblr-enable").val(1);
597
+ $("#sd_tumblr").show();
598
+ }else{
599
+ $("#saswp-tumblr-enable").val(0);
600
+ $("#sd_tumblr").hide();
601
+ }
602
+ break;
603
+ case 'saswp-for-amp-checkbox':
604
+
605
+ if ($(this).is(':checked')) {
606
+ $("#saswp-for-amp").val(1);
607
+ }else{
608
+ $("#saswp-for-amp").val(0);
609
+ }
610
+ break;
611
+ case 'saswp_kb_contact_1_checkbox':
612
+
613
+ if ($(this).is(':checked')) {
614
+ $("#saswp_kb_contact_1").val(1);
615
+ $("#saswp_kb_telephone, #saswp_contact_type").parent().parent('li').removeClass("saswp-display-none");
616
+ }else{
617
+ $("#saswp_kb_contact_1").val(0);
618
+ $("#saswp_kb_telephone, #saswp_contact_type").parent().parent('li').addClass("saswp-display-none");
619
+ }
620
+ break;
621
+ case 'saswp-logo-dimensions-check':
622
+
623
+ if ($(this).is(':checked')) {
624
+ $("#saswp-logo-dimensions").val(1);
625
+ $("#saswp-logo-width, #saswp-logo-height").parent().parent('li').show();
626
+ }else{
627
+ $("#saswp-logo-dimensions").val(0);
628
+ $("#saswp-logo-width, #saswp-logo-height").parent().parent('li').hide();
629
+ }
630
+ break;
631
+ case 'saswp_archive_schema_checkbox':
632
+
633
+ if ($(this).is(':checked')) {
634
+ $("#saswp_archive_schema").val(1);
635
+ $(".saswp_archive_schema_type_class").parent().parent().show();
636
+ }else{
637
+ $("#saswp_archive_schema").val(0);
638
+ $(".saswp_archive_schema_type_class").parent().parent().hide();
639
+ }
640
+ break;
641
+
642
+ case 'saswp_website_schema_checkbox':
643
+
644
+ if ($(this).is(':checked')) {
645
+ $("#saswp_website_schema").val(1);
646
+ $("#saswp_search_box_schema").parent().parent().show();
647
+ }else{
648
+ $("#saswp_website_schema").val(0);
649
+ $("#saswp_search_box_schema").parent().parent().hide();
650
+ }
651
+ break;
652
+
653
+ case 'saswp_search_box_schema_checkbox':
654
+
655
+ if ($(this).is(':checked')) {
656
+ $("#saswp_search_box_schema").val(1);
657
+ }else{
658
+ $("#saswp_search_box_schema").val(0);
659
+ }
660
+ break;
661
+
662
+ case 'saswp_breadcrumb_schema_checkbox':
663
+
664
+ if ($(this).is(':checked')) {
665
+ $("#saswp_breadcrumb_schema").val(1);
666
+ }else{
667
+ $("#saswp_breadcrumb_schema").val(0);
668
+ }
669
+ break;
670
+
671
+ case 'saswp_comments_schema_checkbox':
672
+
673
+ if ($(this).is(':checked')) {
674
+ $("#saswp_comments_schema").val(1);
675
+ }else{
676
+ $("#saswp_comments_schema").val(0);
677
+ }
678
+ break;
679
+
680
+ case 'saswp-compativility-checkbox':
681
+
682
+ if ($(this).is(':checked')) {
683
+ $("#saswp-flexmlx-compativility").val(1);
684
+ }else{
685
+ $("#saswp-flexmlx-compativility").val(0);
686
+ }
687
+ break;
688
+
689
+ case 'saswp-review-module-checkbox':
690
+
691
+ if ($(this).is(':checked')) {
692
+ $("#saswp-review-module").val(1);
693
+ }else{
694
+ $("#saswp-review-module").val(0);
695
+ }
696
+ break;
697
+
698
+ case 'saswp-kk-star-raring-checkbox':
699
+
700
+ saswp_compatibliy_notes(current, id);
701
+ if ($(this).is(':checked')) {
702
+ $("#saswp-kk-star-raring").val(1);
703
+ }else{
704
+ $("#saswp-kk-star-raring").val(0);
705
+ }
706
+ break;
707
+ case 'saswp-woocommerce-checkbox':
708
+ saswp_compatibliy_notes(current, id);
709
+ if ($(this).is(':checked')) {
710
+ $("#saswp-woocommerce").val(1);
711
+ }else{
712
+ $("#saswp-woocommerce").val(0);
713
+ }
714
+ break;
715
+
716
+ case 'saswp-extra-checkbox':
717
+ saswp_compatibliy_notes(current, id);
718
+ if ($(this).is(':checked')) {
719
+ $("#saswp-extra").val(1);
720
+ }else{
721
+ $("#saswp-extra").val(0);
722
+ }
723
+ break;
724
+
725
+ case 'saswp-dw-question-answer-checkbox':
726
+ saswp_compatibliy_notes(current, id);
727
+ if ($(this).is(':checked')) {
728
+ $("#saswp-dw-question-answer").val(1);
729
+ }else{
730
+ $("#saswp-dw-question-answer").val(0);
731
+ }
732
+ break;
733
+
734
+ case 'saswp-wp-job-manager-checkbox':
735
+ saswp_compatibliy_notes(current, id);
736
+ if ($(this).is(':checked')) {
737
+ $("#saswp-wp-job-manager").val(1);
738
+ }else{
739
+ $("#saswp-wp-job-manager").val(0);
740
+ }
741
+ break;
742
+
743
+ case 'saswp-yoast-checkbox':
744
+ saswp_compatibliy_notes(current, id);
745
+ if ($(this).is(':checked')) {
746
+ $("#saswp-yoast").val(1);
747
+ }else{
748
+ $("#saswp-yoast").val(0);
749
+ }
750
+ break;
751
+
752
+ case 'saswp-rankmath-checkbox':
753
+ saswp_compatibliy_notes(current, id);
754
+ if ($(this).is(':checked')) {
755
+ $("#saswp-rankmath").val(1);
756
+ }else{
757
+ $("#saswp-rankmath").val(0);
758
+ }
759
+ break;
760
+
761
+ case 'saswp-tagyeem-checkbox':
762
+ saswp_compatibliy_notes(current, id);
763
+ if ($(this).is(':checked')) {
764
+ $("#saswp-tagyeem").val(1);
765
+ }else{
766
+ $("#saswp-tagyeem").val(0);
767
+ }
768
+ break;
769
+
770
+ case 'saswp-the-events-calendar-checkbox':
771
+ saswp_compatibliy_notes(current, id);
772
+ if ($(this).is(':checked')) {
773
+ $("#saswp-the-events-calendar").val(1);
774
+ }else{
775
+ $("#saswp-the-events-calendar").val(0);
776
+ }
777
+ break;
778
+
779
+
780
+ case 'saswp-woocommerce-booking-checkbox':
781
+ saswp_compatibliy_notes(current, id);
782
+ if ($(this).is(':checked')) {
783
+ $("#saswp-woocommerce-booking").val(1);
784
+ $("#saswp-woocommerce-booking-main").val(1);
785
+ }else{
786
+ $("#saswp-woocommerce-booking").val(0);
787
+ $("#saswp-woocommerce-booking-main").val(0);
788
+ }
789
+ break;
790
+
791
+ case 'saswp-woocommerce-booking-main-checkbox':
792
+ saswp_compatibliy_notes(current, id);
793
+ if ($(this).is(':checked')) {
794
+ $("#saswp-woocommerce-booking-main").val(1);
795
+ $("#saswp-woocommerce-booking").val(1);
796
+ }else{
797
+ $("#saswp-woocommerce-booking-main").val(0);
798
+ $("#saswp-woocommerce-booking").val(0);
799
+ }
800
+ break;
801
+
802
+ case 'saswp-woocommerce-membership-checkbox':
803
+ saswp_compatibliy_notes(current, id);
804
+ if ($(this).is(':checked')) {
805
+ $("#saswp-woocommerce-membership").val(1);
806
+ }else{
807
+ $("#saswp-woocommerce-membership").val(0);
808
+ }
809
+ break;
810
+
811
+ case 'saswp-defragment-checkbox':
812
+
813
+ if ($(this).is(':checked')) {
814
+ $("#saswp-defragment").val(1);
815
+ }else{
816
+ $("#saswp-defragment").val(0);
817
+ }
818
+ break;
819
+
820
+ case 'saswp-cooked-checkbox':
821
+ saswp_compatibliy_notes(current, id);
822
+ if ($(this).is(':checked')) {
823
+ $("#saswp-cooked").val(1);
824
+ }else{
825
+ $("#saswp-cooked").val(0);
826
+ }
827
+ break;
828
+
829
+ case 'saswp-flexmlx-compativility-checkbox':
830
+ saswp_compatibliy_notes(current, id);
831
+ if ($(this).is(':checked')) {
832
+ $("#saswp-flexmlx-compativility").val(1);
833
+ }else{
834
+ $("#saswp-flexmlx-compativility").val(0);
835
+ }
836
+ break;
837
+
838
+ case 'saswp-shopper-approved-review-checkbox':
839
+ saswp_compatibliy_notes(current, id);
840
+ if ($(this).is(':checked')) {
841
+ $("#saswp-shopper-approved-review").val(1);
842
+ $(".saswp-s-reviews-settings-table").parent().parent().parent().show();
843
+ }else{
844
+ $("#saswp-shopper-approved-review").val(0);
845
+ $(".saswp-s-reviews-settings-table").parent().parent().parent().hide();
846
+ }
847
+ break;
848
+
849
+ case 'saswp-google-review-checkbox':
850
+
851
+ if ($(this).is(':checked')) {
852
+
853
+ $("#saswp-google-review").val(1);
854
+
855
+ if($("#saswp-google-rv-free-checkbox").length){
856
+
857
+ $("#saswp-google-review-free").parent().parent().show();
858
+
859
+ if($("#saswp-google-rv-free-checkbox").is(":checked")){
860
+ $("#saswp_google_place_api_key").parent().parent().show();
861
+ }else{
862
+ $("#saswp_google_place_api_key").parent().parent().hide();
863
+ }
864
+ }else{
865
+ $("#saswp_google_place_api_key").parent().parent().show();
866
+ }
867
+ $(".saswp-g-reviews-settings-table").parent().parent().parent().show();
868
+
869
+ }else{
870
+
871
+ $("#saswp-google-review").val(0);
872
+ $("#saswp_google_place_api_key").parent().parent().hide();
873
+ $(".saswp-g-reviews-settings-table").parent().parent().parent().hide();
874
+
875
+ if($("#saswp-google-rv-free-checkbox").length){
876
+ $("#saswp-google-review-free").parent().parent().hide();
877
+
878
+ }
879
+
880
+
881
+
882
+
883
+
884
+ }
885
+ break;
886
+
887
+ case 'saswp-google-rv-free-checkbox':
888
+
889
+ if($("#saswp-google-review-checkbox").is(":checked")){
890
+ if ($(this).is(':checked')) {
891
+ $("#saswp-google-review-free").val(1);
892
+ $("#saswp_google_place_api_key").parent().parent().show();
893
+ }else{
894
+ $("#saswp-google-review-free").val(0);
895
+ $("#saswp_google_place_api_key").parent().parent().hide();
896
+ }
897
+
898
+ }else{
899
+ $("#saswp-google-review-free").val(0);
900
+ $("#saswp_google_place_api_key").parent().parent().hide();
901
+ }
902
+
903
+
904
+ break;
905
+
906
+
907
+ case 'saswp-markup-footer-checkbox':
908
+
909
+ if ($(this).is(':checked')) {
910
+ $("#saswp-markup-footer").val(1);
911
+ }else{
912
+ $("#saswp-markup-footer").val(0);
913
+ }
914
+ break;
915
+
916
+ case 'saswp-pretty-print-checkbox':
917
+
918
+ if ($(this).is(':checked')) {
919
+ $("#saswp-pretty-print").val(1);
920
+ }else{
921
+ $("#saswp-pretty-print").val(0);
922
+ }
923
+ break;
924
+
925
+ case 'saswp-wppostratings-raring-checkbox':
926
+ saswp_compatibliy_notes(current, id);
927
+ if ($(this).is(':checked')) {
928
+ $("#saswp-wppostratings-raring").val(1);
929
+ }else{
930
+ $("#saswp-wppostratings-raring").val(0);
931
+ }
932
+ break;
933
+
934
+ case 'saswp-bbpress-checkbox':
935
+ saswp_compatibliy_notes(current, id);
936
+ if ($(this).is(':checked')) {
937
+ $("#saswp-bbpress").val(1);
938
+ }else{
939
+ $("#saswp-bbpress").val(0);
940
+ }
941
+ break;
942
+
943
+ case 'saswp-microdata-cleanup-checkbox':
944
+
945
+ if ($(this).is(':checked')) {
946
+ $("#saswp-microdata-cleanup").val(1);
947
+ }else{
948
+ $("#saswp-microdata-cleanup").val(0);
949
+ }
950
+ break;
951
+
952
+
953
+ default:
954
+ break;
955
+ }
956
+
957
+ }).change();
958
+
959
+ $("#saswp_kb_type").change(function(){
960
+
961
+ var datatype = $(this).val();
962
+
963
+ $(".saswp_org_fields, .saswp_person_fields").parent().parent().addClass('saswp_hide');
964
+ $(".saswp_kg_logo").parent().parent().parent().addClass('saswp_hide');
965
+ $("#sd-person-image").parent().parent().parent().addClass('saswp_hide');
966
+
967
+
968
+ if(datatype == 'Organization'){
969
+
970
+ $(".saswp_org_fields").parent().parent().removeClass('saswp_hide');
971
+ $(".saswp_person_fields").parent().parent().addClass('saswp_hide');
972
+ $(".saswp_kg_logo").parent().parent().parent().removeClass('saswp_hide');
973
+ $("#sd-person-image").parent().parent().parent().addClass('saswp_hide');
974
+ }
975
+ if(datatype == 'Person'){
976
+
977
+ $(".saswp_org_fields").parent().parent().addClass('saswp_hide');
978
+ $(".saswp_person_fields").parent().parent().removeClass('saswp_hide');
979
+ $(".saswp_kg_logo").parent().parent().parent().removeClass('saswp_hide');
980
+ $("#sd-person-image").parent().parent().parent().removeClass('saswp_hide');
981
+ }
982
+
983
+ }).change();
984
+
985
+ $(document).on("click", "input[data-id=media]" ,function(e) { // Application Icon upload
986
+ e.preventDefault();
987
+ var current = $(this);
988
+ var button = current;
989
+ var id = button.attr('id').replace('_button', '');
990
+ var saswpMediaUploader = wp.media({
991
+ title: "Application Icon",
992
+ button: {
993
+ text: "Select Icon"
994
+ },
995
+ multiple: false, // Set this to true to allow multiple files to be selected
996
+ library:{type : 'image'}
997
+ })
998
+ .on("select", function() {
999
+ var attachment = saswpMediaUploader.state().get('selection').first().toJSON();
1000
+
1001
+ $("#"+id).val(attachment.url);
1002
+ $("input[data-id='"+id+"_id']").val(attachment.id);
1003
+ $("input[data-id='"+id+"_height']").val(attachment.height);
1004
+ $("input[data-id='"+id+"_width']").val(attachment.width);
1005
+ $("input[data-id='"+id+"_thumbnail']").val(attachment.url);
1006
+
1007
+ if(current.attr('id') === 'sd_default_image_button'){
1008
+
1009
+ $("#sd_default_image_width").val(attachment.width);
1010
+ $("#sd_default_image_height").val(attachment.height);
1011
+
1012
+ }
1013
+ var smaller_img_notice = '';
1014
+ if("saswp_image_div_"+id == 'saswp_image_div_sd_default_image' && attachment.height < 1200){
1015
+ smaller_img_notice = '<p class="saswp_warning">Image size is smaller than recommended size</p>';
1016
+ }
1017
+
1018
+ $(".saswp_image_div_"+id).html('<div class="saswp_image_thumbnail"><img class="saswp_image_prev" src="'+attachment.url+'"/><a data-id="'+id+'" href="#" class="saswp_prev_close">X</a></div>'+smaller_img_notice);
1019
+
1020
+ })
1021
+ .open();
1022
+ });
1023
+
1024
+ $(document).on("click", ".saswp_prev_close", function(e){
1025
+ e.preventDefault();
1026
+
1027
+ var id = $(this).attr('data-id');
1028
+ console.log(id);
1029
+ $(this).parent().remove();
1030
+ $("#"+id).val('');
1031
+ $("input[data-id='"+id+"_id']").val('');
1032
+ $("input[data-id='"+id+"_height']").val('');
1033
+ $("input[data-id='"+id+"_width']").val('');
1034
+ $("input[data-id='"+id+"_thumbnail']").val('');
1035
+
1036
+ if(id === 'sd_default_image'){
1037
+
1038
+ $("#sd_default_image_width").val('');
1039
+ $("#sd_default_image_height").val('');
1040
+
1041
+ }
1042
+
1043
+
1044
+ });
1045
+
1046
+ //Settings page jquery ends here
1047
+
1048
+
1049
+ $(document).on("change",".saswp-schema-type-toggle", function(e){
1050
+ var schema_id = $(this).attr("data-schema-id");
1051
+ var post_id = $(this).attr("data-post-id");
1052
+ if($(this).is(':checked')){
1053
+ var status = 1;
1054
+ }else{
1055
+ var status = 0;
1056
+ }
1057
+ $.ajax({
1058
+ type: "POST",
1059
+ url:ajaxurl,
1060
+ dataType: "json",
1061
+ data:{action:"saswp_enable_disable_schema_on_post",status:status, schema_id:schema_id, post_id:post_id, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1062
+ success:function(response){
1063
+ },
1064
+ error: function(response){
1065
+ console.log(response);
1066
+ }
1067
+ });
1068
+
1069
+ });
1070
+
1071
+
1072
+ $(document).on("click",".saswp-reset-data", function(e){
1073
+ e.preventDefault();
1074
+
1075
+ var saswp_confirm = confirm("Are you sure?");
1076
+
1077
+ if(saswp_confirm == true){
1078
+
1079
+ $.ajax({
1080
+ type: "POST",
1081
+ url:ajaxurl,
1082
+ dataType: "json",
1083
+ data:{action:"saswp_reset_all_settings", saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1084
+ success:function(response){
1085
+ setTimeout(function(){ location.reload(); }, 1000);
1086
+ },
1087
+ error: function(response){
1088
+ console.log(response);
1089
+ }
1090
+ });
1091
+
1092
+ }
1093
+
1094
+
1095
+ });
1096
+
1097
+ //Licensing jquery starts here
1098
+ $(document).on("click",".saswp_license_activation", function(e){
1099
+ e.preventDefault();
1100
+ var current = $(this);
1101
+ current.addClass('updating-message');
1102
+ var license_status = $(this).attr('license-status');
1103
+ var add_on = $(this).attr('add-on');
1104
+ var license_key = $("#"+add_on+"_addon_license_key").val();
1105
+
1106
+ if(license_status && add_on && license_key){
1107
+
1108
+ $.ajax({
1109
+ type: "POST",
1110
+ url:ajaxurl,
1111
+ dataType: "json",
1112
+ data:{action:"saswp_license_status_check",license_key:license_key,license_status:license_status, add_on:add_on, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1113
+ success:function(response){
1114
+
1115
+ $("#"+add_on+"_addon_license_key_status").val(response['status']);
1116
+
1117
+ if(response['status'] =='active'){
1118
+ $(".saswp-"+add_on+"-dashicons").addClass('dashicons-yes');
1119
+ $(".saswp-"+add_on+"-dashicons").removeClass('dashicons-no-alt');
1120
+ $(".saswp-"+add_on+"-dashicons").css("color", "green");
1121
+
1122
+ $(".saswp_license_activation[add-on='" + add_on + "']").attr("license-status", "inactive");
1123
+ $(".saswp_license_activation[add-on='" + add_on + "']").text("Deactivate");
1124
+
1125
+ $(".saswp_license_status_msg[add-on='" + add_on + "']").text('Activated');
1126
+
1127
+ $(".saswp_license_status_msg[add-on='" + add_on + "']").css("color", "green");
1128
+ $(".saswp_license_status_msg[add-on='" + add_on + "']").text(response['message']);
1129
+
1130
+ }else{
1131
+
1132
+ $(".saswp-"+add_on+"-dashicons").addClass('dashicons-no-alt');
1133
+ $(".saswp-"+add_on+"-dashicons").removeClass('dashicons-yes');
1134
+ $(".saswp-"+add_on+"-dashicons").css("color", "red");
1135
+
1136
+ $(".saswp_license_activation[add-on='" + add_on + "']").attr("license-status", "active");
1137
+ $(".saswp_license_activation[add-on='" + add_on + "']").text("Activate");
1138
+
1139
+ $(".saswp_license_status_msg[add-on='" + add_on + "']").css("color", "red");
1140
+ $(".saswp_license_status_msg[add-on='" + add_on + "']").text(response['message']);
1141
+ }
1142
+ current.removeClass('updating-message');
1143
+ },
1144
+ error: function(response){
1145
+ console.log(response);
1146
+ }
1147
+ });
1148
+
1149
+ }else{
1150
+ alert('Please enter value license key');
1151
+ current.removeClass('updating-message');
1152
+ }
1153
+
1154
+ });
1155
+ //Licensing jquery ends here
1156
+ //query form send starts here
1157
+
1158
+ $(".saswp-send-query").on("click", function(e){
1159
+ e.preventDefault();
1160
+ var message = $("#saswp_query_message").val();
1161
+ if($.trim(message) !=''){
1162
+ $.ajax({
1163
+ type: "POST",
1164
+ url:ajaxurl,
1165
+ dataType: "json",
1166
+ data:{action:"saswp_send_query_message", message:message, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1167
+ success:function(response){
1168
+ if(response['status'] =='t'){
1169
+ $(".saswp-query-success").show();
1170
+ $(".saswp-query-error").hide();
1171
+ }else{
1172
+ console.log('dd');
1173
+ $(".saswp-query-success").hide();
1174
+ $(".saswp-query-error").show();
1175
+ }
1176
+ },
1177
+ error: function(response){
1178
+ console.log(response);
1179
+ }
1180
+ });
1181
+ }else{
1182
+ alert('Please enter the message');
1183
+ }
1184
+
1185
+ });
1186
+
1187
+ //Importer from schema plugin starts here
1188
+
1189
+ $(".saswp-import-plugins").on("click", function(e){
1190
+ e.preventDefault();
1191
+ var current_selection = $(this);
1192
+ current_selection.addClass('updating-message');
1193
+ var plugin_name = $(this).attr('data-id');
1194
+ $.get(ajaxurl,
1195
+ { action:"saswp_import_plugin_data", plugin_name:plugin_name, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1196
+ function(response){
1197
+ if(response['status'] =='t'){
1198
+ $(current_selection).parent().find(".saswp-imported-message").text(response['message']);
1199
+ $(current_selection).parent().find(".saswp-imported-message").removeClass('saswp-error');
1200
+ setTimeout(function(){ location.reload(); }, 2000);
1201
+ }else{
1202
+ $(current_selection).parent().find(".saswp-imported-message").addClass('saswp-error');
1203
+ $(current_selection).parent().find(".saswp-imported-message").text(response['message']);
1204
+ }
1205
+ current_selection.removeClass('updating-message');
1206
+ },'json');
1207
+ });
1208
+
1209
+
1210
+ $(".saswp-feedback-no-thanks").on("click", function(e){
1211
+ e.preventDefault();
1212
+ $.get(ajaxurl,
1213
+ { action:"saswp_feeback_no_thanks"},
1214
+ function(response){
1215
+ if(response['status'] =='t'){
1216
+ $(".saswp-feedback-notice").hide();
1217
+ }
1218
+ },'json');
1219
+ });
1220
+
1221
+ $(".saswp-feedback-remindme").on("click", function(e){
1222
+ e.preventDefault();
1223
+ $.get(ajaxurl,
1224
+ { action:"saswp_feeback_remindme"},
1225
+ function(response){
1226
+ if(response['status'] =='t'){
1227
+ $(".saswp-feedback-notice").hide();
1228
+ }
1229
+ },'json');
1230
+ });
1231
+
1232
+ $(document).on("change",'.saswp-local-business-type-select', function(e){
1233
+ e.preventDefault();
1234
+ var current = $(this);
1235
+ var business_type = $(this).val();
1236
+ $.get(ajaxurl,
1237
+ { action:"saswp_get_sub_business_ajax", business_type:business_type, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1238
+ function(response){
1239
+
1240
+ if(response['status'] =='t'){
1241
+ $(".saswp-local-business-name-select").parents('tr').remove();
1242
+ var schema_id = current.parents('.saswp-post-specific-wrapper').attr('data-id');
1243
+ var html ='<tr><th><label for="saswp_business_name_'+schema_id+'">Sub Business Type</label></th>';
1244
+ html +='<td><select class="saswp-local-business-name-select" id="saswp_business_name_'+schema_id+'" name="saswp_business_name_'+schema_id+'">';
1245
+ $.each(response['result'], function(index, element){
1246
+ html +='<option value="'+index+'">'+element+'</option>';
1247
+ });
1248
+ html +='</select></td>';
1249
+ html +='</tr>';
1250
+ current.parents('.form-table tr:first').after(html);
1251
+ }else{
1252
+ $(".saswp-local-business-name-select").parents('tr').remove();
1253
+ }
1254
+ },'json');
1255
+ });
1256
+
1257
+
1258
+ function saswp_item_reviewed_call(){
1259
+
1260
+ $(".saswp-item-reviewed").change(function(e){
1261
+ e.preventDefault();
1262
+ var schema_type ="";
1263
+
1264
+ if($('select#schema_type option:selected').val()){
1265
+ schema_type = $('select#schema_type option:selected').val();
1266
+ }
1267
+ if($(".saswp-tab-links.selected").attr('saswp-schema-type')){
1268
+ schema_type = $(".saswp-tab-links.selected").attr('saswp-schema-type');
1269
+ }
1270
+
1271
+ if(schema_type === 'Review'){
1272
+
1273
+ var current = $(this);
1274
+ var item = $(this).val();
1275
+ var post_id = saswp_localize_data.post_id;
1276
+ var schema_id = $(current).attr('data-id');
1277
+ var post_specific = $(current).attr('post-specific');
1278
+ $.get(ajaxurl,
1279
+ { action:"saswp_get_item_reviewed_fields",schema_id:schema_id, post_specific:post_specific ,item:item, post_id:post_id, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1280
+ function(response){
1281
+
1282
+ $(current).parent().parent().nextAll().remove(".saswp-review-tr");
1283
+ $(current).parent().parent().after(response);
1284
+
1285
+ });
1286
+
1287
+ }
1288
+
1289
+
1290
+ }).change();
1291
+
1292
+ }
1293
+ saswp_item_reviewed_call();
1294
+
1295
+ function saswpAddTimepicker(){
1296
+ $('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
1297
+ }
1298
+ $('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
1299
+
1300
+ $(document).on("click",".saswp-add-custom-schema", function(e){
1301
+
1302
+ e.preventDefault();
1303
+
1304
+ $(".saswp-add-custom-schema-field").removeClass('saswp_hide');
1305
+ $(this).hide();
1306
+
1307
+ });
1308
+
1309
+ $(document).on("click", ".saswp-delete-custom-schema", function(e){
1310
+
1311
+ e.preventDefault();
1312
+
1313
+ $("#saswp_custom_schema_field").val('');
1314
+ $(".saswp-add-custom-schema-field").addClass('saswp_hide');
1315
+ $(".saswp-add-custom-schema").show();
1316
+
1317
+ });
1318
+
1319
+ $(".saswp-modify_schema_post_enable").on("click", function(e){
1320
+ var current = $(this);
1321
+ current.addClass('updating-message');
1322
+ e.preventDefault();
1323
+ $.get(ajaxurl,
1324
+ { action:"saswp_modify_schema_post_enable", post_id: saswp_localize_data.post_id,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1325
+ function(response){
1326
+ current.remove();
1327
+ $(".saswp-add-custom-schema-div").remove();
1328
+ $("#post_specific .inside").append(response);
1329
+ current.removeClass('updating-message');
1330
+ saswpAddTimepicker();
1331
+ saswp_schema_datepicker();
1332
+ saswp_enable_rating_review();
1333
+ saswp_item_reviewed_call();
1334
+ });
1335
+
1336
+ });
1337
+ saswp_schema_datepicker();
1338
+
1339
+ saswp_reviews_datepicker();
1340
+ function saswp_reviews_datepicker(){
1341
+
1342
+ $('.saswp-reviews-datepicker-picker').datepicker({
1343
+ dateFormat: "yy-mm-dd"
1344
+ });
1345
+ }
1346
+
1347
+ //Review js starts here
1348
+
1349
+ $(document).on("click", ".saswp-add-more-item",function(e){
1350
+ e.preventDefault();
1351
+ var rows = $('.saswp-review-item-list-table tr').length;
1352
+ console.log(rows);
1353
+ var html = '<tr class="saswp-review-item-tr">';
1354
+ html += '<td>Review Item Feature</td>';
1355
+ html += '<td><input type="text" name="saswp-review-item-feature[]"></td>';
1356
+ html += '<td>Rating</td>';
1357
+ html += '<td><input step="0.1" min="0" max="5" type="number" name="saswp-review-item-star-rating[]"></td>';
1358
+ html += '<td><a type="button" class="saswp-remove-review-item button">x</a></td>';
1359
+ html += '</tr>';
1360
+ $(".saswp-review-item-list-table").append(html);
1361
+
1362
+ });
1363
+
1364
+ $(document).on("click", ".saswp-remove-review-item", function(e){
1365
+ e.preventDefault();
1366
+ $(this).parent().parent('tr').remove();
1367
+ });
1368
+
1369
+ $(document).on("focusout", ".saswp-review-item-tr input[type=number]", function(e){
1370
+ e.preventDefault();
1371
+ var total_rating = 0;
1372
+ var element_count = $(".saswp-review-item-tr input[type=number]").length;
1373
+ $(".saswp-review-item-tr input[type=number]").each(function(index, element){
1374
+ if($(element).val() ==''){
1375
+ total_rating += parseFloat(0);
1376
+ }else{
1377
+ total_rating += parseFloat($(element).val());
1378
+ }
1379
+
1380
+ });
1381
+ var over_all_rating = total_rating / element_count;
1382
+ $("#saswp-review-item-over-all").val(over_all_rating);
1383
+ });
1384
+
1385
+ $("#saswp-review-location").change(function(){
1386
+ var location = $(this).val();
1387
+ $(".saswp-review-shortcode").addClass('saswp_hide');
1388
+ if(location == 3){
1389
+ $(".saswp-review-shortcode").removeClass('saswp_hide');
1390
+ }
1391
+ }).change();
1392
+
1393
+ $("#saswp-review-item-enable").change(function(){
1394
+ if ($(this).is(':checked')) {
1395
+ $(".saswp-review-fields").show();
1396
+ }else{
1397
+ $(".saswp-review-fields").hide();
1398
+ }
1399
+ }).change();
1400
+
1401
+ $(document).on("click", ".saswp-restore-post-schema", function(e){
1402
+ e.preventDefault();
1403
+ var current = $(this);
1404
+ current.addClass('updating-message');
1405
+
1406
+ if($(".saswp-post-specific-schema-ids").val()){
1407
+ var schema_ids = JSON.parse($(".saswp-post-specific-schema-ids").val());
1408
+ }
1409
+
1410
+ $.post(ajaxurl,
1411
+ { action:"saswp_restore_schema", schema_ids:schema_ids,post_id: saswp_localize_data.post_id, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1412
+ function(response){
1413
+ if(response['status'] =='t'){
1414
+ setTimeout(function(){ location.reload(); }, 1000);
1415
+ }else{
1416
+ alert(response['msg']);
1417
+ setTimeout(function(){ location.reload(); }, 1000);
1418
+ }
1419
+ current.removeClass('updating-message');
1420
+ },'json');
1421
+ });
1422
+
1423
+ //Review js ends here
1424
+
1425
+ $(document).on("click","div.saswp-tab ul.saswp-tab-nav a", function(e){
1426
+ e.preventDefault();
1427
+ var attr = $(this).attr('data-id');
1428
+ $(".saswp-post-specific-wrapper").hide();
1429
+ $("#"+attr).show();
1430
+ $('div.saswp-tab ul.saswp-tab-nav a').removeClass('selected');
1431
+ $('div.saswp-tab ul.saswp-tab-nav li').removeClass('selected');
1432
+ $(this).addClass('selected');
1433
+ $(this).parent().addClass('selected');
1434
+ saswp_enable_rating_review();
1435
+ });
1436
+
1437
+
1438
+ $('#saswp-global-tabs a:first').addClass('saswp-global-selected');
1439
+ $('.saswp-global-container').hide();
1440
+
1441
+ var hash = window.location.hash;
1442
+
1443
+ if(hash == '#saswp-default-container'){
1444
+ $('.saswp-global-container:eq(2)').show();
1445
+ }else{
1446
+ $('.saswp-global-container:first').show();
1447
+ }
1448
+
1449
+
1450
+
1451
+ $('#saswp-global-tabs a').click(function(){
1452
+ var t = $(this).attr('data-id');
1453
+
1454
+ if(!$(this).hasClass('saswp-global-selected')){
1455
+ $('#saswp-global-tabs a').removeClass('saswp-global-selected');
1456
+ $(this).addClass('saswp-global-selected');
1457
+
1458
+ $('.saswp-global-container').hide();
1459
+ $('#'+t).show();
1460
+ }
1461
+ });
1462
+
1463
+
1464
+ $('#saswp-tools-tabs a:first').addClass('saswp-global-selected');
1465
+ $('.saswp-tools-container').hide();
1466
+ $('.saswp-tools-container:first').show();
1467
+
1468
+ $('#saswp-tools-tabs a').click(function(){
1469
+ var t = $(this).attr('data-id');
1470
+
1471
+ if(!$(this).hasClass('saswp-global-selected')){
1472
+ $('#saswp-tools-tabs a').removeClass('saswp-global-selected');
1473
+ $(this).addClass('saswp-global-selected');
1474
+
1475
+ $('.saswp-tools-container').hide();
1476
+ $('#'+t).show();
1477
+ }
1478
+ });
1479
+
1480
+
1481
+ $('#saswp-review-tabs a:first').addClass('saswp-global-selected');
1482
+ $('.saswp-review-container').hide();
1483
+ $('.saswp-review-container:first').show();
1484
+
1485
+ $('#saswp-review-tabs a').click(function(){
1486
+ var t = $(this).attr('data-id');
1487
+
1488
+ if(!$(this).hasClass('saswp-global-selected')){
1489
+ $('#saswp-review-tabs a').removeClass('saswp-global-selected');
1490
+ $(this).addClass('saswp-global-selected');
1491
+
1492
+ $('.saswp-review-container').hide();
1493
+ $('#'+t).show();
1494
+ }
1495
+ });
1496
+
1497
+
1498
+ //Importer from schema plugin ends here
1499
+
1500
+ //custom fields modify schema starts here
1501
+
1502
+ //Changing the url of add new schema type
1503
+ $('a[href="'+saswp_localize_data.new_url_selector+'"]').attr( 'href', saswp_localize_data.new_url_href);
1504
+
1505
+
1506
+ $("#saswp_enable_custom_field").change(function(){
1507
+ if ($(this).is(':checked')) {
1508
+ $(".saswp-custom-fields-div").show();
1509
+ }else{
1510
+ $(".saswp-custom-fields-div").hide();
1511
+ }
1512
+ });
1513
+
1514
+ $(document).on('change','.saswp-custom-fields-name',function(){
1515
+
1516
+ var type = 'text';
1517
+ var fields_name = $(this).val();
1518
+ var str2 = "image";
1519
+ if(fields_name.indexOf(str2) != -1){
1520
+ type = 'image';
1521
+ }
1522
+
1523
+ var id = $(this).parent().parent('tr').find("td:eq(1)");
1524
+ saswp_get_meta_list(type, null, id, fields_name);
1525
+ $(this).parent().parent('tr').find("td:gt(1)").remove();
1526
+ });
1527
+
1528
+ $(document).on("click", '.saswp-skip-button', function(e){
1529
+ e.preventDefault();
1530
+ $(this).parent().parent().hide();
1531
+
1532
+ $.post(ajaxurl,
1533
+ { action:"saswp_skip_wizard", saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1534
+ function(response){
1535
+
1536
+ },'json');
1537
+
1538
+ });
1539
+
1540
+ $(document).on("click", ".saswp_add_schema_fields_on_fly", function(e){
1541
+ e.preventDefault();
1542
+
1543
+ var schema_id = $(this).attr('data-id');
1544
+ var fields_type = $(this).attr('fields_type');
1545
+ var div_type = $(this).attr('div_type');
1546
+
1547
+ var count = $(".saswp-"+div_type+"-table-div").length;
1548
+ var index = $( ".saswp-"+div_type+"-table-div:nth-child("+count+")" ).attr('data-id');
1549
+ index = ++index;
1550
+
1551
+ if(!index){
1552
+ index = 0;
1553
+ }
1554
+
1555
+ saswp_get_post_specific_schema_fields(index, fields_type, div_type, schema_id, fields_type+'_');
1556
+
1557
+ });
1558
+
1559
+ $(document).on("click", ".saswp-table-close", function(){
1560
+ $(this).parent().remove();
1561
+ });
1562
+
1563
+ //How to schema js ends here
1564
+
1565
+
1566
+ $(document).on("change",".saswp-custom-meta-list", function(){
1567
+
1568
+ var meta_val = $(this).val();
1569
+ var field_name = $(this).parent().parent('tr').find(".saswp-custom-fields-name").val();
1570
+ var html = '';
1571
+ if(meta_val == 'manual_text'){
1572
+ html = '<td><input type="text" name="saswp_fixed_text['+field_name+']"></td>';
1573
+ }
1574
+
1575
+ if(meta_val == 'custom_field'){
1576
+ html += '<td><select class="saswp-custom-fields-select2" name="saswp_custom_meta_field['+field_name+']">';
1577
+ html += '</select></td>';
1578
+
1579
+ }
1580
+ $(this).parent().parent('tr').find("td:gt(1)").remove();
1581
+ $(this).parent().parent('tr').append(html);
1582
+ saswpCustomSelect2();
1583
+
1584
+ });
1585
+
1586
+ $(document).on("click", '.saswp-add-custom-fields', function(){
1587
+ var schema_type = $('select#schema_type option:selected').val();
1588
+ var post_id = $('#post_ID').val();
1589
+ if(schema_type !=''){
1590
+
1591
+ if(!saswp_meta_list_fields){
1592
+
1593
+ $.ajax({
1594
+ type: "POST",
1595
+ url:ajaxurl,
1596
+ dataType: "json",
1597
+ data:{action:"saswp_get_schema_type_fields",post_id:post_id, schema_type:schema_type, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1598
+ success:function(response){
1599
+ saswp_meta_list_fields = response;
1600
+ saswp_get_meta_list('text', saswp_meta_list_fields, null, null);
1601
+
1602
+ },
1603
+ error: function(response){
1604
+ console.log(response);
1605
+ }
1606
+ });
1607
+
1608
+
1609
+ }else{
1610
+ saswp_get_meta_list('text', saswp_meta_list_fields, null, null);
1611
+ }
1612
+
1613
+ }
1614
+ });
1615
+ saswpCustomSelect2();
1616
+ function saswpCustomSelect2(){
1617
+ if((saswp_localize_data.post_type == 'saswp' || saswp_localize_data.page_now =='saswp') && saswp_localize_data.page_now !='saswp_page_structured_data_options'){
1618
+
1619
+ $('.saswp-custom-fields-select2').select2({
1620
+ ajax: {
1621
+ type: "POST",
1622
+ url: ajaxurl, // AJAX URL is predefined in WordPress admin
1623
+ dataType: 'json',
1624
+ delay: 250, // delay in ms while typing when to perform a AJAX search
1625
+ data: function (params) {
1626
+ return {
1627
+ saswp_security_nonce: saswp_localize_data.saswp_security_nonce,
1628
+ q: params.term, // search query
1629
+ action: 'saswp_get_custom_meta_fields' // AJAX action for admin-ajax.php
1630
+ };
1631
+ },
1632
+ processResults: function( data ) {
1633
+ return {
1634
+ results: data
1635
+ };
1636
+ },
1637
+ cache: true
1638
+ },
1639
+ minimumInputLength: 2 // the minimum of symbols to input before perform a search
1640
+ });
1641
+
1642
+ }
1643
+
1644
+ }
1645
+
1646
+ function saswp_enable_rating_review(){
1647
+ var schema_type ="";
1648
+ if($('select#schema_type option:selected').val()){
1649
+ schema_type = $('select#schema_type option:selected').val();
1650
+ }
1651
+ if($(".saswp-tab-links.selected").attr('saswp-schema-type')){
1652
+ schema_type = $(".saswp-tab-links.selected").attr('saswp-schema-type');
1653
+ }
1654
+
1655
+ if(schema_type){
1656
+ $(".saswp-enable-rating-review-"+schema_type.toLowerCase()).change(function(){
1657
+
1658
+ if($(this).is(':checked')){
1659
+ $(this).parent().parent().siblings('.saswp-rating-review-'+schema_type.toLowerCase()).show();
1660
+ }else{
1661
+ $(this).parent().parent().siblings('.saswp-rating-review-'+schema_type.toLowerCase()).hide();
1662
+ }
1663
+
1664
+ }).change();
1665
+ }
1666
+
1667
+ }
1668
+ saswp_enable_rating_review();
1669
+
1670
+ //custom fields modify schema ends here
1671
+
1672
+
1673
+ //Google review js starts here
1674
+
1675
+ $('a[href="'+saswp_localize_data.collection_post_add_url+'"]').attr( 'href', saswp_localize_data.collection_post_add_new_url);
1676
+
1677
+
1678
+
1679
+ $(document).on("click", '.saswp_coonect_google_place', function(){
1680
+
1681
+ var place_id = $("#saswp_google_place_id").val();
1682
+ var language = $("#saswp_language_list").val();
1683
+ var google_api = $("#saswp_googel_api").val();
1684
+
1685
+ if(place_id !=''){
1686
+ $.ajax({
1687
+ type: "POST",
1688
+ url:ajaxurl,
1689
+ dataType: "json",
1690
+ data:{action:"saswp_connect_google_place",place_id:place_id, language:language, google_api:google_api, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1691
+ success:function(response){
1692
+ console.log(response['status']);
1693
+ },
1694
+ error: function(response){
1695
+ console.log(response);
1696
+ }
1697
+ });
1698
+ }
1699
+ });
1700
+
1701
+ //google review js ends here
1702
+
1703
+ //Adding settings button beside add schema type button on schema type list page
1704
+
1705
+ if ('saswp' == saswp_localize_data.post_type && saswp_localize_data.page_now == 'edit.php') {
1706
+
1707
+ jQuery(jQuery(".wrap a")[0]).after("<a href='"+saswp_localize_data.saswp_settings_url+"' id='' class='page-title-action'>Settings</a>");
1708
+
1709
+ }
1710
+
1711
+ //star rating stars here
1712
+ if(typeof(saswp_reviews_data) !== 'undefined'){
1713
+
1714
+ $(".saswp-rating-div").rateYo({
1715
+
1716
+ rating: saswp_reviews_data.rating_val,
1717
+ halfStar: true,
1718
+ //normalFill: "#ffd700",
1719
+ readOnly: saswp_reviews_data.readonly,
1720
+ onSet: function (rating, rateYoInstance) {
1721
+ $(this).next().val(rating);
1722
+ console.log(rating);
1723
+ }
1724
+
1725
+ });
1726
+
1727
+ }
1728
+ $(document).on("click", ".saswp-add-g-location-btn", function(e){
1729
+
1730
+ var blocks_field = '';
1731
+
1732
+ if($("#saswp_google_place_api_key").length){
1733
+
1734
+ blocks_field = '<input class="saswp-g-blocks-field" name="sd_data[saswp_reviews_location_blocks][]" type="number" min="5" step="5" placeholder="5" disabled="disabled">';
1735
+ }else{
1736
+ blocks_field = '<input class="saswp-g-blocks-field" name="sd_data[saswp_reviews_location_blocks][]" type="number" min="10" step="10" placeholder="10">';
1737
+ }
1738
+
1739
+ e.preventDefault();
1740
+ var html = '';
1741
+ html += '<tr>'
1742
+ + '<td style="width:12%;"><strong>Place Id</strong></td>'
1743
+ + '<td style="width:20%;"><input class="saswp-g-location-field" name="sd_data[saswp_reviews_location_name][]" type="text" value=""></td>'
1744
+ + '<td style="width:10%;"><strong>Reviews</strong></td>'
1745
+ + '<td style="width:10%;">'+blocks_field+'</td>'
1746
+ + '<td style="width:10%;"><a class="button button-default saswp-fetch-g-reviews">Fetch</a></td>'
1747
+ + '<td style="width:10%;"><a type="button" class="saswp-remove-review-item button">x</a></td>'
1748
+ + '<td style="width:10%;"><p class="saswp-rv-fetched-msg"></p></td>'
1749
+ + '</tr>';
1750
+ if(html){
1751
+ $(".saswp-g-reviews-settings-table").append(html);
1752
+ }
1753
+
1754
+ });
1755
+
1756
+ function saswp_fetch_s_approved_reviews(current){
1757
+
1758
+ current.addClass('updating-message');
1759
+ $.get(ajaxurl,
1760
+ { action:"saswp_fetch_s_approved_reviews", saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1761
+ function(response){
1762
+ current.removeClass('updating-message');
1763
+ console.log(response);
1764
+ if(response['status']){
1765
+ current.parent().parent().find('.saswp-rv-fetched-msg').text(response['message']);
1766
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "green");
1767
+ }else{
1768
+ current.parent().parent().find('.saswp-rv-fetched-msg').text(response['message']);
1769
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "#988f1b");
1770
+ }
1771
+
1772
+ },'json');
1773
+
1774
+ }
1775
+
1776
+ function saswp_add_s_approved_reviews(current, site_id, token, limit, api_key, page, loop_run){
1777
+ current.addClass('updating-message');
1778
+ $.get(ajaxurl,
1779
+ { action:"saswp_add_s_approved_reviews",site_id:site_id,token:token,limit:limit,api_key:api_key,page:page, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1780
+ function(response){
1781
+ current.removeClass('updating-message');
1782
+ console.log(response);
1783
+ if(response['status']){
1784
+ current.parent().parent().find('.saswp-rv-fetched-msg').text(response['message']);
1785
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "green");
1786
+ }else{
1787
+ current.parent().parent().find('.saswp-rv-fetched-msg').text(response['message']);
1788
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "#988f1b");
1789
+ }
1790
+ page++;
1791
+ if(page <loop_run){
1792
+ saswp_add_s_approved_reviews(current, site_id, token, limit, api_key, page);
1793
+ }else{
1794
+ saswp_fetch_s_approved_reviews(current);
1795
+ }
1796
+ },'json');
1797
+
1798
+ }
1799
+
1800
+ $(document).on("click",".saswp-fetch-s-approved-reviews", function(e){
1801
+
1802
+ e.preventDefault();
1803
+ var current = $(this);
1804
+ current.addClass('updating-message');
1805
+ var site_id = $("#saswp_s_approved_site_id").val();
1806
+ var token = $("#saswp_s_approved_token").val();
1807
+ var limit = $("#saswp_s_approved_reviews").val();
1808
+ var api_key = $("#reviews_addon_license_key").val();
1809
+ var loop_run = 1;
1810
+ var page = 0;
1811
+
1812
+ if(limit > 100){
1813
+ var div_limit = limit/100;
1814
+ var div_remainder = limit%100;
1815
+ loop_run = div_limit;
1816
+
1817
+ if(div_remainder){
1818
+ loop_run++;
1819
+ }
1820
+
1821
+ }
1822
+
1823
+ if(site_id && token && api_key){
1824
+
1825
+ saswp_add_s_approved_reviews(current, site_id, token, limit, api_key, page, loop_run);
1826
+
1827
+ }else{
1828
+ current.removeClass('updating-message');
1829
+ alert('Fill the site id and token with valid api key');
1830
+ }
1831
+
1832
+ });
1833
+
1834
+
1835
+ $(document).on("click", '.saswp-fetch-g-reviews', function(){
1836
+
1837
+ var current = $(this);
1838
+ var premium_status = 'free';
1839
+ current.addClass('updating-message');
1840
+
1841
+ var location = $(this).parent().parent().find('.saswp-g-location-field').val();
1842
+ var blocks = $(this).parent().parent().find('.saswp-g-blocks-field').val();
1843
+ var g_api = $("#saswp_google_place_api_key").val();
1844
+ var reviews_api = $("#reviews_addon_license_key").val();
1845
+ var reviews_api_status = $("#reviews_addon_license_key_status").val();
1846
+
1847
+ if($("#saswp_google_place_api_key").length){
1848
+ premium_status = 'free';
1849
+ }else{
1850
+ premium_status = 'premium';
1851
+ }
1852
+
1853
+ if(premium_status == 'premium'){
1854
+
1855
+ if(blocks > 0){
1856
+
1857
+ var blocks_remainder = blocks % 10;
1858
+
1859
+ if(blocks_remainder != 0){
1860
+
1861
+ current.parent().parent().find('.saswp-rv-fetched-msg').text('Reviews count should be in step of 10');
1862
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "#988f1b");
1863
+ current.removeClass('updating-message');
1864
+ return false;
1865
+
1866
+ }
1867
+
1868
+ }else{
1869
+ alert('Blocks value is zero');
1870
+ current.removeClass('updating-message');
1871
+ return false;
1872
+ }
1873
+
1874
+ }
1875
+
1876
+ if(location !='' && (reviews_api || g_api)){
1877
+ $.ajax({
1878
+ type: "POST",
1879
+ url:ajaxurl,
1880
+ dataType: "json",
1881
+ data:{action:"saswp_fetch_google_reviews",reviews_api_status:reviews_api_status, reviews_api:reviews_api,location:location,blocks:blocks,g_api:g_api,premium_status:premium_status, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
1882
+ success:function(response){
1883
+ if(response['status'] =='t'){
1884
+ current.parent().parent().find('.saswp-rv-fetched-msg').text('Success');
1885
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "green");
1886
+ }else{
1887
+ current.parent().parent().find('.saswp-rv-fetched-msg').text(response['message']);
1888
+ current.parent().parent().find('.saswp-rv-fetched-msg').css("color", "#988f1b");
1889
+ }
1890
+ current.removeClass('updating-message');
1891
+ },
1892
+ error: function(response){
1893
+ console.log(response);
1894
+ }
1895
+ });
1896
+ }else{
1897
+ if(location ==''){
1898
+ alert('Please enter place id');
1899
+ }
1900
+ if(g_api ==''){
1901
+ alert('Please enter api key');
1902
+ }
1903
+ if(reviews_api ==''){
1904
+ alert('Please enter reviews api key');
1905
+ }
1906
+ current.removeClass('updating-message');
1907
+ }
1908
+ });
1909
+
1910
+ //rating ends here
1911
+
1912
+ $("#sd-person-phone-number, #saswp_kb_telephone").focusout(function(){
1913
+ var current = $(this);
1914
+
1915
+ current.parent().find('.saswp-phone-validation').remove();
1916
+
1917
+ var pnumber = $(this).val();
1918
+ var p_regex = /^\+([0-9]{1,3})\)?[-. ]?([0-9]{2,4})[-. ]?([0-9]{2,4})[-. ]?([0-9]{2,4})$/;
1919
+
1920
+ if(!p_regex.test(pnumber)){
1921
+ current.after('<span style="color:red;" class="saswp-phone-validation">Invalid Phone Number</span>');
1922
+ }else{
1923
+ current.parent().find('.saswp-phone-validation').remove();
1924
+ }
1925
+
1926
+ });
1927
+
1928
+ });
admin_section/settings.php CHANGED
@@ -29,8 +29,36 @@ function saswp_plugin_action_links( $links ) {
29
 
30
  function saswp_add_menu_links() {
31
  // Settings page - Same as main menu page
32
- add_submenu_page( 'edit.php?post_type=saswp', esc_html__( 'Schema & Structured Data For Wp', 'schema-and-structured-data-for-wp' ), esc_html__( 'Settings', 'schema-and-structured-data-for-wp' ), 'manage_options', 'structured_data_options', 'saswp_admin_interface_render' );
33
- add_submenu_page( 'edit.php?post_type=saswp', esc_html__( 'Schema & Structured Data For Wp', 'schema-and-structured-data-for-wp' ), '<span style="color:#fff176;">'.esc_html__( 'Upgrade To Premium', 'schema-and-structured-data-for-wp' ).'</span>', 'manage_options', 'structured_data_premium', 'saswp_premium_interface_render' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  }
36
  add_action( 'admin_menu', 'saswp_add_menu_links' );
@@ -1061,7 +1089,7 @@ function saswp_general_page_callback(){
1061
 
1062
  function saswp_check_data_imported_from($plugin_post_type_name){
1063
 
1064
- $cc_args = array(
1065
  'posts_per_page' => -1,
1066
  'post_type' => 'saswp',
1067
  'meta_key' => 'imported_from',
@@ -1140,10 +1168,18 @@ function saswp_import_callback(){
1140
  $schema_pro_message = '';
1141
  $wp_seo_schema_message = '';
1142
  $seo_pressor_message = '';
 
1143
  $schema_plugin = saswp_check_data_imported_from('schema');
1144
  $schema_pro_plugin = saswp_check_data_imported_from('schema_pro');
1145
  $wp_seo_schema_plugin = saswp_check_data_imported_from('wp_seo_schema');
1146
  $seo_pressor = saswp_check_data_imported_from('seo_pressor');
 
 
 
 
 
 
 
1147
 
1148
  if($seo_pressor->post_count !=0){
1149
 
@@ -1196,6 +1232,12 @@ function saswp_import_callback(){
1196
  </div>
1197
  </li>
1198
 
 
 
 
 
 
 
1199
  </ul>
1200
  <?php
1201
  echo '<h2>'.esc_html__('Import / Export','schema-and-structured-data-for-wp').'</h2>';
@@ -1552,6 +1594,18 @@ function saswp_compatibility_page_callback(){
1552
  'name' => 'sd_data[saswp-seo-press]',
1553
  )
1554
  );
 
 
 
 
 
 
 
 
 
 
 
 
1555
  $aiosp = array(
1556
  'label' => 'All in One SEO Pack',
1557
  'id' => 'saswp-aiosp-checkbox',
@@ -1563,6 +1617,19 @@ function saswp_compatibility_page_callback(){
1563
  'id' => 'saswp-aiosp',
1564
  'name' => 'sd_data[saswp-aiosp]',
1565
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
1566
  );
1567
 
1568
  $the_events_calendar = array(
@@ -1774,6 +1841,8 @@ function saswp_compatibility_page_callback(){
1774
  $seo_press,
1775
  $the_seo_framework,
1776
  $aiosp,
 
 
1777
  $rankmath
1778
 
1779
  );
@@ -1980,7 +2049,9 @@ function saswp_get_field_note($pname){
1980
  'smart_crawl' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/smartcrawl-seo/">SmartCrawl Seo</a>',
1981
  'the_seo_framework' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/autodescription/">The Seo Framework</a>',
1982
  'seo_press' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/wp-seopress/">SEOPress</a>',
1983
- 'aiosp' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/all-in-one-seo-pack/">All in One SEO Pack</a>'
 
 
1984
  );
1985
 
1986
  if(!saswp_check_plugin_active_status($pname)){
29
 
30
  function saswp_add_menu_links() {
31
  // Settings page - Same as main menu page
32
+ add_submenu_page( 'edit.php?post_type=saswp', esc_html__( 'Schema & Structured Data For Wp', 'schema-and-structured-data-for-wp' ), esc_html__( 'Settings', 'schema-and-structured-data-for-wp' ), 'manage_options', 'structured_data_options', 'saswp_admin_interface_render' );
33
+
34
+ $mappings_file = SASWP_DIR_NAME . '/core/array-list/pro_extensions.php';
35
+
36
+ $pro_ext = array();
37
+
38
+ if ( file_exists( $mappings_file ) ) {
39
+ $pro_ext = include $mappings_file;
40
+ }
41
+
42
+ $check_active_ext = false;
43
+ if(!empty($pro_ext)){
44
+
45
+ foreach($pro_ext as $ext){
46
+
47
+ if(is_plugin_active($ext['path'])){
48
+
49
+ $check_active_ext = true;
50
+ break;
51
+ }
52
+
53
+ }
54
+
55
+ }
56
+
57
+ if(!$check_active_ext){
58
+ add_submenu_page( 'edit.php?post_type=saswp', esc_html__( 'Schema & Structured Data For Wp', 'schema-and-structured-data-for-wp' ), '<span style="color:#fff176;">'.esc_html__( 'Upgrade To Premium', 'schema-and-structured-data-for-wp' ).'</span>', 'manage_options', 'structured_data_premium', 'saswp_premium_interface_render' );
59
+ }
60
+
61
+
62
 
63
  }
64
  add_action( 'admin_menu', 'saswp_add_menu_links' );
1089
 
1090
  function saswp_check_data_imported_from($plugin_post_type_name){
1091
 
1092
+ $cc_args = array(
1093
  'posts_per_page' => -1,
1094
  'post_type' => 'saswp',
1095
  'meta_key' => 'imported_from',
1168
  $schema_pro_message = '';
1169
  $wp_seo_schema_message = '';
1170
  $seo_pressor_message = '';
1171
+ $wpsso_core_message = '';
1172
  $schema_plugin = saswp_check_data_imported_from('schema');
1173
  $schema_pro_plugin = saswp_check_data_imported_from('schema_pro');
1174
  $wp_seo_schema_plugin = saswp_check_data_imported_from('wp_seo_schema');
1175
  $seo_pressor = saswp_check_data_imported_from('seo_pressor');
1176
+ $wpsso_core = saswp_check_data_imported_from('wpsso_core');
1177
+
1178
+ if($wpsso_core->post_count !=0){
1179
+
1180
+ $wpsso_core_message = $message;
1181
+
1182
+ }
1183
 
1184
  if($seo_pressor->post_count !=0){
1185
 
1232
  </div>
1233
  </li>
1234
 
1235
+ <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__('WPSSO Core','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="wpsso_core" class="button saswp-import-plugins"><?php echo esc_html__('Import','schema-and-structured-data-for-wp'); ?></button>
1236
+ <p class="saswp-imported-message"></p>
1237
+ <?php echo '<p>'.esc_html__($wpsso_core_message, 'schema-and-structured-data-for-wp').'</p>'; ?>
1238
+ </div>
1239
+ </li>
1240
+
1241
  </ul>
1242
  <?php
1243
  echo '<h2>'.esc_html__('Import / Export','schema-and-structured-data-for-wp').'</h2>';
1594
  'name' => 'sd_data[saswp-seo-press]',
1595
  )
1596
  );
1597
+ $squirrly_seo = array(
1598
+ 'label' => 'Squirrly Seo',
1599
+ 'id' => 'saswp-squirrly-seo-checkbox',
1600
+ 'name' => 'saswp-squirrly-seo-checkbox',
1601
+ 'type' => 'checkbox',
1602
+ 'class' => 'checkbox saswp-checkbox',
1603
+ 'note' => saswp_get_field_note('squirrly_seo'),
1604
+ 'hidden' => array(
1605
+ 'id' => 'saswp-squirrly-seo',
1606
+ 'name' => 'sd_data[saswp-squirrly-seo]',
1607
+ )
1608
+ );
1609
  $aiosp = array(
1610
  'label' => 'All in One SEO Pack',
1611
  'id' => 'saswp-aiosp-checkbox',
1617
  'id' => 'saswp-aiosp',
1618
  'name' => 'sd_data[saswp-aiosp]',
1619
  )
1620
+ );
1621
+
1622
+ $recipe_maker = array(
1623
+ 'label' => 'WP Recipe Maker',
1624
+ 'id' => 'saswp-wp-recipe-maker-checkbox',
1625
+ 'name' => 'saswp-wp-recipe-maker-checkbox',
1626
+ 'type' => 'checkbox',
1627
+ 'class' => 'checkbox saswp-checkbox',
1628
+ 'note' => saswp_get_field_note('wp_recipe_maker'),
1629
+ 'hidden' => array(
1630
+ 'id' => 'saswp-wp-recipe-maker',
1631
+ 'name' => 'sd_data[saswp-wp-recipe-maker]',
1632
+ )
1633
  );
1634
 
1635
  $the_events_calendar = array(
1841
  $seo_press,
1842
  $the_seo_framework,
1843
  $aiosp,
1844
+ $squirrly_seo,
1845
+ $recipe_maker,
1846
  $rankmath
1847
 
1848
  );
2049
  'smart_crawl' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/smartcrawl-seo/">SmartCrawl Seo</a>',
2050
  'the_seo_framework' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/autodescription/">The Seo Framework</a>',
2051
  'seo_press' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/wp-seopress/">SEOPress</a>',
2052
+ 'aiosp' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/all-in-one-seo-pack/">All in One SEO Pack</a>',
2053
+ 'squirrly_seo' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/squirrly-seo/">Squirrly SEO</a>',
2054
+ 'wp_recipe_maker' => esc_html__('Requires','schema-and-structured-data-for-wp').' <a target="_blank" href="https://wordpress.org/plugins/wp-recipe-maker/">WP Recipe Maker</a>'
2055
  );
2056
 
2057
  if(!saswp_check_plugin_active_status($pname)){
admin_section/structure_admin.php CHANGED
@@ -1099,7 +1099,7 @@ function saswp_custom_breadcrumbs() {
1099
 
1100
  $parents .= '<li class="item-parent item-parent-' . esc_attr($ancestor) . '"><a class="bread-parent bread-parent-' . esc_attr($ancestor) . '" href="' . esc_url(get_permalink($ancestor)) . '" title="' . esc_attr(get_the_title($ancestor)) . '">' . esc_html__(get_the_title($ancestor), 'schema-and-structured-data-for-wp' ) . '</a></li>';
1101
  $parents .= '<li class="separator separator-' . esc_attr($ancestor) . '"> ' . esc_html__($separator, 'schema-and-structured-data-for-wp' ) . ' </li>';
1102
- $variables1_titles[] = get_the_title($ancestor);
1103
  $variables2_links[] = get_permalink($ancestor);
1104
 
1105
  }
@@ -1316,7 +1316,12 @@ function saswp_import_plugin_data(){
1316
  if ( is_plugin_active('seo-pressor/seo-pressor.php')) {
1317
  $result = saswp_import_seo_pressor_plugin_data();
1318
  }
1319
- break;
 
 
 
 
 
1320
 
1321
  default:
1322
  break;
@@ -1461,8 +1466,8 @@ function saswp_license_status($add_on, $license_status, $license_key){
1461
  if(strtolower($add_on) == 'reviews'){
1462
 
1463
  if(function_exists('saswp_create_reviews_user')){
1464
-
1465
- $user_create = saswp_create_reviews_user($license_key, strtolower($add_on));
1466
 
1467
  if($user_create['status']){
1468
 
1099
 
1100
  $parents .= '<li class="item-parent item-parent-' . esc_attr($ancestor) . '"><a class="bread-parent bread-parent-' . esc_attr($ancestor) . '" href="' . esc_url(get_permalink($ancestor)) . '" title="' . esc_attr(get_the_title($ancestor)) . '">' . esc_html__(get_the_title($ancestor), 'schema-and-structured-data-for-wp' ) . '</a></li>';
1101
  $parents .= '<li class="separator separator-' . esc_attr($ancestor) . '"> ' . esc_html__($separator, 'schema-and-structured-data-for-wp' ) . ' </li>';
1102
+ $variables1_titles[] = @get_the_title($ancestor);
1103
  $variables2_links[] = get_permalink($ancestor);
1104
 
1105
  }
1316
  if ( is_plugin_active('seo-pressor/seo-pressor.php')) {
1317
  $result = saswp_import_seo_pressor_plugin_data();
1318
  }
1319
+ break;
1320
+ case 'wpsso_core':
1321
+ if ( is_plugin_active('wpsso/wpsso.php') && is_plugin_active('wpsso-schema-json-ld/wpsso-schema-json-ld.php')) {
1322
+ $result = saswp_import_wpsso_core_plugin_data();
1323
+ }
1324
+ break;
1325
 
1326
  default:
1327
  break;
1466
  if(strtolower($add_on) == 'reviews'){
1467
 
1468
  if(function_exists('saswp_create_reviews_user')){
1469
+
1470
+ $user_create = saswp_create_reviews_user($license_key, $item_name[strtolower($add_on)]);
1471
 
1472
  if($user_create['status']){
1473
 
core/array-list/meta_list.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
- return array(
 
3
  'text' => array(
4
  array(
5
  'label' => __( 'Single Element', 'schema-and-structured-data-for-wp' ),
@@ -54,4 +55,5 @@ return array(
54
  ),
55
  ),
56
  ),
57
- );
 
1
  <?php
2
+ return apply_filters('saswp_modify_post_meta_list',
3
+ array(
4
  'text' => array(
5
  array(
6
  'label' => __( 'Single Element', 'schema-and-structured-data-for-wp' ),
55
  ),
56
  ),
57
  ),
58
+ )
59
+ );
core/array-list/plugins.php CHANGED
@@ -83,5 +83,17 @@ return array(
83
  'path_free' => 'all-in-one-seo-pack/all_in_one_seo_pack.php',
84
  'status_key' => 'saswp-aiosp',
85
  ),
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  );
83
  'path_free' => 'all-in-one-seo-pack/all_in_one_seo_pack.php',
84
  'status_key' => 'saswp-aiosp',
85
  ),
86
+ array(
87
+ 'key' => 'squirrly_seo',
88
+ 'name' => 'Squirrly SEO',
89
+ 'path_free' => 'squirrly-seo/squirrly.php',
90
+ 'status_key' => 'saswp-squirrly-seo',
91
+ ),
92
+ array(
93
+ 'key' => 'wp_recipe_maker',
94
+ 'name' => 'WP Recipe Maker',
95
+ 'path_free' => 'wp-recipe-maker/wp-recipe-maker.php',
96
+ 'status_key' => 'saswp-wp-recipe-maker',
97
+ ),
98
 
99
  );
core/array-list/pro_extensions.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ return array(
3
+
4
+ array(
5
+ 'key' => 'cooked_compatibility_for_schema',
6
+ 'name' => 'Cooked Compatibility for Schema',
7
+ 'path' => 'cooked-compatibility-for-schema/cooked-compatibility-for-schema.php',
8
+ ),
9
+ array(
10
+ 'key' => 'woocommerce_compatibility_for_schema',
11
+ 'name' => 'WooCommerce Compatibility for Schema',
12
+ 'path' => 'woocommerce-compatibility-for-schema/woocommerce-compatibility-for-schema.php',
13
+ ),
14
+ array(
15
+ 'key' => 'reviews_for_schema',
16
+ 'name' => 'Reviews for Schema',
17
+ 'path' => 'reviews-for-schema/reviews-for-schema.php',
18
+ )
19
+
20
+ );
output/compatibility.php CHANGED
@@ -7,11 +7,11 @@ class saswp_output_compatibility{
7
 
8
  public function __construct() {
9
 
10
- $mappings_file = SASWP_DIR_NAME . '/core/array-list/plugins.php';
11
-
12
- if ( file_exists( $mappings_file ) ) {
13
- $this->_plugins_list = include $mappings_file;
14
- }
15
 
16
  }
17
 
@@ -46,9 +46,8 @@ class saswp_output_compatibility{
46
 
47
  }
48
 
49
- }
50
-
51
-
52
  }
53
 
54
  public function saswp_wp_post_ratings_override(){
@@ -71,19 +70,18 @@ class saswp_output_compatibility{
71
 
72
  add_filter('the_seo_framework_receive_json_data', '__return_false');
73
  }
 
 
 
74
  public function saswp_smart_crawl_override(){
75
  add_filter('wds-schema-data', '__return_false');
76
  }
77
- public function saswp_seo_press_hooks(){
78
-
79
- remove_action('wp_head', 'seopress_social_accounts_jsonld_hook',1);
80
- remove_action('wp_head', 'seopress_social_website_option',1);
81
-
82
- }
83
- public function saswp_seo_press_override(){
84
-
85
- add_action('wp_head', array($this, 'saswp_seo_press_hooks'),0);
86
-
87
  }
88
  public function saswp_woocommerce_override(){
89
 
7
 
8
  public function __construct() {
9
 
10
+ $mappings_file = SASWP_DIR_NAME . '/core/array-list/plugins.php';
11
+
12
+ if ( file_exists( $mappings_file ) ) {
13
+ $this->_plugins_list = include $mappings_file;
14
+ }
15
 
16
  }
17
 
46
 
47
  }
48
 
49
+ }
50
+
 
51
  }
52
 
53
  public function saswp_wp_post_ratings_override(){
70
 
71
  add_filter('the_seo_framework_receive_json_data', '__return_false');
72
  }
73
+ public function saswp_squirrly_seo_override(){
74
+ add_filter('sq_json_ld', '__return_false',99);
75
+ }
76
  public function saswp_smart_crawl_override(){
77
  add_filter('wds-schema-data', '__return_false');
78
  }
79
+ public function saswp_seo_press_hooks(){
80
+ remove_action('wp_head', 'seopress_social_accounts_jsonld_hook',1);
81
+ remove_action('wp_head', 'seopress_social_website_option',1);
82
+ }
83
+ public function saswp_seo_press_override(){
84
+ add_action('wp_head', array($this, 'saswp_seo_press_hooks'),0);
 
 
 
 
85
  }
86
  public function saswp_woocommerce_override(){
87
 
output/function.php CHANGED
@@ -27,11 +27,27 @@ function saswp_schema_markup_hook_on_init() {
27
  add_action('wp_head', 'saswp_schema_markup_output');
28
  add_action( 'amp_post_template_head' , 'saswp_schema_markup_output' );
29
  }
 
 
 
30
  remove_action( 'amp_post_template_head', 'amp_post_template_add_schemaorg_metadata',99,1);
31
  remove_action( 'amp_post_template_footer', 'amp_post_template_add_schemaorg_metadata',99,1);
32
- remove_action('wp_footer', 'orbital_markup_site');
33
- add_action('cooked_amp_head', 'saswp_schema_markup_output');
 
 
 
 
 
 
 
 
 
34
 
 
 
 
 
35
  if(isset($sd_data['saswp-microdata-cleanup']) && $sd_data['saswp-microdata-cleanup'] == 1){
36
  ob_start("saswp_remove_microdata");
37
  }
@@ -40,7 +56,7 @@ function saswp_schema_markup_hook_on_init() {
40
  }
41
 
42
  /**
43
- * Function to show all the schema markup in the page head
44
  * @global type $sd_data
45
  * @global type json array
46
  */
@@ -80,7 +96,7 @@ function saswp_schema_markup_output() {
80
 
81
  }else{
82
 
83
- $schema_output = saswp_schema_output();
84
 
85
  }
86
  if(saswp_global_option()) {
@@ -752,7 +768,7 @@ function saswp_remove_microdata($content){
752
  if(isset($sd_data['saswp-aiosp']) && $sd_data['saswp-aiosp'] == 1 ){
753
  $content = preg_replace('/<script type=\"application\/ld\+json" class=\"aioseop-schema"\>(.*?)<\/script>/', "", $content);
754
  }
755
-
756
  }
757
 
758
  return $content;
@@ -811,3 +827,66 @@ function saswp_get_the_tags(){
811
  return $tag_str;
812
 
813
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  add_action('wp_head', 'saswp_schema_markup_output');
28
  add_action( 'amp_post_template_head' , 'saswp_schema_markup_output' );
29
  }
30
+
31
+ add_action('cooked_amp_head', 'saswp_schema_markup_output');
32
+
33
  remove_action( 'amp_post_template_head', 'amp_post_template_add_schemaorg_metadata',99,1);
34
  remove_action( 'amp_post_template_footer', 'amp_post_template_add_schemaorg_metadata',99,1);
35
+ remove_action('wp_footer', 'orbital_markup_site');
36
+ add_filter('hunch_schema_markup', '__return_false');
37
+ add_filter('wpsso_json_prop_https_schema_org_graph', '__return_false');
38
+
39
+ if(class_exists('BSF_AIOSRS_Pro_Markup')){
40
+
41
+ remove_action( 'wp_head', array( BSF_AIOSRS_Pro_Markup::get_instance(), 'schema_markup' ),10);
42
+ remove_action( 'wp_head', array( BSF_AIOSRS_Pro_Markup::get_instance(), 'global_schemas_markup' ),10);
43
+ remove_action( 'wp_footer', array( BSF_AIOSRS_Pro_Markup::get_instance(), 'schema_markup' ),10);
44
+ remove_action( 'wp_footer', array( BSF_AIOSRS_Pro_Markup::get_instance(), 'global_schemas_markup' ),10);
45
+ }
46
 
47
+ if(isset($sd_data['saswp-wp-recipe-maker']) && $sd_data['saswp-wp-recipe-maker'] == 1){
48
+ add_filter( 'wprm_recipe_metadata', '__return_false' );
49
+ }
50
+
51
  if(isset($sd_data['saswp-microdata-cleanup']) && $sd_data['saswp-microdata-cleanup'] == 1){
52
  ob_start("saswp_remove_microdata");
53
  }
56
  }
57
 
58
  /**
59
+ * This function collects all the schema markups and show them at one place either header or footer
60
  * @global type $sd_data
61
  * @global type json array
62
  */
96
 
97
  }else{
98
 
99
+ $schema_output = saswp_schema_output();
100
 
101
  }
102
  if(saswp_global_option()) {
768
  if(isset($sd_data['saswp-aiosp']) && $sd_data['saswp-aiosp'] == 1 ){
769
  $content = preg_replace('/<script type=\"application\/ld\+json" class=\"aioseop-schema"\>(.*?)<\/script>/', "", $content);
770
  }
771
+
772
  }
773
 
774
  return $content;
827
  return $tag_str;
828
 
829
  }
830
+
831
+ /**
832
+ * Function to get shorcode ids from content by shortcode typ
833
+ * @global type $post
834
+ * @param type $type
835
+ * @return type
836
+ * @since version 1.9.3
837
+ */
838
+ function saswp_get_ids_from_content_by_type($type){
839
+
840
+ global $post;
841
+ $content = $post->post_content;
842
+
843
+ switch ($type) {
844
+
845
+ case 'wp_recipe_maker':
846
+
847
+ // Gutenberg.
848
+ $gutenberg_matches = array();
849
+ $gutenberg_patern = '/<!--\s+wp:(wp\-recipe\-maker\/recipe)(\s+(\{.*?\}))?\s+(\/)?-->/';
850
+ preg_match_all( $gutenberg_patern, $content, $matches );
851
+
852
+ if ( isset( $matches[3] ) ) {
853
+ foreach ( $matches[3] as $block_attributes_json ) {
854
+ if ( ! empty( $block_attributes_json ) ) {
855
+ $attributes = json_decode( $block_attributes_json, true );
856
+ if ( ! is_null( $attributes ) ) {
857
+ if ( isset( $attributes['id'] ) ) {
858
+ $gutenberg_matches[] = intval( $attributes['id'] );
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+
865
+ // Classic Editor.
866
+ preg_match_all( '/<!--WPRM Recipe (\d+)-->.+?<!--End WPRM Recipe-->/ms', $content, $matches );
867
+ $classic_matches = isset( $matches[1] ) ? array_map( 'intval', $matches[1] ) : array();
868
+
869
+ return $gutenberg_matches + $classic_matches;
870
+
871
+ default:
872
+ break;
873
+ }
874
+
875
+ }
876
+ /**
877
+ * Function to get recipe schema markup from wp_recipe_maker
878
+ * @param type $recipe
879
+ * @return array
880
+ * @since version 1.9.3
881
+ */
882
+ function saswp_wp_recipe_schema_json($recipe){
883
+
884
+ if ( 'food' === $recipe->type() ) {
885
+ $metadata = WPRM_Metadata::get_food_metadata( $recipe );
886
+ } elseif ( 'howto' === $recipe->type() ) {
887
+ $metadata = WPRM_Metadata::get_howto_metadata( $recipe );
888
+ } else {
889
+ $metadata = array();
890
+ }
891
+ return $metadata;
892
+ }
output/output.php CHANGED
@@ -203,6 +203,7 @@ function saswp_schema_output() {
203
  }
204
 
205
  $all_schema_output = array();
 
206
 
207
  foreach($Conditionals as $schemaConditionals){
208
 
@@ -903,8 +904,28 @@ function saswp_schema_output() {
903
  }
904
 
905
  if( 'Recipe' === $schema_type){
906
-
907
- if(empty($image_details[0]) || $image_details[0] === NULL ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
908
  $image_details[0] = $sd_data['sd_logo']['url'];
909
  }
910
 
@@ -944,14 +965,29 @@ function saswp_schema_output() {
944
  $input1 = array_merge($input1, $extra_theme_review);
945
  }
946
 
947
- $input1 = apply_filters('saswp_modify_recipe_schema_output', $input1 );
 
 
 
948
  }
949
 
950
  if( 'qanda' === $schema_type){
951
 
952
- $service_object = new saswp_output_service();
953
- $input1 = $service_object->saswp_dw_question_answers_details(get_the_ID());
954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
955
  if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
956
  $service = new saswp_output_service();
957
  $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
@@ -1728,9 +1764,16 @@ function saswp_schema_output() {
1728
 
1729
  if(!empty($input1)){
1730
  $all_schema_output[] = $input1;
1731
- }
 
1732
  }
1733
 
 
 
 
 
 
 
1734
  return apply_filters('saswp_modify_schema_output', $all_schema_output);
1735
  }
1736
 
@@ -3728,14 +3771,19 @@ function saswp_post_specific_schema_output() {
3728
  $business_sub_name = '';
3729
  $business_type = saswp_remove_warnings($all_post_meta, 'saswp_business_type_'.$schema_id, 'saswp_array');
3730
  $post_specific_obj = new saswp_post_specific();
3731
- $check_business_type = $post_specific_obj->_local_sub_business[$business_type];
3732
 
3733
- if(!empty($check_business_type)){
 
 
 
 
 
 
 
 
3734
 
3735
- $business_sub_name = saswp_remove_warnings($all_post_meta, 'saswp_business_name_'.$schema_id, 'saswp_array');
3736
-
3737
  }
3738
-
3739
  if($business_sub_name){
3740
 
3741
  $local_business = $business_sub_name;
203
  }
204
 
205
  $all_schema_output = array();
206
+ $recipe_json = array();
207
 
208
  foreach($Conditionals as $schemaConditionals){
209
 
904
  }
905
 
906
  if( 'Recipe' === $schema_type){
907
+
908
+ if(isset($sd_data['saswp-wp-recipe-maker']) && $sd_data['saswp-wp-recipe-maker'] == 1){
909
+
910
+ $recipe_ids = saswp_get_ids_from_content_by_type('wp_recipe_maker');
911
+
912
+ if($recipe_ids){
913
+
914
+ foreach($recipe_ids as $recipe){
915
+
916
+ if(class_exists('WPRM_Recipe_Manager')){
917
+ $recipe_arr = WPRM_Recipe_Manager::get_recipe( $recipe );
918
+ $recipe_json[] = saswp_wp_recipe_schema_json($recipe_arr);
919
+ }
920
+
921
+ }
922
+
923
+ }
924
+
925
+
926
+ }else{
927
+
928
+ if(empty($image_details[0]) || $image_details[0] === NULL ){
929
  $image_details[0] = $sd_data['sd_logo']['url'];
930
  }
931
 
965
  $input1 = array_merge($input1, $extra_theme_review);
966
  }
967
 
968
+
969
+ }
970
+
971
+ $input1 = apply_filters('saswp_modify_recipe_schema_output', $input1 );
972
  }
973
 
974
  if( 'qanda' === $schema_type){
975
 
 
 
976
 
977
+ if(isset($sd_data['saswp-dw-question-answer']) && $sd_data['saswp-dw-question-answer'] ==1){
978
+
979
+ $service_object = new saswp_output_service();
980
+ $input1 = $service_object->saswp_dw_question_answers_details(get_the_ID());
981
+
982
+ }
983
+
984
+ if(isset($sd_data['saswp-bbpress']) && $sd_data['saswp-bbpress'] ==1){
985
+
986
+ $service_object = new saswp_output_service();
987
+ $input1 = $service_object->saswp_bb_press_topic_details(get_the_ID());
988
+
989
+ }
990
+
991
  if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
992
  $service = new saswp_output_service();
993
  $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
1764
 
1765
  if(!empty($input1)){
1766
  $all_schema_output[] = $input1;
1767
+ }
1768
+
1769
  }
1770
 
1771
+ if($recipe_json){
1772
+ foreach($recipe_json as $json){
1773
+ array_push($all_schema_output, $json);
1774
+ }
1775
+ }
1776
+
1777
  return apply_filters('saswp_modify_schema_output', $all_schema_output);
1778
  }
1779
 
3771
  $business_sub_name = '';
3772
  $business_type = saswp_remove_warnings($all_post_meta, 'saswp_business_type_'.$schema_id, 'saswp_array');
3773
  $post_specific_obj = new saswp_post_specific();
 
3774
 
3775
+ if(array_key_exists($business_type, $post_specific_obj->_local_sub_business)){
3776
+
3777
+ $check_business_type = $post_specific_obj->_local_sub_business[$business_type];
3778
+
3779
+ if(!empty($check_business_type)){
3780
+
3781
+ $business_sub_name = saswp_remove_warnings($all_post_meta, 'saswp_business_name_'.$schema_id, 'saswp_array');
3782
+
3783
+ }
3784
 
 
 
3785
  }
3786
+
3787
  if($business_sub_name){
3788
 
3789
  $local_business = $business_sub_name;
output/service.php CHANGED
@@ -37,8 +37,71 @@ Class saswp_output_service{
37
 
38
  add_action( 'wp_ajax_saswp_get_meta_list', array($this, 'saswp_get_meta_list'));
39
 
 
 
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  public function saswp_get_meta_list(){
44
 
@@ -179,6 +242,8 @@ Class saswp_output_service{
179
  }
180
 
181
  default:
 
 
182
  break;
183
  }
184
 
@@ -1845,7 +1910,60 @@ Class saswp_output_service{
1845
  return $review_data;
1846
 
1847
  }
1848
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1849
  /**
1850
  * This function gets all the question and answers in schema markup from the current question type post create by
1851
  * DW Question & Answer ( https://wordpress.org/plugins/dw-question-answer/ )
@@ -1886,7 +2004,7 @@ Class saswp_output_service{
1886
  if ( $my_posts->have_posts() ) {
1887
 
1888
  while ( $my_posts->have_posts() ) : $my_posts->the_post();
1889
- $dw_qa['text'] = get_the_content();
1890
  endwhile;
1891
 
1892
  }
@@ -2954,8 +3072,7 @@ Class saswp_output_service{
2954
 
2955
 
2956
  if($site_name){
2957
-
2958
-
2959
  $publisher['publisher']['@type'] = 'Organization';
2960
  $publisher['publisher']['name'] = esc_attr($site_name);
2961
 
37
 
38
  add_action( 'wp_ajax_saswp_get_meta_list', array($this, 'saswp_get_meta_list'));
39
 
40
+ add_filter( 'saswp_modify_post_meta_list', array( $this, 'saswp_get_acf_meta_keys' ) );
41
+
42
  }
43
 
44
+ public function saswp_get_acf_meta_keys($fields){
45
+
46
+ if ( function_exists( 'acf' ) && class_exists( 'acf' ) ) {
47
+
48
+ $post_type = 'acf';
49
+ if ( ( defined( 'ACF_PRO' ) && ACF_PRO ) || ( defined( 'ACF' ) && ACF ) ) {
50
+ $post_type = 'acf-field-group';
51
+ }
52
+ $text_acf_field = array();
53
+ $image_acf_field = array();
54
+ $args = array(
55
+ 'post_type' => $post_type,
56
+ 'posts_per_page' => -1,
57
+ 'post_status' => 'publish',
58
+ );
59
+
60
+ $the_query = new WP_Query( $args );
61
+ if ( $the_query->have_posts() ) :
62
+ while ( $the_query->have_posts() ) :
63
+ $the_query->the_post();
64
+
65
+ $post_id = get_the_id();
66
+
67
+ $acf_fields = apply_filters( 'acf/field_group/get_fields', array(), $post_id ); // WPCS: XSS OK.
68
+
69
+ if ( 'acf-field-group' == $post_type ) {
70
+ $acf_fields = acf_get_fields( $post_id );
71
+ }
72
+
73
+ if ( is_array( $acf_fields ) && ! empty( $acf_fields ) ) {
74
+ foreach ( $acf_fields as $key => $value ) {
75
+
76
+ if ( 'image' == $value['type'] ) {
77
+ $image_acf_field[ $value['name'] ] = $value['label'];
78
+ } else {
79
+ $text_acf_field[ $value['name'] ] = $value['label'];
80
+ }
81
+ }
82
+ }
83
+ endwhile;
84
+ endif;
85
+ wp_reset_postdata();
86
+
87
+ if ( ! empty( $text_acf_field ) ) {
88
+ $fields['text'][] = array(
89
+ 'label' => __( 'Advanced Custom Fields', 'schema-and-structured-data-for-wp' ),
90
+ 'meta-list' => $text_acf_field,
91
+ );
92
+ }
93
+
94
+ if ( ! empty( $image_acf_field ) ) {
95
+ $fields['image'][] = array(
96
+ 'label' => __( 'Advanced Custom Fields', 'schema-and-structured-data-for-wp' ),
97
+ 'meta-list' => $image_acf_field,
98
+ );
99
+ }
100
+ }
101
+
102
+ return $fields;
103
+
104
+ }
105
 
106
  public function saswp_get_meta_list(){
107
 
242
  }
243
 
244
  default:
245
+ $response = get_post_meta($schema_post_id, $field, true );
246
+
247
  break;
248
  }
249
 
1910
  return $review_data;
1911
 
1912
  }
1913
+
1914
+ public function saswp_bb_press_topic_details($post_id){
1915
+
1916
+ $dw_qa = array();
1917
+ $qa_page = array();
1918
+
1919
+ $dw_qa['@type'] = 'Question';
1920
+ $dw_qa['name'] = bbp_get_topic_title($post_id);
1921
+ $dw_qa['upvoteCount'] = bbp_get_topic_reply_count();
1922
+ $dw_qa['text'] = wp_strip_all_tags(bbp_get_topic_content());
1923
+ $dw_qa['dateCreated'] = date_format(date_create(get_post_time( get_option( 'date_format' ), false, $post_id, true )), "Y-m-d\TH:i:s\Z");
1924
+
1925
+ $dw_qa['author'] = array(
1926
+ '@type' => 'Person',
1927
+ 'name' =>bbp_get_topic_author($post_id),
1928
+ );
1929
+
1930
+ $dw_qa['answerCount'] = bbp_get_topic_reply_count();
1931
+
1932
+ $args = array(
1933
+ 'post_type' => 'reply',
1934
+ 'post_parent' => $post_id,
1935
+ 'post_per_page' => '-1',
1936
+ 'post_status' => array('publish')
1937
+ );
1938
+
1939
+ $answer_array = get_posts($args);
1940
+
1941
+ $suggested_answer = array();
1942
+
1943
+ foreach($answer_array as $answer){
1944
+
1945
+ $authorinfo = get_userdata($answer->post_author);
1946
+
1947
+ $suggested_answer[] = array(
1948
+ '@type' => 'Answer',
1949
+ 'upvoteCount' => 1,
1950
+ 'url' => get_permalink($answer->ID),
1951
+ 'text' => wp_strip_all_tags($answer->post_content),
1952
+ 'dateCreated' => get_the_date("Y-m-d\TH:i:s\Z", $answer),
1953
+ 'author' => array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename),
1954
+ );
1955
+
1956
+
1957
+ }
1958
+
1959
+ $dw_qa['suggestedAnswer'] = $suggested_answer;
1960
+
1961
+ $qa_page['@context'] = 'http://schema.org';
1962
+ $qa_page['@type'] = 'QAPage';
1963
+ $qa_page['mainEntity'] = $dw_qa;
1964
+ return $qa_page;
1965
+ }
1966
+
1967
  /**
1968
  * This function gets all the question and answers in schema markup from the current question type post create by
1969
  * DW Question & Answer ( https://wordpress.org/plugins/dw-question-answer/ )
2004
  if ( $my_posts->have_posts() ) {
2005
 
2006
  while ( $my_posts->have_posts() ) : $my_posts->the_post();
2007
+ $dw_qa['text'] = @get_the_content();
2008
  endwhile;
2009
 
2010
  }
3072
 
3073
 
3074
  if($site_name){
3075
+
 
3076
  $publisher['publisher']['@type'] = 'Organization';
3077
  $publisher['publisher']['name'] = esc_attr($site_name);
3078
 
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.2
6
- Stable tag: 1.9.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -22,6 +22,7 @@ Schema & Structured Data for WP & AMP adds Google Rich Snippets markup according
22
  * <strong>Migration</strong>: Import the data from other schema plugins such as (SEO Pressor, WP SEO Schema, Schema Plugin etc )
23
  * <strong>Compatibility</strong>: Generate the schema markup for the plugins. We have provided schema support for them. Few of them are - kk Star Ratings, WP-PostRatings, bbPress
24
  * <strong>Google Review</strong>: Display your business google reviews and its schema markup on your website.
 
25
  * <strong>Review Module</strong>: Create your own review rating box with pros and cons and its schema markup
26
  * <strong>Unlimited Custom Post Types</strong>: You can control to represent the Rich Snippets data in the google search console using unlimited custom post types.
27
  * <strong>Easy to use</strong> with Minimal Settings
@@ -110,6 +111,17 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
 
 
 
 
113
  = 1.9.2 (28 Aug 2019) =
114
 
115
  * Added: Compatibility with SEO Framework ( https://wordpress.org/plugins/autodescription/ ) #426
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 5.2
6
+ Stable tag: 1.9.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
22
  * <strong>Migration</strong>: Import the data from other schema plugins such as (SEO Pressor, WP SEO Schema, Schema Plugin etc )
23
  * <strong>Compatibility</strong>: Generate the schema markup for the plugins. We have provided schema support for them. Few of them are - kk Star Ratings, WP-PostRatings, bbPress
24
  * <strong>Google Review</strong>: Display your business google reviews and its schema markup on your website.
25
+ * **[Premium]** Reviews ( [Fetch](https://structured-data-for-wp.com/reviews-for-schema) reviews from 75+ platforms ).
26
  * <strong>Review Module</strong>: Create your own review rating box with pros and cons and its schema markup
27
  * <strong>Unlimited Custom Post Types</strong>: You can control to represent the Rich Snippets data in the google search console using unlimited custom post types.
28
  * <strong>Easy to use</strong> with Minimal Settings
111
 
112
  == Changelog ==
113
 
114
+
115
+ = 1.9.3 (30 Aug 2019) =
116
+
117
+ * New Feature: ACF meta fields inside Modify Schema Output #216
118
+ * Added: Compatibility with Squirrly Seo ( https://wordpress.org/plugins/squirrly-seo/ ) #426
119
+ * Added: Compatibility with WP Recipe maker ( https://wordpress.org/plugins/wp-recipe-maker/ ) #323
120
+ * Added: bbPress support with "Q&A Schema" #391
121
+ * Added: WPSSO Core importer #85
122
+ * Bug Fixed: Upgrade to pro message should not be there, if any pro extension is activated #450
123
+ * Bug Fixed: Notice: Undefined index: professionalservice in /schema-and-structured-data-for-wp/output/output.php on line 3731 #448
124
+
125
  = 1.9.2 (28 Aug 2019) =
126
 
127
  * Added: Compatibility with SEO Framework ( https://wordpress.org/plugins/autodescription/ ) #426
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.9.2
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.2');
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.9.3
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.3');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
view/review.php CHANGED
@@ -140,7 +140,7 @@ class saswp_metaboxes_review {
140
 
141
  <div class="saswp-review-description">
142
  <div><label><?php echo esc_html__('Summary Title', 'schema-and-structured-data-for-wp'); ?></label> <input type="text" id="saswp-review-item-description-title" name="saswp-review-item-description-title" value="<?php if ( isset( $saswp_review_details['saswp-review-item-description-title'] ) && ( ! empty( $saswp_review_details['saswp-review-item-description-title'] ) ) ) echo esc_attr( $saswp_review_details['saswp-review-item-description-title'] ); ?>"></div>
143
- <div class="saswp-wp-ediot-desc"><label>Description</label></div>
144
  <?php
145
  $content = get_post_meta( $post->ID, 'saswp-review-item-description', true );
146
  wp_editor( $content, 'saswp-review-item-description', array('textarea_rows'=> '5', 'media_buttons' => FALSE,) );
140
 
141
  <div class="saswp-review-description">
142
  <div><label><?php echo esc_html__('Summary Title', 'schema-and-structured-data-for-wp'); ?></label> <input type="text" id="saswp-review-item-description-title" name="saswp-review-item-description-title" value="<?php if ( isset( $saswp_review_details['saswp-review-item-description-title'] ) && ( ! empty( $saswp_review_details['saswp-review-item-description-title'] ) ) ) echo esc_attr( $saswp_review_details['saswp-review-item-description-title'] ); ?>"></div>
143
+ <div class="saswp-wp-ediot-desc"><label><?php echo esc_html__('Description', 'schema-and-structured-data-for-wp'); ?></label></div>
144
  <?php
145
  $content = get_post_meta( $post->ID, 'saswp-review-item-description', true );
146
  wp_editor( $content, 'saswp-review-item-description', array('textarea_rows'=> '5', 'media_buttons' => FALSE,) );