Schema & Structured Data for WP & AMP - Version 1.0.1

Version Description

(27 August 2018) = * AMP Compatibility improved for Schema * Default Schema compatibility added, which means the posts and pages will be set by default. * Minor bugs fixed

Download this release

Release Info

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

Code changes from version 1.0 to 1.0.1

admin_section/common-function.php CHANGED
@@ -104,14 +104,51 @@ function saswp_get_tab( $default = '', $available = array() ) {
104
  return $tab;
105
  }
106
 
107
- $sd_data=array();
 
 
108
  function saswp_defaultSettings(){
109
- global $sd_data;
110
- $defaults = array(
111
- 'saswp-for-wordpress' => 0,
112
- 'saswp-for-amp' => 0,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  );
114
- $sd_data = $settings = get_option( 'sd_data', $defaults);
115
  return $settings;
116
  }
117
- saswp_defaultSettings();
104
  return $tab;
105
  }
106
 
107
+ add_action('plugins_loaded', 'saswp_defaultSettings' );
108
+
109
+ $sd_data=array();
110
  function saswp_defaultSettings(){
111
+ global $sd_data;
112
+ $current_user = wp_get_current_user();
113
+ $current_url = get_home_url();
114
+ $custom_logo_id = get_theme_mod( 'custom_logo' );
115
+ $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
116
+ $defaults = array(
117
+ 'saswp-for-amp' => 1,
118
+ 'saswp-for-wordpress'=>1,
119
+ 'saswp_kb_type' => 'Organization',
120
+ 'saswp_kb_contact_1' => 0,
121
+ 'sd_name' => $current_user->user_login,
122
+ 'sd_alt_name' => $current_user->user_login,
123
+ 'sd-person-name' => $current_user->user_nicename,
124
+ 'sd-person-url' => $current_url,
125
+ 'saswp-logo-width' => '600',
126
+ 'saswp-logo-height' => '60',
127
+ 'sd_logo' => array(
128
+ 'url'=>$logo[0],
129
+ 'id'=>$custom_logo_id,
130
+ 'height'=>$logo[2],
131
+ 'width'=>$logo[1],
132
+ 'thumbnail'=>$logo[0]
133
+ ),
134
+ 'sd-data-logo-ampforwp' => array(
135
+ 'url'=>$logo[0],
136
+ 'id'=>$custom_logo_id,
137
+ 'height'=>$logo[2],
138
+ 'width'=>$logo[1],
139
+ 'thumbnail'=>$logo[0]
140
+ ),
141
+ 'sd_default_image' => array(
142
+ 'url'=>$logo[0],
143
+ 'id'=>$custom_logo_id,
144
+ 'height'=>$logo[2],
145
+ 'width'=>$logo[1],
146
+ 'thumbnail'=>$logo[0]
147
+ ),
148
+ 'sd_default_image_width' =>$logo[1],
149
+ 'sd_default_image_height' =>$logo[2]
150
+
151
  );
152
+ $sd_data = $settings = get_option( 'sd_data', $defaults);
153
  return $settings;
154
  }
 
admin_section/css/main-style.css CHANGED
@@ -12,25 +12,59 @@ and open the template in the editor.
12
  font-weight: 600;
13
  padding: 0px;
14
  }
 
 
 
 
 
 
15
  .saswp-knowledge table th{
16
  width: auto;
17
  padding: 0px;
 
 
 
 
 
 
18
  }
19
  .saswp-schema table th{
20
  width: auto;
21
  padding: 0px;
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  .saswp-help table th{
24
  width: auto;
25
  padding: 0px;
26
  }
 
 
 
 
 
 
27
  .saswp-settings-list{
28
  display:inline-block;
29
  width:100%
30
  }
31
  .saswp-settings-list li{
32
- padding:15px;
33
- padding-left:0px;
34
  }
35
  .saswp-settings-list li div label{
36
  font-weight: 600;
@@ -53,6 +87,9 @@ padding-left:0px;
53
  .saswp_qanda_p{
54
  font-weight: 500;
55
  }
 
 
 
56
 
57
 
58
 
12
  font-weight: 600;
13
  padding: 0px;
14
  }
15
+ .saswp-general table{
16
+ margin-top: 0px;
17
+ }
18
+ .saswp-general table td{
19
+ padding: 5px;
20
+ }
21
  .saswp-knowledge table th{
22
  width: auto;
23
  padding: 0px;
24
+ }
25
+ .saswp-knowledge table{
26
+ margin-top: 0px;
27
+ }
28
+ .saswp-knowledge table td{
29
+ padding: 5px;
30
  }
31
  .saswp-schema table th{
32
  width: auto;
33
  padding: 0px;
34
  }
35
+ .saswp-schema table{
36
+ margin-top: 0px;
37
+ }
38
+ .saswp-schema table td{
39
+ padding: 5px;
40
+ }
41
+ .saswp-amp table th{
42
+ width: auto;
43
+ padding: 0px;
44
+ }
45
+ .saswp-amp table{
46
+ margin-top: 0px;
47
+ }
48
+ .saswp-amp table td{
49
+ padding: 5px;
50
+ }
51
  .saswp-help table th{
52
  width: auto;
53
  padding: 0px;
54
  }
55
+ .saswp-help table{
56
+ margin-top: 0px;
57
+ }
58
+ .saswp-help table td{
59
+ padding: 5px;
60
+ }
61
  .saswp-settings-list{
62
  display:inline-block;
63
  width:100%
64
  }
65
  .saswp-settings-list li{
66
+ padding:15px;
67
+ padding-left:0px;
68
  }
69
  .saswp-settings-list li div label{
70
  font-weight: 600;
87
  .saswp_qanda_p{
88
  font-weight: 500;
89
  }
90
+ .saswp-display-none{
91
+ display: none !important;
92
+ }
93
 
94
 
95
 
admin_section/fields-generator.php CHANGED
@@ -84,6 +84,7 @@ class saswp_fields_generator {
84
  $input .= '</select>';
85
  break;
86
  default:
 
87
  $input = sprintf(
88
  '<input class="%s" %s id="%s" name="%s" type="%s" value="%s">',
89
  $class,
@@ -92,7 +93,8 @@ class saswp_fields_generator {
92
  esc_attr($meta_field['name']),
93
  esc_attr($meta_field['type']),
94
  esc_attr($settings[$meta_field['id']])
95
- );
 
96
  }
97
 
98
  $allowed_html = saswp_expanded_allowed_tags();
84
  $input .= '</select>';
85
  break;
86
  default:
87
+
88
  $input = sprintf(
89
  '<input class="%s" %s id="%s" name="%s" type="%s" value="%s">',
90
  $class,
93
  esc_attr($meta_field['name']),
94
  esc_attr($meta_field['type']),
95
  esc_attr($settings[$meta_field['id']])
96
+ );
97
+
98
  }
99
 
100
  $allowed_html = saswp_expanded_allowed_tags();
admin_section/js/main-script.js CHANGED
@@ -23,9 +23,11 @@ jQuery(document).ready(function($){
23
  window.history.pushState("", "", href);
24
  return false;
25
  });
26
- //Settings page jquery starts here
 
27
  $(".saswp-checkbox").change(function(){
28
- var id = $(this).attr("id");
 
29
  switch(id){
30
  case 'saswp-for-wordpress-checkbox':
31
 
@@ -35,6 +37,96 @@ jQuery(document).ready(function($){
35
  $("#saswp-for-wordpress").val(0);
36
  }
37
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  case 'saswp-for-amp-checkbox':
39
 
40
  if ($(this).is(':checked')) {
@@ -47,18 +139,18 @@ jQuery(document).ready(function($){
47
 
48
  if ($(this).is(':checked')) {
49
  $("#saswp_kb_contact_1").val(1);
50
- $("#saswp_kb_telephone, #saswp_contact_type").parent().parent('li').show();
51
- }else{
52
  $("#saswp_kb_contact_1").val(0);
53
- $("#saswp_kb_telephone, #saswp_contact_type").parent().parent('li').hide();
54
  }
55
  break;
56
  case 'saswp-logo-dimensions-check':
57
 
58
  if ($(this).is(':checked')) {
59
  $("#saswp-logo-dimensions").val(1);
60
- $("#saswp-logo-width, #saswp-logo-height").parent().parent('li').show();
61
- }else{
62
  $("#saswp-logo-dimensions").val(0);
63
  $("#saswp-logo-width, #saswp-logo-height").parent().parent('li').hide();
64
  }
@@ -94,12 +186,14 @@ jQuery(document).ready(function($){
94
  }else{
95
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
96
  }
97
- }else{
98
  if(i<8){
99
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
100
  }else{
101
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
102
  }
 
 
103
  }
104
 
105
  }
23
  window.history.pushState("", "", href);
24
  return false;
25
  });
26
+ //Settings page jquery starts here
27
+
28
  $(".saswp-checkbox").change(function(){
29
+ var id = $(this).attr("id");
30
+ console.log(id);
31
  switch(id){
32
  case 'saswp-for-wordpress-checkbox':
33
 
37
  $("#saswp-for-wordpress").val(0);
38
  }
39
  break;
40
+ case 'saswp-facebook-enable-checkbox':
41
+
42
+ if ($(this).is(':checked')) {
43
+ $("#saswp-facebook-enable").val(1);
44
+ $("#sd_facebook").show();
45
+ }else{
46
+ $("#saswp-facebook-enable").val(0);
47
+ $("#sd_facebook").hide();
48
+ }
49
+ break;
50
+ case 'saswp-twitter-enable-checkbox':
51
+
52
+ if ($(this).is(':checked')) {
53
+ $("#saswp-twitter-enable").val(1);
54
+ $("#sd_twitter").show();
55
+ }else{
56
+ $("#saswp-twitter-enable").val(0);
57
+ $("#sd_twitter").hide();
58
+ }
59
+ break;
60
+ case 'saswp-google-plus-enable-checkbox':
61
+
62
+ if ($(this).is(':checked')) {
63
+ $("#saswp-google-plus-enable").val(1);
64
+ $("#sd_google_plus").show();
65
+ }else{
66
+ $("#saswp-google-plus-enable").val(0);
67
+ $("#sd_google_plus").hide();
68
+ }
69
+ break;
70
+ case 'saswp-instagram-enable-checkbox':
71
+
72
+ if ($(this).is(':checked')) {
73
+ $("#saswp-instagram-enable").val(1);
74
+ $("#sd_instagram").show();
75
+ }else{
76
+ $("#saswp-instagram-enable").val(0);
77
+ $("#sd_instagram").hide();
78
+ }
79
+ break;
80
+ case 'saswp-youtube-enable-checkbox':
81
+
82
+ if ($(this).is(':checked')) {
83
+ $("#sd_youtube").show();
84
+ $("#saswp-youtube-enable").val(1);
85
+ }else{
86
+ $("#saswp-youtube-enable").val(0);
87
+ $("#sd_youtube").hide();
88
+ }
89
+ break;
90
+ case 'saswp-linkedin-enable-checkbox':
91
+
92
+ if ($(this).is(':checked')) {
93
+ $("#saswp-linkedin-enable").val(1);
94
+ $("#sd_linkedin").show();
95
+ }else{
96
+ $("#saswp-linkedin-enable").val(0);
97
+ $("#sd_linkedin").hide();
98
+ }
99
+ break;
100
+ case 'saswp-pinterest-enable-checkbox':
101
+
102
+ if ($(this).is(':checked')) {
103
+ $("#saswp-pinterest-enable").val(1);
104
+ $("#sd_pinterest").show();
105
+ }else{
106
+ $("#saswp-pinterest-enable").val(0);
107
+ $("#sd_pinterest").hide();
108
+ }
109
+ break;
110
+ case 'saswp-soundcloud-enable-checkbox':
111
+
112
+ if ($(this).is(':checked')) {
113
+ $("#saswp-soundcloud-enable").val(1);
114
+ $("#sd_soundcloud").show();
115
+ }else{
116
+ $("#saswp-soundcloud-enable").val(0);
117
+ $("#sd_soundcloud").hide();
118
+ }
119
+ break;
120
+ case 'saswp-tumblr-enable-checkbox':
121
+
122
+ if ($(this).is(':checked')) {
123
+ $("#saswp-tumblr-enable").val(1);
124
+ $("#sd_tumblr").show();
125
+ }else{
126
+ $("#saswp-tumblr-enable").val(0);
127
+ $("#sd_tumblr").hide();
128
+ }
129
+ break;
130
  case 'saswp-for-amp-checkbox':
131
 
132
  if ($(this).is(':checked')) {
139
 
140
  if ($(this).is(':checked')) {
141
  $("#saswp_kb_contact_1").val(1);
142
+ $("#saswp_kb_telephone, #saswp_contact_type").parent().parent('li').removeClass("saswp-display-none");
143
+ }else{
144
  $("#saswp_kb_contact_1").val(0);
145
+ $("#saswp_kb_telephone, #saswp_contact_type").parent().parent('li').addClass("saswp-display-none");
146
  }
147
  break;
148
  case 'saswp-logo-dimensions-check':
149
 
150
  if ($(this).is(':checked')) {
151
  $("#saswp-logo-dimensions").val(1);
152
+ $("#saswp-logo-width, #saswp-logo-height").parent().parent('li').show();
153
+ }else{
154
  $("#saswp-logo-dimensions").val(0);
155
  $("#saswp-logo-width, #saswp-logo-height").parent().parent('li').hide();
156
  }
186
  }else{
187
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
188
  }
189
+ }else if(datatype ==="Organization"){
190
  if(i<8){
191
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
192
  }else{
193
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
194
  }
195
+ }else{
196
+ $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
197
  }
198
 
199
  }
admin_section/js/structure_admin.js CHANGED
@@ -31,7 +31,7 @@ jQuery(document).ready(function($){
31
  parent.children(".spinner").addClass("show");
32
  var ajaxURL = amp_sdwp_field_data.ajax_url;
33
  //ajax call
34
- $.ajax({
35
  url : ajaxURL,
36
  method : "POST",
37
  data: {
31
  parent.children(".spinner").addClass("show");
32
  var ajaxURL = amp_sdwp_field_data.ajax_url;
33
  //ajax call
34
+ $.ajax({
35
  url : ajaxURL,
36
  method : "POST",
37
  data: {
admin_section/newsletter.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class saswp_newsletter {
2
+ const DISPLAY_VERSION = 'v1.0';
3
+ function __construct () {
4
+ add_action('admin_enqueue_scripts', array($this, 'saswp_admin_enqueue_scripts'));
5
+ }
6
+ function saswp_admin_enqueue_scripts () {
7
+ $dismissed = explode (',', get_user_meta (wp_get_current_user ()->ID, 'dismissed_wp_pointers', true));
8
+ $do_tour = !in_array ('saswp_subscribe_pointer', $dismissed);
9
+ if ($do_tour) {
10
+ wp_enqueue_style ('wp-pointer');
11
+ wp_enqueue_script ('wp-pointer');
12
+ add_action('admin_print_footer_scripts', array($this, 'saswp_admin_print_footer_scripts'));
13
+ add_action('admin_head', array($this, 'saswp_admin_head')); // Hook to admin head
14
+ }
15
+ }
16
+ function saswp_admin_head () {
17
+ ?>
18
+ <style type="text/css" media="screen"> #pointer-primary { margin: 0 5px 0 0; } </style>
19
+ <?php }
20
+ function saswp_admin_print_footer_scripts () {
21
+
22
+ global $pagenow;
23
+ global $current_user;
24
+ $tour = array ();
25
+ $tab = isset($_GET['tab']) ? $_GET['tab'] : '';
26
+ $function = '';
27
+ $button2 = '';
28
+ $options = array ();
29
+ $show_pointer = false;
30
+
31
+ if (!array_key_exists($tab, $tour)) {
32
+ $show_pointer = true;
33
+ $displayID = '#menu-posts-saswp'; // Define ID used on page html element where we want to display pointer
34
+ $content = '<h3>' . sprintf (__('Thanks for using Structured Data!', 'schema-and-structured-data-for-wp'), self::DISPLAY_VERSION) . '</h3>';
35
+ $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>', 'schema-and-structured-data-for-wp');
36
+ $content .= __('
37
+ <style type="text/css">
38
+ .wp-pointer-buttons{ padding:0; overflow: hidden; }
39
+ .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; }
40
+ </style>
41
+ <div id="afw_mc_embed_signup">
42
+ <form class="ml-block-form" action="https://app.mailerlite.com/webforms/submit/z7t4b8" data-code="z7t4b8" method="post" target="_blank">
43
+ <div id="afw_mc_embed_signup_scroll">
44
+ <div class="afw-mc-field-group" style=" margin-left: 15px; width: 195px; float: left;">
45
+ <input type="text" name="fields[name]" class="form-control" placeholder="Name" hidden value="' . esc_attr( $current_user->display_name ) . '" style="display:none">
46
+
47
+ <input type="text" value="' . esc_attr( $current_user->user_email ) . '" name="fields[email]" class="form-control" placeholder="Email*" style=" width: 180px; padding: 6px 5px;">
48
+
49
+ <input type="text" name="fields[company]" class="form-control" placeholder="Website" hidden style=" display:none; width: 168px; padding: 6px 5px;" value="' . esc_attr( get_home_url() ) . '">
50
+
51
+ <input type="hidden" name="ml-submit" value="1" />
52
+ </div>
53
+ <div id="mce-responses">
54
+ <div class="response" id="mce-error-response" style="display:none"></div>
55
+ <div class="response" id="mce-success-response" style="display:none"></div>
56
+ </div>
57
+ <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
58
+ <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_a631df13442f19caede5a5baf_c9a71edce6" tabindex="-1" value=""></div>
59
+ <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;">
60
+ </div>
61
+ </form>
62
+ </div>','schema-and-structured-data-for-wp');
63
+ $options = array (
64
+ 'content' => $content,
65
+ 'position' => array ('edge' => 'left', 'align' => 'left')
66
+ );
67
+ }
68
+ if ($show_pointer) {
69
+ $this->saswp_pointer_script ($displayID, $options, esc_html__('No Thanks', 'schema-and-structured-data-for-wp'), $button2, $function);
70
+ }
71
+ }
72
+ function saswp_get_admin_url($page, $tab) {
73
+ $url = admin_url();
74
+ $url .= $page.'?tab='.$tab;
75
+ return $url;
76
+ }
77
+ function saswp_pointer_script ($displayID, $options, $button1, $button2=false, $function='') {
78
+ ?>
79
+ <script type="text/javascript">
80
+ (function ($) {
81
+ var wp_pointers_tour_opts = <?php echo json_encode ($options); ?>, setup;
82
+ wp_pointers_tour_opts = $.extend (wp_pointers_tour_opts, {
83
+ buttons: function (event, t) {
84
+ button= jQuery ('<a id="pointer-close" class="button-secondary">' + '<?php echo $button1; ?>' + '</a>');
85
+ button_2= jQuery ('#pointer-close.button');
86
+ button.bind ('click.pointer', function () {
87
+ t.element.pointer ('close');
88
+ });
89
+ button_2.on('click', function() {
90
+ t.element.pointer ('close');
91
+ } );
92
+ return button;
93
+ },
94
+ close: function () {
95
+ $.post (ajaxurl, {
96
+ pointer: 'saswp_subscribe_pointer',
97
+ action: 'dismiss-wp-pointer'
98
+ });
99
+ },
100
+ show: function(event, t){
101
+ t.pointer.css({'left':'170px', 'top':'197px', 'position':'fixed'});
102
+ }
103
+ });
104
+ setup = function () {
105
+ $('<?php echo esc_attr($displayID); ?>').pointer(wp_pointers_tour_opts).pointer('open');
106
+ <?php if ($button2) { ?>
107
+ jQuery ('#pointer-close').after ('<a id="pointer-primary" class="button-primary">' + '<?php echo $button2; ?>' + '</a>');
108
+ jQuery ('#pointer-primary').click (function () {
109
+ <?php echo $function; ?>
110
+ });
111
+ jQuery ('#pointer-close').click (function () {
112
+ $.post (ajaxurl, {
113
+ pointer: 'saswp_subscribe_pointer',
114
+ action: 'dismiss-wp-pointer'
115
+ });
116
+ })
117
+ <?php } ?>
118
+ };
119
+ if (wp_pointers_tour_opts.position && wp_pointers_tour_opts.position.defer_loading) {
120
+ $(window).bind('load.wp-pointers', setup);
121
+ }
122
+ else {
123
+ setup ();
124
+ }
125
+ }) (jQuery);
126
+ </script>
127
+ <?php
128
+ }
129
+ }
130
+ $saswp_newsletter = new saswp_newsletter();
131
+ ?>
admin_section/settings.php CHANGED
@@ -18,10 +18,19 @@ function saswp_admin_interface_render(){
18
  }
19
  // Handing save settings
20
  if ( isset( $_GET['settings-updated'] ) ) {
21
- // Show Settings Saved Message
22
  settings_errors();
23
  }
24
- $tab = saswp_get_tab('general', array('general','knowledge','schema', 'help'));
 
 
 
 
 
 
 
 
 
25
  ?>
26
  <div class="wrap saswp-settings-form">
27
  <h1> <?php echo esc_html__( 'Schema And Structured Data For WP', 'schema-and-structured-data-for-wp' ); ?></h1>
@@ -34,6 +43,10 @@ function saswp_admin_interface_render(){
34
 
35
  echo '<a href="' . esc_url(saswp_admin_link('schema')) . '" class="nav-tab ' . esc_attr( $tab == 'schema' ? 'nav-tab-active' : '') . '"><span class="dashicons dashicons-welcome-view-site"></span> ' . esc_html__('Schema Type','schema-and-structured-data-for-wp') . '</a>';
36
 
 
 
 
 
37
  echo '<a href="' . esc_url(saswp_admin_link('help')) . '" class="nav-tab ' . esc_attr( $tab == 'help' ? 'nav-tab-active' : '') . '"><span class="dashicons dashicons-dashboard"></span> ' . esc_html__('Help','schema-and-structured-data-for-wp') . '</a>';
38
  ?>
39
  </h2>
@@ -54,6 +67,10 @@ function saswp_admin_interface_render(){
54
  echo "<div class='saswp-schema' ".( $tab != 'schema' ? 'style="display:none;"' : '').">";
55
  do_settings_sections( 'saswp_schema_section' ); // Page slug
56
  echo "</div>";
 
 
 
 
57
 
58
  echo "<div class='saswp-help' ".( $tab != 'help' ? 'style="display:none;"' : '').">";
59
  // Status
@@ -72,8 +89,6 @@ function saswp_admin_interface_render(){
72
  </div>
73
  <?php
74
  }
75
-
76
-
77
  /*
78
  WP Settings API
79
  */
@@ -108,7 +123,18 @@ function saswp_settings_init(){
108
  'saswp_schema_page_callback', // CB
109
  'saswp_schema_section', // Page slug
110
  'saswp_schema_section' // Settings Section ID
111
- );
 
 
 
 
 
 
 
 
 
 
 
112
  add_settings_section('saswp_help_section', __return_false(), '__return_false', 'saswp_help_section');
113
 
114
  add_settings_field(
@@ -122,43 +148,7 @@ function saswp_settings_init(){
122
  function saswp_schema_page_callback(){
123
  // Get Settings
124
  $settings = saswp_defaultSettings();
125
- $field_objs = new saswp_fields_generator();
126
- $meta_fields_schema_type = array(
127
- array(
128
- 'label' => 'Post',
129
- 'id' => 'sd_post_type',
130
- 'name' => 'sd_data[sd_post_type]',
131
- 'type' => 'select',
132
- 'options' => array(
133
- ''=>'Select an item',
134
- 'Blogposting'=>'Blogposting',
135
- 'NewsArticle'=>'NewsArticle',
136
- 'WebPage'=>'WebPage',
137
- 'Article'=>'Article',
138
- 'Recipe'=>'Recipe',
139
- 'Product'=>'Product',
140
- 'VideoObject'=>'VideoObject',
141
- )
142
- ),
143
- array(
144
- 'label' => 'Page',
145
- 'id' => 'sd_page_type',
146
- 'name' => 'sd_data[sd_page_type]',
147
- 'type' => 'select',
148
- 'options' => array(
149
- ''=>'Select an item',
150
- 'Blogposting'=>'Blogposting',
151
- 'NewsArticle'=>'NewsArticle',
152
- 'WebPage'=>'WebPage',
153
- 'Article'=>'Article',
154
- 'Recipe'=>'Recipe',
155
- 'Product'=>'Product',
156
- 'VideoObject'=>'VideoObject',
157
- )
158
- ),
159
- );
160
- echo '<h2>'.esc_html__('Schema Type','schema-and-structured-data-for-wp').'</h2>';
161
- $field_objs->saswp_field_generator($meta_fields_schema_type, $settings);
162
  $meta_fields_default = array(
163
  array(
164
  'label' => 'Default Structured Data Logo',
@@ -251,23 +241,12 @@ function saswp_schema_page_callback(){
251
 
252
  <?php
253
  }
254
- function saswp_general_page_callback(){
255
- // Get Settings
256
- $settings = saswp_defaultSettings();
257
  $field_objs = new saswp_fields_generator();
258
  $meta_fields = array(
259
- array(
260
- 'label' => 'Structured Data for WordPress',
261
- 'id' => 'saswp-for-wordpress-checkbox',
262
- 'name' => 'saswp-for-wordpress-checkbox',
263
- 'type' => 'checkbox',
264
- 'class' => 'checkbox saswp-checkbox',
265
- 'note' => '',
266
- 'hidden' => array(
267
- 'id' => 'saswp-for-wordpress',
268
- 'name' => 'sd_data[saswp-for-wordpress]',
269
- )
270
- ),
271
  array(
272
  'label' => 'Structured Data for AMP',
273
  'id' => 'saswp-for-amp-checkbox',
@@ -278,11 +257,26 @@ function saswp_general_page_callback(){
278
  'id' => 'saswp-for-amp',
279
  'name' => 'sd_data[saswp-for-amp]',
280
  )
281
- ),
 
 
 
 
 
 
 
 
 
 
 
 
282
  );
283
  echo '<h2>'.esc_html__('Set Up','schema-and-structured-data-for-wp').'</h2>';
284
- $field_objs->saswp_field_generator($meta_fields, $settings);
285
-
 
 
 
286
  ?>
287
  <div class="saswp-settings-list">
288
  <h2><?php echo esc_html__('Page Schema','schema-and-structured-data-for-wp') ?></h2>
@@ -343,6 +337,7 @@ function saswp_knowledge_page_callback(){
343
  'name' => 'sd_data[saswp_kb_type]',
344
  'type' => 'select',
345
  'options' => array(
 
346
  'Organization'=>'Organization',
347
  'Person'=>'Person',
348
  )
@@ -459,9 +454,20 @@ function saswp_knowledge_page_callback(){
459
 
460
  //social
461
  echo '<h2>'.esc_html__( 'Social Fields', 'schema-and-structured-data-for-wp' ).'</h2>';
462
- $social_meta_fields = array(
463
- array(
464
  'label' => 'Facebook',
 
 
 
 
 
 
 
 
 
 
 
465
  'id' => 'sd_facebook',
466
  'name' => 'sd_data[sd_facebook]',
467
  'class' => 'regular-text',
@@ -472,6 +478,17 @@ function saswp_knowledge_page_callback(){
472
  ),
473
  array(
474
  'label' => 'Twitter',
 
 
 
 
 
 
 
 
 
 
 
475
  'id' => 'sd_twitter',
476
  'name' => 'sd_data[sd_twitter]',
477
  'class' => 'regular-text',
@@ -480,8 +497,19 @@ function saswp_knowledge_page_callback(){
480
  'placeholder' => 'https://'
481
  )
482
  ),
483
- array(
484
  'label' => 'Google+',
 
 
 
 
 
 
 
 
 
 
 
485
  'id' => 'sd_google_plus',
486
  'name' => 'sd_data[sd_google_plus]',
487
  'class' => 'regular-text',
@@ -489,9 +517,20 @@ function saswp_knowledge_page_callback(){
489
  'attributes' => array(
490
  'placeholder' => 'https://'
491
  )
492
- ),
493
  array(
494
  'label' => 'Instagram',
 
 
 
 
 
 
 
 
 
 
 
495
  'id' => 'sd_instagram',
496
  'name' => 'sd_data[sd_instagram]',
497
  'class' => 'regular-text',
@@ -502,6 +541,17 @@ function saswp_knowledge_page_callback(){
502
  ),
503
  array(
504
  'label' => 'Youtube',
 
 
 
 
 
 
 
 
 
 
 
505
  'id' => 'sd_youtube',
506
  'name' => 'sd_data[sd_youtube]',
507
  'class' => 'regular-text',
@@ -512,6 +562,17 @@ function saswp_knowledge_page_callback(){
512
  ),
513
  array(
514
  'label' => 'LinkedIn',
 
 
 
 
 
 
 
 
 
 
 
515
  'id' => 'sd_linkedin',
516
  'name' => 'sd_data[sd_linkedin]',
517
  'class' => 'regular-text',
@@ -522,6 +583,17 @@ function saswp_knowledge_page_callback(){
522
  ),
523
  array(
524
  'label' => 'Pinterest',
 
 
 
 
 
 
 
 
 
 
 
525
  'id' => 'sd_pinterest',
526
  'name' => 'sd_data[sd_pinterest]',
527
  'class' => 'regular-text',
@@ -532,6 +604,17 @@ function saswp_knowledge_page_callback(){
532
  ),
533
  array(
534
  'label' => 'SoundCloud',
 
 
 
 
 
 
 
 
 
 
 
535
  'id' => 'sd_soundcloud',
536
  'name' => 'sd_data[sd_soundcloud]',
537
  'class' => 'regular-text',
@@ -540,8 +623,19 @@ function saswp_knowledge_page_callback(){
540
  'placeholder' => 'https://'
541
  )
542
  ),
543
- array(
544
  'label' => 'Tumblr',
 
 
 
 
 
 
 
 
 
 
 
545
  'id' => 'sd_tumblr',
546
  'name' => 'sd_data[sd_tumblr]',
547
  'class' => 'regular-text',
18
  }
19
  // Handing save settings
20
  if ( isset( $_GET['settings-updated'] ) ) {
21
+ // Show Settings Saved Message
22
  settings_errors();
23
  }
24
+ $is_amp =false;
25
+ if ( is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') || is_plugin_active('amp/amp.php') ) {
26
+ $is_amp = true;
27
+ }
28
+ if($is_amp){
29
+ $tab = saswp_get_tab('general', array('general','knowledge','schema','amp', 'help'));
30
+ }else{
31
+ $tab = saswp_get_tab('general', array('general','knowledge','schema', 'help'));
32
+ }
33
+
34
  ?>
35
  <div class="wrap saswp-settings-form">
36
  <h1> <?php echo esc_html__( 'Schema And Structured Data For WP', 'schema-and-structured-data-for-wp' ); ?></h1>
43
 
44
  echo '<a href="' . esc_url(saswp_admin_link('schema')) . '" class="nav-tab ' . esc_attr( $tab == 'schema' ? 'nav-tab-active' : '') . '"><span class="dashicons dashicons-welcome-view-site"></span> ' . esc_html__('Schema Type','schema-and-structured-data-for-wp') . '</a>';
45
 
46
+ if($is_amp){
47
+ echo '<a href="' . esc_url(saswp_admin_link('amp')) . '" class="nav-tab ' . esc_attr( $tab == 'amp' ? 'nav-tab-active' : '') . '"><span class="dashicons dashicons-welcome-view-site"></span> ' . esc_html__('AMP','schema-and-structured-data-for-wp') . '</a>';
48
+ }
49
+
50
  echo '<a href="' . esc_url(saswp_admin_link('help')) . '" class="nav-tab ' . esc_attr( $tab == 'help' ? 'nav-tab-active' : '') . '"><span class="dashicons dashicons-dashboard"></span> ' . esc_html__('Help','schema-and-structured-data-for-wp') . '</a>';
51
  ?>
52
  </h2>
67
  echo "<div class='saswp-schema' ".( $tab != 'schema' ? 'style="display:none;"' : '').">";
68
  do_settings_sections( 'saswp_schema_section' ); // Page slug
69
  echo "</div>";
70
+
71
+ echo "<div class='saswp-amp' ".( $tab != 'amp' ? 'style="display:none;"' : '').">";
72
+ do_settings_sections( 'saswp_amp_section' ); // Page slug
73
+ echo "</div>";
74
 
75
  echo "<div class='saswp-help' ".( $tab != 'help' ? 'style="display:none;"' : '').">";
76
  // Status
89
  </div>
90
  <?php
91
  }
 
 
92
  /*
93
  WP Settings API
94
  */
123
  'saswp_schema_page_callback', // CB
124
  'saswp_schema_section', // Page slug
125
  'saswp_schema_section' // Settings Section ID
126
+ );
127
+
128
+ add_settings_section('saswp_amp_section', __return_false(), '__return_false', 'saswp_amp_section');
129
+
130
+ add_settings_field(
131
+ 'saswp_amp_settings', // ID
132
+ '', // Title
133
+ 'saswp_amp_page_callback', // CB
134
+ 'saswp_amp_section', // Page slug
135
+ 'saswp_amp_section' // Settings Section ID
136
+ );
137
+
138
  add_settings_section('saswp_help_section', __return_false(), '__return_false', 'saswp_help_section');
139
 
140
  add_settings_field(
148
  function saswp_schema_page_callback(){
149
  // Get Settings
150
  $settings = saswp_defaultSettings();
151
+ $field_objs = new saswp_fields_generator();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  $meta_fields_default = array(
153
  array(
154
  'label' => 'Default Structured Data Logo',
241
 
242
  <?php
243
  }
244
+
245
+ function saswp_amp_page_callback(){
246
+ $settings = saswp_defaultSettings();
247
  $field_objs = new saswp_fields_generator();
248
  $meta_fields = array(
249
+
 
 
 
 
 
 
 
 
 
 
 
250
  array(
251
  'label' => 'Structured Data for AMP',
252
  'id' => 'saswp-for-amp-checkbox',
257
  'id' => 'saswp-for-amp',
258
  'name' => 'sd_data[saswp-for-amp]',
259
  )
260
+ ),
261
+ array(
262
+ 'label' => 'Structured Data for Non AMP',
263
+ 'id' => 'saswp-for-wordpress-checkbox',
264
+ 'name' => 'saswp-for-wordpress-checkbox',
265
+ 'type' => 'checkbox',
266
+ 'class' => 'checkbox saswp-checkbox',
267
+ 'note' => '',
268
+ 'hidden' => array(
269
+ 'id' => 'saswp-for-wordpress',
270
+ 'name' => 'sd_data[saswp-for-wordpress]',
271
+ )
272
+ ),
273
  );
274
  echo '<h2>'.esc_html__('Set Up','schema-and-structured-data-for-wp').'</h2>';
275
+ $field_objs->saswp_field_generator($meta_fields, $settings);
276
+ }
277
+
278
+ function saswp_general_page_callback(){
279
+ $settings = saswp_defaultSettings();
280
  ?>
281
  <div class="saswp-settings-list">
282
  <h2><?php echo esc_html__('Page Schema','schema-and-structured-data-for-wp') ?></h2>
337
  'name' => 'sd_data[saswp_kb_type]',
338
  'type' => 'select',
339
  'options' => array(
340
+ ''=>'Select an item',
341
  'Organization'=>'Organization',
342
  'Person'=>'Person',
343
  )
454
 
455
  //social
456
  echo '<h2>'.esc_html__( 'Social Fields', 'schema-and-structured-data-for-wp' ).'</h2>';
457
+ $social_meta_fields = array(
458
+ array(
459
  'label' => 'Facebook',
460
+ 'id' => 'saswp-facebook-enable-checkbox',
461
+ 'name' => 'saswp-facebook-enable-checkbox',
462
+ 'type' => 'checkbox',
463
+ 'class' => 'checkbox saswp-checkbox',
464
+ 'hidden' => array(
465
+ 'id' => 'saswp-facebook-enable',
466
+ 'name' => 'sd_data[saswp-facebook-enable]',
467
+ )
468
+ ),
469
+ array(
470
+ 'label' => '',
471
  'id' => 'sd_facebook',
472
  'name' => 'sd_data[sd_facebook]',
473
  'class' => 'regular-text',
478
  ),
479
  array(
480
  'label' => 'Twitter',
481
+ 'id' => 'saswp-twitter-enable-checkbox',
482
+ 'name' => 'saswp-twitter-enable-checkbox',
483
+ 'type' => 'checkbox',
484
+ 'class' => 'checkbox saswp-checkbox',
485
+ 'hidden' => array(
486
+ 'id' => 'saswp-twitter-enable',
487
+ 'name' => 'sd_data[saswp-twitter-enable]',
488
+ )
489
+ ),
490
+ array(
491
+ 'label' => '',
492
  'id' => 'sd_twitter',
493
  'name' => 'sd_data[sd_twitter]',
494
  'class' => 'regular-text',
497
  'placeholder' => 'https://'
498
  )
499
  ),
500
+ array(
501
  'label' => 'Google+',
502
+ 'id' => 'saswp-google-plus-enable-checkbox',
503
+ 'name' => 'saswp-google-plus-enable-checkbox',
504
+ 'type' => 'checkbox',
505
+ 'class' => 'checkbox saswp-checkbox',
506
+ 'hidden' => array(
507
+ 'id' => 'saswp-google-plus-enable',
508
+ 'name' => 'sd_data[saswp-google-plus-enable]',
509
+ )
510
+ ),
511
+ array(
512
+ 'label' => '',
513
  'id' => 'sd_google_plus',
514
  'name' => 'sd_data[sd_google_plus]',
515
  'class' => 'regular-text',
517
  'attributes' => array(
518
  'placeholder' => 'https://'
519
  )
520
+ ),
521
  array(
522
  'label' => 'Instagram',
523
+ 'id' => 'saswp-instagram-enable-checkbox',
524
+ 'name' => 'saswp-instagram-enable-checkbox',
525
+ 'type' => 'checkbox',
526
+ 'class' => 'checkbox saswp-checkbox',
527
+ 'hidden' => array(
528
+ 'id' => 'saswp-instagram-enable',
529
+ 'name' => 'sd_data[saswp-instagram-enable]',
530
+ )
531
+ ),
532
+ array(
533
+ 'label' => '',
534
  'id' => 'sd_instagram',
535
  'name' => 'sd_data[sd_instagram]',
536
  'class' => 'regular-text',
541
  ),
542
  array(
543
  'label' => 'Youtube',
544
+ 'id' => 'saswp-youtube-enable-checkbox',
545
+ 'name' => 'saswp-youtube-enable-checkbox',
546
+ 'type' => 'checkbox',
547
+ 'class' => 'checkbox saswp-checkbox',
548
+ 'hidden' => array(
549
+ 'id' => 'saswp-youtube-enable',
550
+ 'name' => 'sd_data[saswp-youtube-enable]',
551
+ )
552
+ ),
553
+ array(
554
+ 'label' => '',
555
  'id' => 'sd_youtube',
556
  'name' => 'sd_data[sd_youtube]',
557
  'class' => 'regular-text',
562
  ),
563
  array(
564
  'label' => 'LinkedIn',
565
+ 'id' => 'saswp-linkedin-enable-checkbox',
566
+ 'name' => 'saswp-linkedin-enable-checkbox',
567
+ 'type' => 'checkbox',
568
+ 'class' => 'checkbox saswp-checkbox',
569
+ 'hidden' => array(
570
+ 'id' => 'saswp-linkedin-enable',
571
+ 'name' => 'sd_data[saswp-linkedin-enable]',
572
+ )
573
+ ),
574
+ array(
575
+ 'label' => '',
576
  'id' => 'sd_linkedin',
577
  'name' => 'sd_data[sd_linkedin]',
578
  'class' => 'regular-text',
583
  ),
584
  array(
585
  'label' => 'Pinterest',
586
+ 'id' => 'saswp-pinterest-enable-checkbox',
587
+ 'name' => 'saswp-pinterest-enable-checkbox',
588
+ 'type' => 'checkbox',
589
+ 'class' => 'checkbox saswp-checkbox',
590
+ 'hidden' => array(
591
+ 'id' => 'saswp-pinterest-enable',
592
+ 'name' => 'sd_data[saswp-pinterest-enable]',
593
+ )
594
+ ),
595
+ array(
596
+ 'label' => '',
597
  'id' => 'sd_pinterest',
598
  'name' => 'sd_data[sd_pinterest]',
599
  'class' => 'regular-text',
604
  ),
605
  array(
606
  'label' => 'SoundCloud',
607
+ 'id' => 'saswp-soundcloud-enable-checkbox',
608
+ 'name' => 'saswp-soundcloud-enable-checkbox',
609
+ 'type' => 'checkbox',
610
+ 'class' => 'checkbox saswp-checkbox',
611
+ 'hidden' => array(
612
+ 'id' => 'saswp-soundcloud-enable',
613
+ 'name' => 'sd_data[saswp-soundcloud-enable]',
614
+ )
615
+ ),
616
+ array(
617
+ 'label' => '',
618
  'id' => 'sd_soundcloud',
619
  'name' => 'sd_data[sd_soundcloud]',
620
  'class' => 'regular-text',
623
  'placeholder' => 'https://'
624
  )
625
  ),
626
+ array(
627
  'label' => 'Tumblr',
628
+ 'id' => 'saswp-tumblr-enable-checkbox',
629
+ 'name' => 'saswp-tumblr-enable-checkbox',
630
+ 'type' => 'checkbox',
631
+ 'class' => 'checkbox saswp-checkbox',
632
+ 'hidden' => array(
633
+ 'id' => 'saswp-tumblr-enable',
634
+ 'name' => 'sd_data[saswp-tumblr-enable]',
635
+ )
636
+ ),
637
+ array(
638
+ 'label' => '',
639
  'id' => 'sd_tumblr',
640
  'name' => 'sd_data[sd_tumblr]',
641
  'class' => 'regular-text',
admin_section/structure_admin.php CHANGED
@@ -81,7 +81,7 @@ function saswp_generate_field_data( $post_id ){
81
  }
82
 
83
  function saswp_comparison_logic_checker($input){
84
- global $post;
85
  $type = $input['key_1'];
86
  $comparison = $input['key_2'];
87
  $data = $input['key_3'];
@@ -191,8 +191,12 @@ function saswp_comparison_logic_checker($input){
191
  // Page
192
  case 'page':
193
  global $redux_builder_amp;
194
- if(ampforwp_is_front_page()){
195
- $current_post = $redux_builder_amp['amp-frontpage-select-option-pages'];
 
 
 
 
196
  }else{
197
  $current_post = $post->ID;
198
  }
@@ -306,7 +310,7 @@ if(is_admin()){
306
  'name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
307
  'singular_name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
308
  'add_new' => esc_html__( 'Add New', 'schema-and-structured-data-for-wp' ),
309
- 'add_new_item' => esc_html__( 'Add New', 'schema-and-structured-data-for-wp' ),
310
  'edit_item' => esc_html__( 'Edit Structured Data','schema-and-structured-data-for-wp')
311
  ),
312
  'public' => true,
@@ -401,7 +405,7 @@ if(is_admin()){
401
  <select class="widefat comparison" name="data_array[<?php echo esc_attr( $i )?>][key_2]"> <?php
402
  foreach ($comparison as $key => $value) {
403
  $selcomp = '';
404
- if($key == $selected_val_key_2){
405
  $selcomp = 'selected';
406
  }
407
  ?>
@@ -507,15 +511,16 @@ if(is_admin()){
507
  // Save PHP Editor
508
  add_action ( 'save_post' , 'saswp_select_save_data' );
509
  function saswp_select_save_data ( $post_id ) {
 
510
  if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
511
 
512
  // if our nonce isn't there, or we can't verify it, bail
513
  if( !isset( $_POST['saswp_select_name_nonce'] ) || !wp_verify_nonce( $_POST['saswp_select_name_nonce'], 'saswp_select_action_nonce' ) ) return;
514
 
515
  // if our current user can't edit this post, bail
516
- if( !current_user_can( 'edit_post' ) ) return;
517
- $post_data_array = array();
518
-
519
  foreach($_POST['data_array'] as $post){
520
  $post_data_array[] = array_map('sanitize_text_field', $post);
521
  }
@@ -545,13 +550,11 @@ if(is_admin()){
545
  }
546
  add_action("admin_init",'saswp_migration');
547
  function saswp_migration(){
548
- $sdwp_migration_posts = get_option("sdwp_migration_posts");
549
- $sd_data = get_option("sd_data");
550
- if($sdwp_migration_posts != 'inserted'){
551
- if(isset($sd_data['sd_page_type'])){
552
- $postarr = array(
553
- 'post_type'=>'saswp',
554
- 'post_title'=>'Default page type',
555
  'post_status'=>'publish',
556
 
557
  );
@@ -566,14 +569,13 @@ function saswp_migration(){
566
  );
567
  $schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
568
  update_post_meta( $insertedPageId, 'data_array', $post_data_array);
569
- update_post_meta( $insertedPageId, 'schema_type', $sd_data['sd_page_type']);
570
  update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
571
  }
572
- }
573
- if(isset($sd_data['sd_post_type'])){
574
  $postarr = array(
575
  'post_type'=>'saswp',
576
- 'post_title'=>'Default post type',
577
  'post_status'=>'publish',
578
 
579
  );
@@ -588,11 +590,10 @@ function saswp_migration(){
588
  );
589
  $schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
590
  update_post_meta( $insertedPageId, 'data_array', $post_data_array);
591
- update_post_meta( $insertedPageId, 'schema_type', $sd_data['sd_post_type']);
592
  update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
593
  }
594
- }
595
-
596
  update_option( "sdwp_migration_posts", "inserted");
597
 
598
  }
81
  }
82
 
83
  function saswp_comparison_logic_checker($input){
84
+ global $post;
85
  $type = $input['key_1'];
86
  $comparison = $input['key_2'];
87
  $data = $input['key_3'];
191
  // Page
192
  case 'page':
193
  global $redux_builder_amp;
194
+ if(function_exists('ampforwp_is_front_page')){
195
+ if(ampforwp_is_front_page()){
196
+ $current_post = $redux_builder_amp['amp-frontpage-select-option-pages'];
197
+ } else{
198
+ $current_post = $post->ID;
199
+ }
200
  }else{
201
  $current_post = $post->ID;
202
  }
310
  'name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
311
  'singular_name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
312
  'add_new' => esc_html__( 'Add New', 'schema-and-structured-data-for-wp' ),
313
+ 'add_new_item' => esc_html__( 'Add New', 'schema-and-structured-data-for-wp' ),
314
  'edit_item' => esc_html__( 'Edit Structured Data','schema-and-structured-data-for-wp')
315
  ),
316
  'public' => true,
405
  <select class="widefat comparison" name="data_array[<?php echo esc_attr( $i )?>][key_2]"> <?php
406
  foreach ($comparison as $key => $value) {
407
  $selcomp = '';
408
+ if($key == $selected_val_key_1){
409
  $selcomp = 'selected';
410
  }
411
  ?>
511
  // Save PHP Editor
512
  add_action ( 'save_post' , 'saswp_select_save_data' );
513
  function saswp_select_save_data ( $post_id ) {
514
+ // print_r($_POST);die;
515
  if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
516
 
517
  // if our nonce isn't there, or we can't verify it, bail
518
  if( !isset( $_POST['saswp_select_name_nonce'] ) || !wp_verify_nonce( $_POST['saswp_select_name_nonce'], 'saswp_select_action_nonce' ) ) return;
519
 
520
  // if our current user can't edit this post, bail
521
+ if( !current_user_can( 'edit_post' ) ) return;
522
+ $meta_value = get_post_meta( $post_id, null, true );
523
+ $post_data_array = array();
524
  foreach($_POST['data_array'] as $post){
525
  $post_data_array[] = array_map('sanitize_text_field', $post);
526
  }
550
  }
551
  add_action("admin_init",'saswp_migration');
552
  function saswp_migration(){
553
+ $sdwp_migration_posts = get_option("sdwp_migration_posts");
554
+ if($sdwp_migration_posts != 'inserted'){
555
+ $postarr = array(
556
+ 'post_type'=>'saswp',
557
+ 'post_title'=>'Default Page Type',
 
 
558
  'post_status'=>'publish',
559
 
560
  );
569
  );
570
  $schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
571
  update_post_meta( $insertedPageId, 'data_array', $post_data_array);
572
+ update_post_meta( $insertedPageId, 'schema_type', 'WebPage');
573
  update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
574
  }
575
+
 
576
  $postarr = array(
577
  'post_type'=>'saswp',
578
+ 'post_title'=>'Default Post Type',
579
  'post_status'=>'publish',
580
 
581
  );
590
  );
591
  $schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
592
  update_post_meta( $insertedPageId, 'data_array', $post_data_array);
593
+ update_post_meta( $insertedPageId, 'schema_type', 'Blogposting');
594
  update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
595
  }
596
+
 
597
  update_option( "sdwp_migration_posts", "inserted");
598
 
599
  }
output/function.php CHANGED
@@ -55,7 +55,7 @@ function saswp_data_generator() {
55
  }
56
 
57
  if(!empty($schema_output)){
58
- $output .= "// Type Schmea\n";
59
  $output .= $schema_output;
60
  $output .= "\n\n";
61
  }
55
  }
56
 
57
  if(!empty($schema_output)){
58
+ $output .= "// Type Schema\n";
59
  $output .= $schema_output;
60
  $output .= "\n\n";
61
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Schema and Structured Data for WP & AMP ===
2
  Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
3
- Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO
4
  Requires at least: 3.0
5
  Tested up to: 4.9.8
6
- Stable tag: 1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -61,5 +61,11 @@ Yes, Absolutely! We would suggest you send your feature request by creating an i
61
  You can contact us from [here](https://ampforwp.com/contact/)
62
 
63
  == Changelog ==
 
 
 
 
 
 
64
  = 1.0 (6 August 2018) =
65
  * Version 1.0 Released
1
  === Schema and Structured Data for WP & AMP ===
2
  Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
3
+ Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 4.9.8
6
+ Stable tag: 1.0.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
61
  You can contact us from [here](https://ampforwp.com/contact/)
62
 
63
  == Changelog ==
64
+
65
+ = 1.0.1 (27 August 2018) =
66
+ * AMP Compatibility improved for Schema
67
+ * Default Schema compatibility added, which means the posts and pages will be set by default.
68
+ * Minor bugs fixed
69
+
70
  = 1.0 (6 August 2018) =
71
  * Version 1.0 Released
structured-data-for-wp.php CHANGED
@@ -2,10 +2,10 @@
2
  /*
3
  Plugin Name: Schema and Structured Data for WP
4
  Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5
- Version: 1.0
6
  Text Domain: schema-and-structured-data-for-wp
7
  Author: Mohammed Kaludi, Ahmed Kaludi
8
- Author URI: http://ampforwp.com
9
  Donate link: https://www.paypal.me/Kaludi/25
10
  License: GPL2
11
  */
@@ -13,11 +13,11 @@ License: GPL2
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
- define('SASWP_VERSION', '1.0');
17
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
18
 
19
  if ( ! defined( 'SASWP_VERSION' ) ) {
20
- define( 'SASWP_VERSION', '1.0' );
21
  }
22
  // the name of the settings page for the license input to be displayed
23
  if(! defined('SASWP_ITEM_FOLDER_NAME')){
@@ -45,5 +45,6 @@ require_once SASWP_DIR_NAME.'/admin_section/structure_admin.php';
45
  require_once SASWP_DIR_NAME.'/admin_section/settings.php';
46
  require_once SASWP_DIR_NAME.'/admin_section/common-function.php';
47
  require_once SASWP_DIR_NAME.'/admin_section/fields-generator.php';
 
48
  //Loading Metaboxes
49
  require SASWP_DIR_NAME.'/metaboxes/help.php';
2
  /*
3
  Plugin Name: Schema and Structured Data for WP
4
  Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5
+ Version: 1.0.1
6
  Text Domain: schema-and-structured-data-for-wp
7
  Author: Mohammed Kaludi, Ahmed Kaludi
8
+ Author URI: http://structured-data-for-wp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
10
  License: GPL2
11
  */
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
+ define('SASWP_VERSION', '1.0.1');
17
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
18
 
19
  if ( ! defined( 'SASWP_VERSION' ) ) {
20
+ define( 'SASWP_VERSION', '1.0.1' );
21
  }
22
  // the name of the settings page for the license input to be displayed
23
  if(! defined('SASWP_ITEM_FOLDER_NAME')){
45
  require_once SASWP_DIR_NAME.'/admin_section/settings.php';
46
  require_once SASWP_DIR_NAME.'/admin_section/common-function.php';
47
  require_once SASWP_DIR_NAME.'/admin_section/fields-generator.php';
48
+ require_once SASWP_DIR_NAME.'/admin_section/newsletter.php';
49
  //Loading Metaboxes
50
  require SASWP_DIR_NAME.'/metaboxes/help.php';