Schema & Structured Data for WP & AMP - Version 1.0.8

Version Description

(28 January 2019) =

  • Added: Yoast plugin compatibility ( If yoast is activated for schema. Organization & website markup should not be duplicate )
  • Improvement: Show the fields of review schema type according to selected Item Reviewed Type
  • Bug Fixed: Product schema is not getting feature image/product image when WooCommerce compatibility is enable #122
  • Bug Fixed: Missing escaping, Warnings and Notices fixed
  • Bug Fixed: Google is requiring 1200 pixel wide feature images #131
Download this release

Release Info

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

Code changes from version 1.0.7.1 to 1.0.8

admin_section/add-schema/add_new.php CHANGED
@@ -8,14 +8,15 @@ add_action( 'admin_menu', 'saswp_add_new_data_menu' );
8
  add_action( 'admin_init', 'saswp_add_new_init');
9
  add_action( 'admin_footer', 'saswp_add_new_svg_sprite');
10
  add_action( 'wp_ajax_saswp_add_new_save_steps_data', 'saswp_add_new_save_steps_data', 10, 0 );
 
11
  $saswp_add_data_type_config = array(
12
  'installer_dir' => 'admin_section',
13
  'plugin_title' => esc_html__( ucfirst( 'Schema & Structured Data for WP' ), 'schema-and-structured-data-for-wp'),
14
- 'start_steps' => 1,
15
- 'total_steps' => 3,
16
  'installerpage' => 'saswp_add_new_data_type',
17
- 'dev_mode' => false,
18
- 'steps' => array(
19
  1=>array(
20
  'title'=>esc_html__('Select Schema', 'schema-and-structured-data-for-wp'),
21
  'description'=>esc_html__('Where would you like to enable the schema?','schema-and-structured-data-for-wp'),
@@ -33,13 +34,14 @@ $saswp_add_data_type_config = array(
33
  ),
34
 
35
  ),
36
- 'current_step'=>array(
37
  'title'=>'',
38
  'step_id'=>1
39
  )
40
  );
41
 
42
  function saswp_add_new_data_menu(){
 
43
  saswp_add_new_init();
44
 
45
  }
@@ -50,18 +52,26 @@ $saswp_add_data_type_config = array(
50
  return ;
51
  }
52
  if(!isset($_GET['_wpnonce'])){
 
53
  return ;
 
54
  }else{
 
55
  $wp_nonce = $_GET['_wpnonce'];
56
  if( wp_verify_nonce($wp_nonce, '_wpnonce')){
57
- saswp_add_new_steps_call();
58
- }
 
 
 
59
  }
60
 
61
  }
62
 
63
  function saswp_add_new_steps_call(){
 
64
  global $saswp_add_data_type_config;
 
65
  if ( !wp_verify_nonce($_GET['_wpnonce'], '_wpnonce') ||empty( $_GET['page'] ) || $saswp_add_data_type_config['installerpage'] !== $_GET['page'] ) {
66
  return;
67
  }
@@ -74,9 +84,9 @@ $saswp_add_data_type_config = array(
74
 
75
  // Use minified libraries if dev mode is turned on.
76
  $suffix = '';
77
- wp_enqueue_media ();
78
-
79
 
 
 
80
  // Enqueue styles.
81
  wp_enqueue_style( 'saswp-timepicker-js', SASWP_PLUGIN_URL. $saswp_add_data_type_config['installer_dir']. '/css/jquery.timepicker' . $suffix . '.css' , array( 'wp-admin' ), '0.1');
82
  // Enqueue javascript.
@@ -139,18 +149,27 @@ $saswp_add_data_type_config = array(
139
  }
140
 
141
  function saswp_add_new_show_steps_body(){
 
142
  global $saswp_add_data_type_config;
 
143
  if($saswp_add_data_type_config['total_steps']==$saswp_add_data_type_config['current_step']['step_id']){
144
- call_user_func('saswp_add_new_finish_page');
 
 
145
  }else{
146
  if(function_exists('saswp_add_new_step'.$saswp_add_data_type_config['current_step']['step_id'])){
 
147
  call_user_func('saswp_add_new_step'.$saswp_add_data_type_config['current_step']['step_id']);
 
148
  }else{
 
149
  call_user_func('saswp_add_new_finish_page');
 
150
  }
151
  }
152
  }
153
  function saswp_add_new_header() {
 
154
  global $saswp_installer_config;
155
 
156
  // Get the current step.
@@ -173,6 +192,7 @@ $saswp_add_data_type_config = array(
173
 
174
 
175
  function saswp_add_new_step1(){
 
176
  global $saswp_add_data_type_config;
177
  $stepDetails = $saswp_add_data_type_config['steps'][$saswp_add_data_type_config['current_step']['step_id']];
178
  ?>
@@ -222,6 +242,7 @@ $saswp_add_data_type_config = array(
222
  }
223
 
224
  function saswp_add_new_step2(){
 
225
  global $saswp_add_data_type_config;
226
  $stepDetails = $saswp_add_data_type_config['steps'][$saswp_add_data_type_config['current_step']['step_id']];
227
  ?>
@@ -284,6 +305,7 @@ $saswp_add_data_type_config = array(
284
 
285
 
286
  function saswp_add_new_step3(){
 
287
  global $saswp_add_data_type_config;
288
  $stepDetails = $saswp_add_data_type_config['steps'][$saswp_add_data_type_config['current_step']['step_id']];
289
  ?>
@@ -330,18 +352,24 @@ $saswp_add_data_type_config = array(
330
 
331
 
332
  function saswp_add_new_save_steps_data(){
 
333
  if ( ! isset( $_POST['wpnonce'] ) ){
334
  return;
335
  }
336
  if ( !wp_verify_nonce( $_POST['wpnonce'], 'saswp_add_new_nonce' ) ){
337
  return;
338
  }
339
- if(isset($_POST['schema_type'])){
340
- $schema_type = $_POST['schema_type'];
 
 
341
  if($schema_type == 'local_business'){
342
- $schema_type = 'Local Business';
 
 
343
  }
344
  $user_id = get_current_user_id();
 
345
  $schema_post = array(
346
  'post_author' => $user_id,
347
  'post_date' => date("Y-m-d"),
@@ -349,31 +377,45 @@ $saswp_add_data_type_config = array(
349
  'post_status' => 'publish',
350
  'post_name' => ucfirst($schema_type),
351
  'post_type' => 'saswp',
352
- );
 
353
  $post_id = wp_insert_post($schema_post);
354
 
355
  set_transient('saswp_last_post_id', json_encode(array('post_id'=>$post_id)));
 
356
  }
357
 
358
  if(isset($_POST['data_group_array']) && isset($_POST['saswp_post_id'])){
359
- $post_id = sanitize_text_field($_POST['saswp_post_id']);
360
- $post_data_group_array = array();
361
- $temp_condition_array = array();
362
- $show_globally =false;
363
- $post_data_group_array = $_POST['data_group_array'];
364
- foreach($post_data_group_array as $groups){
365
- foreach($groups['data_array'] as $group ){
 
 
 
 
366
  if(array_search('show_globally', $group))
367
  {
 
368
  $temp_condition_array[0] = $group;
369
- $show_globally = true;
 
370
  }
 
371
  }
372
  }
 
373
  if($show_globally){
 
374
  unset($post_data_group_array);
375
- $post_data_group_array['group-0']['data_array'] = $temp_condition_array;
376
- }
 
 
 
377
  update_post_meta(
378
  $post_id,
379
  'data_group_array',
@@ -418,7 +460,7 @@ $saswp_add_data_type_config = array(
418
 
419
  <div class="saswp_branding"></div>
420
 
421
- <h1><?php echo esc_html( 'Schema Added Successfully. Have fun!' ); ?></h1>
422
 
423
  </div>
424
 
@@ -434,7 +476,7 @@ $saswp_add_data_type_config = array(
434
  }
435
  ?>
436
 
437
- <a href="<?php echo $lets_go; ?>" class="merlin__button merlin__button--blue merlin__button--fullwidth merlin__button--popin"><?php echo esc_html( 'Let\'s Go' ); ?></a>
438
 
439
 
440
  <ul class="merlin__drawer merlin__drawer--extras">
@@ -512,12 +554,12 @@ $saswp_add_data_type_config = array(
512
  function saswp_add_new_makesvg( $args = array() ){
513
  // Make sure $args are an array.
514
  if ( empty( $args ) ) {
515
- return __( 'Please define default parameters in the form of an array.', 'accelerated-mobile-pages' );
516
  }
517
 
518
  // Define an icon.
519
  if ( false === array_key_exists( 'icon', $args ) ) {
520
- return __( 'Please define an SVG icon filename.', 'accelerated-mobile-pages' );
521
  }
522
 
523
  // Set defaults.
@@ -551,12 +593,12 @@ $saswp_add_data_type_config = array(
551
 
552
  // If there is a title, display it.
553
  if ( $args['title'] ) {
554
- $svg .= '<title>' . esc_html( $args['title'] ) . '</title>';
555
  }
556
 
557
  // If there is a description, display it.
558
  if ( $args['desc'] ) {
559
- $svg .= '<desc>' . esc_html( $args['desc'] ) . '</desc>';
560
  }
561
 
562
  $svg .= '<use xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use>';
8
  add_action( 'admin_init', 'saswp_add_new_init');
9
  add_action( 'admin_footer', 'saswp_add_new_svg_sprite');
10
  add_action( 'wp_ajax_saswp_add_new_save_steps_data', 'saswp_add_new_save_steps_data', 10, 0 );
11
+
12
  $saswp_add_data_type_config = array(
13
  'installer_dir' => 'admin_section',
14
  'plugin_title' => esc_html__( ucfirst( 'Schema & Structured Data for WP' ), 'schema-and-structured-data-for-wp'),
15
+ 'start_steps' => 1,
16
+ 'total_steps' => 3,
17
  'installerpage' => 'saswp_add_new_data_type',
18
+ 'dev_mode' => false,
19
+ 'steps' => array(
20
  1=>array(
21
  'title'=>esc_html__('Select Schema', 'schema-and-structured-data-for-wp'),
22
  'description'=>esc_html__('Where would you like to enable the schema?','schema-and-structured-data-for-wp'),
34
  ),
35
 
36
  ),
37
+ 'current_step' =>array(
38
  'title'=>'',
39
  'step_id'=>1
40
  )
41
  );
42
 
43
  function saswp_add_new_data_menu(){
44
+
45
  saswp_add_new_init();
46
 
47
  }
52
  return ;
53
  }
54
  if(!isset($_GET['_wpnonce'])){
55
+
56
  return ;
57
+
58
  }else{
59
+
60
  $wp_nonce = $_GET['_wpnonce'];
61
  if( wp_verify_nonce($wp_nonce, '_wpnonce')){
62
+
63
+ saswp_add_new_steps_call();
64
+
65
+ }
66
+
67
  }
68
 
69
  }
70
 
71
  function saswp_add_new_steps_call(){
72
+
73
  global $saswp_add_data_type_config;
74
+
75
  if ( !wp_verify_nonce($_GET['_wpnonce'], '_wpnonce') ||empty( $_GET['page'] ) || $saswp_add_data_type_config['installerpage'] !== $_GET['page'] ) {
76
  return;
77
  }
84
 
85
  // Use minified libraries if dev mode is turned on.
86
  $suffix = '';
 
 
87
 
88
+ wp_enqueue_media ();
89
+
90
  // Enqueue styles.
91
  wp_enqueue_style( 'saswp-timepicker-js', SASWP_PLUGIN_URL. $saswp_add_data_type_config['installer_dir']. '/css/jquery.timepicker' . $suffix . '.css' , array( 'wp-admin' ), '0.1');
92
  // Enqueue javascript.
149
  }
150
 
151
  function saswp_add_new_show_steps_body(){
152
+
153
  global $saswp_add_data_type_config;
154
+
155
  if($saswp_add_data_type_config['total_steps']==$saswp_add_data_type_config['current_step']['step_id']){
156
+
157
+ call_user_func('saswp_add_new_finish_page');
158
+
159
  }else{
160
  if(function_exists('saswp_add_new_step'.$saswp_add_data_type_config['current_step']['step_id'])){
161
+
162
  call_user_func('saswp_add_new_step'.$saswp_add_data_type_config['current_step']['step_id']);
163
+
164
  }else{
165
+
166
  call_user_func('saswp_add_new_finish_page');
167
+
168
  }
169
  }
170
  }
171
  function saswp_add_new_header() {
172
+
173
  global $saswp_installer_config;
174
 
175
  // Get the current step.
192
 
193
 
194
  function saswp_add_new_step1(){
195
+
196
  global $saswp_add_data_type_config;
197
  $stepDetails = $saswp_add_data_type_config['steps'][$saswp_add_data_type_config['current_step']['step_id']];
198
  ?>
242
  }
243
 
244
  function saswp_add_new_step2(){
245
+
246
  global $saswp_add_data_type_config;
247
  $stepDetails = $saswp_add_data_type_config['steps'][$saswp_add_data_type_config['current_step']['step_id']];
248
  ?>
305
 
306
 
307
  function saswp_add_new_step3(){
308
+
309
  global $saswp_add_data_type_config;
310
  $stepDetails = $saswp_add_data_type_config['steps'][$saswp_add_data_type_config['current_step']['step_id']];
311
  ?>
352
 
353
 
354
  function saswp_add_new_save_steps_data(){
355
+
356
  if ( ! isset( $_POST['wpnonce'] ) ){
357
  return;
358
  }
359
  if ( !wp_verify_nonce( $_POST['wpnonce'], 'saswp_add_new_nonce' ) ){
360
  return;
361
  }
362
+ if(isset($_POST['schema_type'])){
363
+
364
+ $schema_type = $_POST['schema_type'];
365
+
366
  if($schema_type == 'local_business'){
367
+
368
+ $schema_type = 'Local Business';
369
+
370
  }
371
  $user_id = get_current_user_id();
372
+
373
  $schema_post = array(
374
  'post_author' => $user_id,
375
  'post_date' => date("Y-m-d"),
377
  'post_status' => 'publish',
378
  'post_name' => ucfirst($schema_type),
379
  'post_type' => 'saswp',
380
+ );
381
+
382
  $post_id = wp_insert_post($schema_post);
383
 
384
  set_transient('saswp_last_post_id', json_encode(array('post_id'=>$post_id)));
385
+
386
  }
387
 
388
  if(isset($_POST['data_group_array']) && isset($_POST['saswp_post_id'])){
389
+
390
+ $post_id = sanitize_text_field($_POST['saswp_post_id']);
391
+ $post_data_group_array = array();
392
+ $temp_condition_array = array();
393
+ $show_globally = false;
394
+ $post_data_group_array = $_POST['data_group_array'];
395
+
396
+ foreach($post_data_group_array as $groups){
397
+
398
+ foreach($groups['data_array'] as $group ){
399
+
400
  if(array_search('show_globally', $group))
401
  {
402
+
403
  $temp_condition_array[0] = $group;
404
+ $show_globally = true;
405
+
406
  }
407
+
408
  }
409
  }
410
+
411
  if($show_globally){
412
+
413
  unset($post_data_group_array);
414
+
415
+ $post_data_group_array['group-0']['data_array'] = $temp_condition_array;
416
+
417
+ }
418
+
419
  update_post_meta(
420
  $post_id,
421
  'data_group_array',
460
 
461
  <div class="saswp_branding"></div>
462
 
463
+ <h1><?php echo esc_html__( 'Schema Added Successfully. Have fun!', 'schema-and-structured-data-for-wp' ); ?></h1>
464
 
465
  </div>
466
 
476
  }
477
  ?>
478
 
479
+ <a href="<?php echo $lets_go; ?>" class="merlin__button merlin__button--blue merlin__button--fullwidth merlin__button--popin"><?php echo esc_html__( 'Let\'s Go', 'schema-and-structured-data-for-wp' ); ?></a>
480
 
481
 
482
  <ul class="merlin__drawer merlin__drawer--extras">
554
  function saswp_add_new_makesvg( $args = array() ){
555
  // Make sure $args are an array.
556
  if ( empty( $args ) ) {
557
+ return __( 'Please define default parameters in the form of an array.', 'schema-and-structured-data-for-wp' );
558
  }
559
 
560
  // Define an icon.
561
  if ( false === array_key_exists( 'icon', $args ) ) {
562
+ return __( 'Please define an SVG icon filename.', 'schema-and-structured-data-for-wp' );
563
  }
564
 
565
  // Set defaults.
593
 
594
  // If there is a title, display it.
595
  if ( $args['title'] ) {
596
+ $svg .= '<title>' . esc_html__( $args['title'], 'schema-and-structured-data-for-wp' ) . '</title>';
597
  }
598
 
599
  // If there is a description, display it.
600
  if ( $args['desc'] ) {
601
+ $svg .= '<desc>' . esc_html__( $args['desc'], 'schema-and-structured-data-for-wp' ) . '</desc>';
602
  }
603
 
604
  $svg .= '<use xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use>';
admin_section/ajax-selectbox.php CHANGED
@@ -4,8 +4,11 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
4
 
5
  $response = $data;
6
  $is_ajax = false;
 
7
  if( $_SERVER['REQUEST_METHOD']=='POST'){
 
8
  $is_ajax = true;
 
9
  if(wp_verify_nonce($_POST["saswp_call_nonce"],'saswp_select_action_nonce')){
10
 
11
  if ( isset( $_POST["id"] ) ) {
@@ -17,8 +20,11 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
17
  if ( isset( $_POST["group_number"] ) ) {
18
  $current_group_number = intval($_POST["group_number"]);
19
  }
 
20
  }else{
 
21
  exit;
 
22
  }
23
 
24
  }
@@ -39,13 +45,16 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
39
 
40
  $choices = saswp_post_type_generator();
41
 
42
- $choices = apply_filters('saswp_modify_select_post_type', $choices );
 
43
  unset($choices['saswp']);
 
44
  break;
45
 
46
  case "page":
47
 
48
  $post_type = 'page';
 
49
  $posts = get_posts(array(
50
  'posts_per_page' => -1,
51
  'post_type' => $post_type,
@@ -118,10 +127,12 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
118
  {
119
 
120
  $posts = get_posts(array(
121
- 'numberposts' => '-1',
122
- 'post_type' => $post_type,
123
- 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
124
- 'suppress_filters' => false,
 
 
125
  ));
126
 
127
  if( $posts)
@@ -175,7 +186,9 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
175
  break;
176
 
177
  case "user_type" :
178
- global $wp_roles;
 
 
179
  $choices = $wp_roles->get_names();
180
 
181
  if( is_multisite() )
@@ -187,9 +200,10 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
187
 
188
  case "ef_taxonomy" :
189
 
190
- $choices = array('all' => esc_html__('All','schema-and-structured-data-for-wp'));
191
  $taxonomies = saswp_post_taxonomy_generator();
192
- $choices = array_merge($choices, $taxonomies);
 
193
  break;
194
 
195
  }
@@ -200,19 +214,25 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
200
  if ( empty( $choices) ) {
201
  $choices = array('none' => esc_html__('No Items', 'schema-and-structured-data-for-wp') );
202
  }
203
- // echo $current_number;
204
- // echo $saved_data;
205
 
206
  $output = '<select class="widefat ajax-output" name="data_group_array[group-'.esc_attr($current_group_number).'][data_array]['. esc_attr($current_number) .'][key_3]">';
207
 
208
  // Generate Options for Posts
209
  if ( $options['param'] == 'post' ) {
210
- foreach ($choices as $choice_post_type) {
 
 
211
  foreach ($choice_post_type as $key => $value) {
 
212
  if ( $saved_data == $key ) {
 
213
  $selected = 'selected="selected"';
 
214
  } else {
 
215
  $selected = '';
 
216
  }
217
 
218
  $output .= '<option '. esc_attr($selected) .' value="' . esc_attr($key) .'"> ' . esc_html__($value, 'schema-and-structured-data-for-wp') .' </option>';
@@ -220,17 +240,24 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
220
  }
221
  // Options for Other then posts
222
  } else {
 
223
  foreach ($choices as $key => $value) {
 
224
  if ( $saved_data == $key ) {
 
225
  $selected = 'selected="selected"';
 
226
  } else {
 
227
  $selected = '';
 
228
  }
229
 
230
  $output .= '<option '. esc_attr($selected) .' value="' . esc_attr($key) .'"> ' . esc_html__($value, 'schema-and-structured-data-for-wp') .' </option>';
231
  }
232
  }
233
- $output .= ' </select> ';
 
234
  $allowed_html = saswp_expanded_allowed_tags();
235
  echo wp_kses($output, $allowed_html);
236
 
@@ -242,62 +269,93 @@ function saswp_ajax_select_creator($data = '', $saved_data= '', $current_number
242
  }
243
  // Generate Proper Post Taxonomy for select and to add data.
244
  function saswp_post_taxonomy_generator(){
 
245
  $taxonomies = '';
246
  $choices = array();
247
  $taxonomies = get_taxonomies( array('public' => true), 'objects' );
248
 
249
-
250
  foreach($taxonomies as $taxonomy) {
 
251
  $choices[ $taxonomy->name ] = $taxonomy->labels->name;
 
252
  }
253
 
254
  // unset post_format (why is this a public taxonomy?)
255
  if( isset($choices['post_format']) ) {
 
256
  unset( $choices['post_format']) ;
 
257
  }
258
 
259
  return $choices;
260
  }
 
261
  add_action('wp_ajax_create_ajax_select_sdwp_taxonomy','saswp_create_ajax_select_taxonomy');
262
 
263
  function saswp_create_ajax_select_taxonomy($selectedParentValue = '',$selectedValue='', $current_number ='', $current_group_number = ''){
 
264
  $is_ajax = false;
 
265
  if( $_SERVER['REQUEST_METHOD']=='POST'){
 
266
  $is_ajax = true;
 
267
  if(wp_verify_nonce($_POST["saswp_call_nonce"],'saswp_select_action_nonce')){
 
268
  if(isset($_POST['id'])){
 
269
  $selectedParentValue = sanitize_text_field(wp_unslash($_POST['id']));
 
270
  }
271
  if(isset($_POST['number'])){
 
272
  $current_number = intval($_POST['number']);
 
273
  }
274
  if ( isset( $_POST["group_number"] ) ) {
 
275
  $current_group_number = intval($_POST["group_number"]);
 
276
  }
277
  }else{
 
278
  exit;
 
279
  }
280
  }
281
  $taxonomies = array();
 
282
  if($selectedParentValue == 'all'){
 
283
  $taxonomies = get_terms( array(
284
  'hide_empty' => true,
285
- ) );
 
286
  }else{
 
287
  $taxonomies = get_terms($selectedParentValue, array(
288
  'hide_empty' => true,
289
  ) );
290
  }
 
291
  $choices = '<option value="all">'.esc_html__('All','schema-and-structured-data-for-wp').'</option>';
 
292
  foreach($taxonomies as $taxonomy) {
 
293
  $sel="";
 
294
  if($selectedValue == $taxonomy->slug){
 
295
  $sel = "selected";
 
296
  }
297
  $choices .= '<option value="'.esc_attr($taxonomy->slug).'" '.esc_attr($sel).'>'.esc_html__($taxonomy->name,'schema-and-structured-data-for-wp').'</option>';
298
  }
299
- $allowed_html = saswp_expanded_allowed_tags();
 
 
300
  echo '<select class="widefat ajax-output-child" name="data_group_array[group-'. esc_attr($current_group_number) .'][data_array]['.esc_attr($current_number).'][key_4]">'. wp_kses($choices, $allowed_html).'</select>';
 
301
  if($is_ajax){
302
  die;
303
  }
4
 
5
  $response = $data;
6
  $is_ajax = false;
7
+
8
  if( $_SERVER['REQUEST_METHOD']=='POST'){
9
+
10
  $is_ajax = true;
11
+
12
  if(wp_verify_nonce($_POST["saswp_call_nonce"],'saswp_select_action_nonce')){
13
 
14
  if ( isset( $_POST["id"] ) ) {
20
  if ( isset( $_POST["group_number"] ) ) {
21
  $current_group_number = intval($_POST["group_number"]);
22
  }
23
+
24
  }else{
25
+
26
  exit;
27
+
28
  }
29
 
30
  }
45
 
46
  $choices = saswp_post_type_generator();
47
 
48
+ $choices = apply_filters('saswp_modify_select_post_type', $choices );
49
+
50
  unset($choices['saswp']);
51
+
52
  break;
53
 
54
  case "page":
55
 
56
  $post_type = 'page';
57
+
58
  $posts = get_posts(array(
59
  'posts_per_page' => -1,
60
  'post_type' => $post_type,
127
  {
128
 
129
  $posts = get_posts(array(
130
+
131
+ 'numberposts' => '-1',
132
+ 'post_type' => $post_type,
133
+ 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
134
+ 'suppress_filters' => false,
135
+
136
  ));
137
 
138
  if( $posts)
186
  break;
187
 
188
  case "user_type" :
189
+
190
+ global $wp_roles;
191
+
192
  $choices = $wp_roles->get_names();
193
 
194
  if( is_multisite() )
200
 
201
  case "ef_taxonomy" :
202
 
203
+ $choices = array('all' => esc_html__('All','schema-and-structured-data-for-wp'));
204
  $taxonomies = saswp_post_taxonomy_generator();
205
+ $choices = array_merge($choices, $taxonomies);
206
+
207
  break;
208
 
209
  }
214
  if ( empty( $choices) ) {
215
  $choices = array('none' => esc_html__('No Items', 'schema-and-structured-data-for-wp') );
216
  }
217
+
 
218
 
219
  $output = '<select class="widefat ajax-output" name="data_group_array[group-'.esc_attr($current_group_number).'][data_array]['. esc_attr($current_number) .'][key_3]">';
220
 
221
  // Generate Options for Posts
222
  if ( $options['param'] == 'post' ) {
223
+
224
+ foreach ($choices as $choice_post_type) {
225
+
226
  foreach ($choice_post_type as $key => $value) {
227
+
228
  if ( $saved_data == $key ) {
229
+
230
  $selected = 'selected="selected"';
231
+
232
  } else {
233
+
234
  $selected = '';
235
+
236
  }
237
 
238
  $output .= '<option '. esc_attr($selected) .' value="' . esc_attr($key) .'"> ' . esc_html__($value, 'schema-and-structured-data-for-wp') .' </option>';
240
  }
241
  // Options for Other then posts
242
  } else {
243
+
244
  foreach ($choices as $key => $value) {
245
+
246
  if ( $saved_data == $key ) {
247
+
248
  $selected = 'selected="selected"';
249
+
250
  } else {
251
+
252
  $selected = '';
253
+
254
  }
255
 
256
  $output .= '<option '. esc_attr($selected) .' value="' . esc_attr($key) .'"> ' . esc_html__($value, 'schema-and-structured-data-for-wp') .' </option>';
257
  }
258
  }
259
+
260
+ $output .= ' </select> ';
261
  $allowed_html = saswp_expanded_allowed_tags();
262
  echo wp_kses($output, $allowed_html);
263
 
269
  }
270
  // Generate Proper Post Taxonomy for select and to add data.
271
  function saswp_post_taxonomy_generator(){
272
+
273
  $taxonomies = '';
274
  $choices = array();
275
  $taxonomies = get_taxonomies( array('public' => true), 'objects' );
276
 
 
277
  foreach($taxonomies as $taxonomy) {
278
+
279
  $choices[ $taxonomy->name ] = $taxonomy->labels->name;
280
+
281
  }
282
 
283
  // unset post_format (why is this a public taxonomy?)
284
  if( isset($choices['post_format']) ) {
285
+
286
  unset( $choices['post_format']) ;
287
+
288
  }
289
 
290
  return $choices;
291
  }
292
+
293
  add_action('wp_ajax_create_ajax_select_sdwp_taxonomy','saswp_create_ajax_select_taxonomy');
294
 
295
  function saswp_create_ajax_select_taxonomy($selectedParentValue = '',$selectedValue='', $current_number ='', $current_group_number = ''){
296
+
297
  $is_ajax = false;
298
+
299
  if( $_SERVER['REQUEST_METHOD']=='POST'){
300
+
301
  $is_ajax = true;
302
+
303
  if(wp_verify_nonce($_POST["saswp_call_nonce"],'saswp_select_action_nonce')){
304
+
305
  if(isset($_POST['id'])){
306
+
307
  $selectedParentValue = sanitize_text_field(wp_unslash($_POST['id']));
308
+
309
  }
310
  if(isset($_POST['number'])){
311
+
312
  $current_number = intval($_POST['number']);
313
+
314
  }
315
  if ( isset( $_POST["group_number"] ) ) {
316
+
317
  $current_group_number = intval($_POST["group_number"]);
318
+
319
  }
320
  }else{
321
+
322
  exit;
323
+
324
  }
325
  }
326
  $taxonomies = array();
327
+
328
  if($selectedParentValue == 'all'){
329
+
330
  $taxonomies = get_terms( array(
331
  'hide_empty' => true,
332
+ ) );
333
+
334
  }else{
335
+
336
  $taxonomies = get_terms($selectedParentValue, array(
337
  'hide_empty' => true,
338
  ) );
339
  }
340
+
341
  $choices = '<option value="all">'.esc_html__('All','schema-and-structured-data-for-wp').'</option>';
342
+
343
  foreach($taxonomies as $taxonomy) {
344
+
345
  $sel="";
346
+
347
  if($selectedValue == $taxonomy->slug){
348
+
349
  $sel = "selected";
350
+
351
  }
352
  $choices .= '<option value="'.esc_attr($taxonomy->slug).'" '.esc_attr($sel).'>'.esc_html__($taxonomy->name,'schema-and-structured-data-for-wp').'</option>';
353
  }
354
+
355
+ $allowed_html = saswp_expanded_allowed_tags();
356
+
357
  echo '<select class="widefat ajax-output-child" name="data_group_array[group-'. esc_attr($current_group_number) .'][data_array]['.esc_attr($current_number).'][key_4]">'. wp_kses($choices, $allowed_html).'</select>';
358
+
359
  if($is_ajax){
360
  die;
361
  }
admin_section/common-function.php CHANGED
@@ -7,23 +7,30 @@
7
  */
8
  add_action('admin_init', 'saswp_import_all_settings_and_schema',9);
9
  function saswp_import_all_settings_and_schema(){
10
- $url = get_option('saswp-file-upload_url');
 
11
  global $wpdb;
12
  $result ='';
 
13
  if($url){
14
- $json_data = file_get_contents($url);
15
- $json_array = json_decode($json_data, true);
 
16
  $all_schema_post = $json_array['posts'];
17
 
18
- $sd_data = $json_array['sd_data'];
19
  $schema_post = array();
 
 
20
  if($all_schema_post){
21
  // begin transaction
22
  $wpdb->query('START TRANSACTION');
23
- foreach($all_schema_post as $schema_post){
 
 
24
  $post_id = wp_insert_post($schema_post['post']);
25
- $result = $post_id;
26
- $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
27
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
28
 
29
  if ( isset( $schema_post['schema_type'] ) ){
@@ -64,59 +71,71 @@
64
  * @global type $wpdb
65
  * @return boolean
66
  */
67
- function saswp_export_all_settings_and_schema(){
68
- $export_data = array();
 
69
  $export_data_all = array();
70
- $schema_post = array();
71
- $user_id = get_current_user_id();
 
72
  $all_schema_post = get_posts(
 
73
  array(
74
  'post_type' => 'saswp',
75
- 'posts_per_page' => -1,
76
- 'post_status' => 'any',
77
  )
78
- );
79
- if($all_schema_post){
 
 
 
80
  foreach($all_schema_post as $schema){
81
 
82
- $schema_post = array(
83
- 'post_author' => $user_id,
84
- 'post_date' => $schema->post_date,
85
- 'post_date_gmt' => $schema->post_date_gmt,
86
- 'post_content' => $schema->post_content,
87
- 'post_title' => $schema->post_title,
88
- 'post_excerpt' => $schema->post_excerpt,
89
- 'post_status' => $schema->post_status,
90
- 'comment_status' => $schema->comment_status,
91
- 'ping_status' => $schema->ping_status,
92
- 'post_password' => $schema->post_password,
93
- 'post_name' => $schema->post_name,
94
- 'to_ping' => $schema->to_ping,
95
- 'pinged' => $schema->pinged,
96
- 'post_modified' => $schema->post_modified,
97
- 'post_modified_gmt' => $schema->post_modified_gmt,
 
98
  'post_content_filtered' => $schema->post_content_filtered,
99
- 'post_parent' => $schema->post_parent,
100
- 'menu_order' => $schema->menu_order,
101
- 'post_type' => 'saswp',
102
- 'post_mime_type' => $schema->post_mime_type,
103
- 'comment_count' => $schema->comment_count,
104
- 'filter' => $schema->filter,
 
105
  );
 
106
  $export_data[$schema->ID]['post'] = $schema_post;
107
 
108
- $post_meta = get_post_meta($schema->ID, $key='', true );
109
- $schema_type = $post_meta['schema_type'][0];
110
- $local_business_type = $post_meta['saswp_business_type'][0];
111
- $local_business_sub_type = $post_meta['saswp_business_name'][0];
112
- $data_group_array = get_post_meta($schema->ID, $key='data_group_array', true );
113
- $local_business_details = get_post_meta($schema->ID, $key='saswp_local_business_details', true );
114
 
115
 
116
- $export_data[$schema->ID]['schema_type'] = $schema_type;
117
- $export_data[$schema->ID]['saswp_business_type'] = $local_business_type;
118
- $export_data[$schema->ID]['saswp_business_name'] = $local_business_sub_type;
119
- $export_data[$schema->ID]['data_group_array'] = $data_group_array;
 
 
 
 
120
  $export_data[$schema->ID]['saswp_local_business_details'] = $local_business_details;
121
  }
122
 
@@ -125,11 +144,14 @@
125
  $export_data_all['sd_data'] =$get_sd_data;
126
  header('Content-type: application/json');
127
  header('Content-disposition: attachment; filename=structuredatabackup.json');
128
- echo json_encode($export_data_all);
 
129
  }else{
 
130
  header('Content-type: application/json');
131
  header('Content-disposition: attachment; filename=structuredatabackup.json');
132
- echo json_encode(array('message'=> 'Data is not available'));
 
133
  }
134
  wp_die();
135
  }
@@ -144,7 +166,8 @@
144
 
145
  $schema_post = array();
146
  global $wpdb;
147
- $user_id = get_current_user_id();
 
148
  $all_schema_post = get_posts(
149
  array(
150
  'post_type' => 'schema',
@@ -152,45 +175,49 @@
152
  'post_status' => 'any',
153
  )
154
  );
 
155
  if($all_schema_post){
156
  // begin transaction
157
  $wpdb->query('START TRANSACTION');
158
  foreach($all_schema_post as $schema){
159
 
160
  $schema_post = array(
161
- 'post_author' => $user_id,
162
- 'post_date' => $schema->post_date,
163
- 'post_date_gmt' => $schema->post_date_gmt,
164
- 'post_content' => $schema->post_content,
165
- 'post_title' => $schema->post_title. ' (Migrated from Schema plugin)',
166
- 'post_excerpt' => $schema->post_excerpt,
167
- 'post_status' => $schema->post_status,
168
- 'comment_status' => $schema->comment_status,
169
- 'ping_status' => $schema->ping_status,
170
- 'post_password' => $schema->post_password,
171
- 'post_name' => $schema->post_name,
172
- 'to_ping' => $schema->to_ping,
173
- 'pinged' => $schema->pinged,
174
- 'post_modified' => $schema->post_modified,
175
- 'post_modified_gmt' => $schema->post_modified_gmt,
 
176
  'post_content_filtered' => $schema->post_content_filtered,
177
- 'post_parent' => $schema->post_parent,
178
- 'menu_order' => $schema->menu_order,
179
- 'post_type' => 'saswp',
180
- 'post_mime_type' => $schema->post_mime_type,
181
- 'comment_count' => $schema->comment_count,
182
- 'filter' => $schema->filter,
 
183
  );
184
  $post_id = wp_insert_post($schema_post);
185
- $result = $post_id;
186
- $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
187
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
188
 
189
- $schema_post_meta = get_post_meta($schema->ID, $key='', true );
190
- $schema_post_types = get_post_meta($schema->ID, $key='_schema_post_types', true );
191
- $schema_post_meta_box = get_post_meta($schema->ID, $key='_schema_post_meta_box', true );
192
 
193
  $data_group_array = array();
 
194
  if($schema_post_types){
195
 
196
  $i=0;
@@ -209,7 +236,7 @@
209
 
210
  }
211
  }
212
- $schema_type ='';
213
  $schema_article_type ='';
214
 
215
  if(isset($schema_post_meta['_schema_type'])){
@@ -232,8 +259,8 @@
232
  //Importing settings starts here
233
 
234
  $schema_plugin_options = get_option('schema_wp_settings');
235
- $custom_logo_id = get_theme_mod( 'custom_logo' );
236
- $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
237
 
238
  $saswp_plugin_options = array(
239
  'sd_logo' => array(
@@ -344,9 +371,11 @@
344
  $settings = WPPostsRateKeys_Settings::get_options();
345
 
346
  if(isset($settings['seop_home_social'])){
 
347
  foreach($settings['seop_home_social'] as $social){
348
 
349
  switch ($social['social_type']) {
 
350
  case 'Facebook':
351
 
352
  $social_fields['saswp-facebook-enable'] = 1;
@@ -396,7 +425,9 @@
396
  }
397
 
398
  if(isset($settings['seop_operating_hour'])){
 
399
  $hours = $settings['seop_operating_hour'];
 
400
  if(isset($hours['Mo'])){
401
  $opening_hours .='Mo-Mo'.' '.$hours['Mo']['from'].'-'.$hours['Mo']['to'].' ';
402
  }
@@ -421,24 +452,30 @@
421
  }
422
 
423
 
424
- if(isset($settings)){
 
425
  $local_business_details = array();
426
  $wpdb->query('START TRANSACTION');
427
 
428
  $user_id = get_current_user_id();
429
 
430
- if($settings['seop_local_name'] !=''){
 
431
  $schema_post = array(
432
  'post_author' => $user_id,
433
  'post_status' => 'publish',
434
- 'post_type' => 'saswp',
435
- );
 
436
  $schema_post['post_title'] = 'Organization (Migrated from SEO Pressor)';
437
 
438
  if(isset($settings['seop_local_name'])){
439
- $schema_post['post_title'] = $settings['seop_local_name'].'(Migrated from WP SEO Plugin)';
 
 
440
  }
441
  if(isset($settings['seop_home_logo'])){
 
442
  $image_details = wp_get_attachment_image_src($settings['seop_home_logo'], 'full');
443
 
444
  $local_business_details['local_business_logo'] = array(
@@ -467,11 +504,12 @@
467
  $local_business_details['local_street_address'] = $settings['seop_local_address'];
468
  }
469
  $post_id = wp_insert_post($schema_post);
470
- $result = $post_id;
471
- $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
472
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
473
 
474
- $data_group_array = array();
 
475
  $data_group_array['group-0'] =array(
476
  'data_array' => array(
477
  array(
@@ -483,11 +521,11 @@
483
  );
484
 
485
  $saswp_meta_key = array(
486
- 'schema_type' => 'local_business',
487
- 'data_group_array'=>$data_group_array,
488
- 'imported_from' => 'wp_seo_schema',
489
- 'saswp_local_business_details' => $local_business_details,
490
- 'saswp_dayofweek' => $opening_hours,
491
  );
492
 
493
  foreach ($saswp_meta_key as $key => $val){
@@ -496,9 +534,9 @@
496
 
497
  }
498
 
499
- $get_options = get_option('sd_data');
500
  $merge_options = array_merge($get_options, $social_fields);
501
- $result = update_option('sd_data', $merge_options);
502
 
503
  if (is_wp_error($result) ){
504
  echo esc_attr($result->get_error_message());
@@ -511,12 +549,14 @@
511
  }
512
 
513
  function saswp_import_wp_seo_schema_plugin_data(){
 
514
  global $KcSeoWPSchema;
515
  global $wpdb;
516
  $settings = get_option($KcSeoWPSchema->options['settings']);
517
 
518
  if(isset($settings)){
519
- $saswp_plugin_options = array();
 
520
  $local_business_details = array();
521
  $wpdb->query('START TRANSACTION');
522
 
@@ -527,7 +567,7 @@
527
  $schema_post = array(
528
  'post_author' => $user_id,
529
  'post_status' => 'publish',
530
- 'post_type' => 'saswp',
531
  );
532
  $schema_post['post_title'] = 'Organization (Migrated from WP SEO Plugin)';
533
 
@@ -575,11 +615,12 @@
575
  }
576
 
577
  $post_id = wp_insert_post($schema_post);
578
- $result = $post_id;
579
- $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
580
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
581
 
582
- $data_group_array = array();
 
583
  $data_group_array['group-0'] =array(
584
  'data_array' => array(
585
  array(
@@ -591,10 +632,10 @@
591
  );
592
 
593
  $saswp_meta_key = array(
594
- 'schema_type' => 'local_business',
595
- 'data_group_array'=>$data_group_array,
596
- 'imported_from' => 'wp_seo_schema',
597
- 'saswp_local_business_details' => $local_business_details
598
  );
599
 
600
  foreach ($saswp_meta_key as $key => $val){
@@ -648,9 +689,9 @@
648
  if(isset($settings['siteurl'])){
649
  $saswp_plugin_options['sd_url'] = $settings['sitename'];
650
  }
651
- $get_options = get_option('sd_data');
652
  $merge_options = array_merge($get_options, $saswp_plugin_options);
653
- $result = update_option('sd_data', $merge_options);
654
 
655
  if (is_wp_error($result) ){
656
  echo esc_attr($result->get_error_message());
@@ -668,60 +709,65 @@
668
  $schema_post = array();
669
  global $wpdb;
670
  $user_id = get_current_user_id();
 
671
  $all_schema_post = get_posts(
672
  array(
673
  'post_type' => 'aiosrs-schema',
674
- 'posts_per_page' => -1,
675
- 'post_status' => 'any',
676
  )
677
- );
 
678
  if($all_schema_post){
679
  // begin transaction
680
  $wpdb->query('START TRANSACTION');
681
  foreach($all_schema_post as $schema){
682
 
683
  $schema_post = array(
684
- 'post_author' => $user_id,
685
- 'post_date' => $schema->post_date,
686
- 'post_date_gmt' => $schema->post_date_gmt,
687
- 'post_content' => $schema->post_content,
688
- 'post_title' => $schema->post_title. ' (Migrated from Schema_pro plugin)',
689
- 'post_excerpt' => $schema->post_excerpt,
690
- 'post_status' => $schema->post_status,
691
- 'comment_status' => $schema->comment_status,
692
- 'ping_status' => $schema->ping_status,
693
- 'post_password' => $schema->post_password,
694
- 'post_name' => $schema->post_name,
695
- 'to_ping' => $schema->to_ping,
696
- 'pinged' => $schema->pinged,
697
- 'post_modified' => $schema->post_modified,
698
- 'post_modified_gmt' => $schema->post_modified_gmt,
699
  'post_content_filtered' => $schema->post_content_filtered,
700
- 'post_parent' => $schema->post_parent,
701
- 'menu_order' => $schema->menu_order,
702
- 'post_type' => 'saswp',
703
- 'post_mime_type' => $schema->post_mime_type,
704
- 'comment_count' => $schema->comment_count,
705
- 'filter' => $schema->filter,
706
- );
 
707
  $post_id = wp_insert_post($schema_post);
708
- $result = $post_id;
709
- $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
710
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
711
 
712
- $schema_post_meta = get_post_meta($schema->ID, $key='', true );
713
-
714
- $schema_post_types = get_post_meta($schema->ID, $key='bsf-aiosrs-schema-type', true );
715
- $schema_post_meta_box = get_post_meta($schema->ID, $key='bsf-aiosrs-'.$schema_post_types, true );
716
- $schema_enable_location = get_post_meta($schema->ID, $key='bsf-aiosrs-schema-location', true );
717
- $schema_exclude_location = get_post_meta($schema->ID, $key='bsf-aiosrs-schema-exclusion', true );
718
 
719
  $data_array = array();
 
720
  if($schema_exclude_location){
721
 
722
  $exclude_rule = $schema_exclude_location['rule'];
723
  $fields = array_flip($exclude_rule);
 
724
  unset($fields['specifics']);
 
725
  $exclude_rule = array_flip($fields);
726
  $exclude_specific = $schema_exclude_location['specific'];
727
 
@@ -729,18 +775,22 @@
729
  foreach($exclude_rule as $rule){
730
 
731
  if($rule =='basic-singulars'){
 
732
  $data_array['data_array'][] =array(
733
  'key_1' => 'post_type',
734
  'key_2' => 'not_equal',
735
  'key_3' => 'post',
736
- );
 
737
  }else{
 
738
  $explode = explode("|", $rule);
739
  $data_array['data_array'][] =array(
740
  'key_1' => 'post_type',
741
  'key_2' => 'not_equal',
742
  'key_3' => $explode[0],
743
- );
 
744
  }
745
  }
746
 
@@ -752,29 +802,36 @@
752
 
753
  if($specific_post_name =='post'){
754
 
755
- $specific_post_type = get_post_type($specific_post_id);
 
756
  $data_array['data_array'][] =array(
757
  'key_1' => $specific_post_type,
758
  'key_2' => 'not_equal',
759
  'key_3' => $specific_post_id,
760
  );
 
761
  }
762
 
763
  if($specific_post_name =='tax'){
 
764
  $data_array['data_array'][] =array(
765
  'key_1' => 'post_category',
766
  'key_2' => 'not_equal',
767
  'key_3' => $specific_post_id,
768
  );
 
769
  }
770
 
771
  }
772
 
773
  $temp_data_array = $data_array['data_array'];
774
  $temp_two_array = $data_array['data_array'];
775
- $j =0;
 
776
  foreach($temp_two_array as $key => $val){
777
- $index =0;
 
 
778
  foreach($temp_data_array as $t=>$tval){
779
 
780
  if(($val['key_1'] == $tval['key_1']) && ($val['key_2'] == $tval['key_2']) && ($val['key_3'] == $tval['key_3'])){
@@ -790,40 +847,55 @@
790
  }
791
 
792
  $data_group_array = array();
 
793
  if($schema_enable_location){
 
794
  $enable_rule = $schema_enable_location['rule'];
795
- $fields = array_flip($enable_rule);
 
796
  unset($fields['specifics']);
797
- $enable_rule = array_flip($fields);
 
798
  $enable_specific = $schema_enable_location['specific'];
799
 
800
  $i=0;
801
  foreach ($enable_rule as $rule){
802
 
803
  if($rule =='basic-singulars'){
 
804
  $data_group_array['group-'.$i] =array(
 
805
  'data_array' => array(
806
  array(
807
  'key_1' => 'post_type',
808
  'key_2' => 'equal',
809
  'key_3' => 'post',
810
  )
811
- )
812
- );
 
 
813
  }else{
 
814
  $explode = explode("|", $rule);
 
815
  $data_group_array['group-'.$i] =array(
 
816
  'data_array' => array(
817
  array(
818
  'key_1' => 'post_type',
819
  'key_2' => 'equal',
820
  'key_3' => $explode[0],
821
  )
822
- )
823
- );
 
 
824
  }
825
  if(isset($data_array['data_array'])){
826
- $data_group_array['group-'.$i]['data_array'] = array_merge($data_group_array['group-'.$i]['data_array'],$data_array['data_array']);
 
 
827
  }
828
  $i++;
829
 
@@ -831,58 +903,74 @@
831
 
832
  foreach ($enable_specific as $rule){
833
 
834
- $explode = explode("-", $rule);
835
  $specific_post_name = $explode[0];
836
  $specific_post_id = $explode[1];
837
 
838
  if($specific_post_name =='post'){
839
 
840
- $specific_post_type = get_post_type($specific_post_id);
841
- $data_group_array['group-'.$i] =array(
842
- 'data_array' => array(
843
- array(
844
- 'key_1' => $specific_post_type,
845
- 'key_2' => 'equal',
846
- 'key_3' => $specific_post_id,
847
- )
848
- )
 
 
 
849
  );
850
  }
851
 
852
  if($specific_post_name =='tax'){
 
853
  $data_group_array['group-'.$i] =array(
854
- 'data_array' => array(
855
- array(
856
- 'key_1' => 'post_category',
857
- 'key_2' => 'equal',
858
- 'key_3' => $specific_post_id,
859
- )
860
- )
 
 
861
  );
 
862
  }
863
  if(isset($data_array['data_array'])){
864
- $data_group_array['group-'.$i]['data_array'] = array_merge($data_group_array['group-'.$i]['data_array'],$data_array['data_array']);
 
 
865
  }
866
 
867
  $i++;
868
 
869
  }
870
  }
871
- $schema_type ='';
872
- $local_name ='';
873
- $local_image ='';
874
- $local_phone ='';
875
- $local_url ='';
876
- $local_url ='';
 
877
  if(isset($schema_post_types)){
 
878
  $schema_type = ucfirst($schema_post_types);
879
 
 
880
  }
881
  if($schema_type =='Video-object'){
 
882
  $schema_type = 'VideoObject';
 
883
  }
884
  $local_business_details = array();
 
885
  if($schema_type =='Local-business'){
 
886
  $schema_type = 'local_business';
887
 
888
  if(isset($schema_post_meta_box['telephone'])){
@@ -891,7 +979,7 @@
891
  if(isset($schema_post_meta_box['image'])){
892
  $local_business_details['local_business_logo']['url'] = $schema_post_meta_box['image'];
893
  }
894
- if(isset($schema_post_meta_box['price-range'])){
895
  $local_business_details['local_price_range'] = $schema_post_meta_box['price-range'];
896
  }
897
  if(isset($schema_post_meta_box['location-postal'])){
@@ -908,40 +996,46 @@
908
  }
909
  }
910
  $saswp_meta_key = array(
911
- 'schema_type' => $schema_type,
912
- 'data_group_array'=>$data_group_array,
913
- 'imported_from' => 'schema_pro',
914
- 'saswp_local_business_details' => $local_business_details
 
 
915
  );
916
 
917
- foreach ($saswp_meta_key as $key => $val){
 
918
  update_post_meta($post_id, $key, $val);
919
- }
 
 
920
  }
921
  //Importing settings starts here
922
 
923
  $schema_pro_general_settings = get_option('wp-schema-pro-general-settings');
924
- $schema_pro_social_profile = get_option('wp-schema-pro-social-profiles');
925
- $schema_pro_global_schemas = get_option('wp-schema-pro-global-schemas');
926
- $schema_pro_settings = get_option('aiosrs-pro-settings');
927
-
928
- $logo = wp_get_attachment_image_src( $schema_pro_general_settings['site-logo-custom'] , 'full' );
929
 
930
- $saswp_plugin_options = array(
931
- 'sd_logo' => array(
932
- 'url' =>$logo[0],
933
- 'id' =>$schema_pro_general_settings['site-logo-custom'],
934
- 'height' =>$logo[1],
935
- 'width' =>$logo[2],
936
- 'thumbnail' =>$logo[0]
937
- ),
938
- 'saswp_kb_contact_1'=> 0,
 
 
939
  //AMP Block
940
- 'saswp-for-amp' => 1,
941
- 'saswp-for-wordpress'=>1,
942
- 'saswp-logo-width' => '60',
943
- 'saswp-logo-height' => '60',
944
- 'sd_initial_wizard_status' =>1,
945
 
946
  );
947
  if(isset($schema_pro_social_profile['facebook'])){
@@ -1089,6 +1183,7 @@ function saswp_expanded_allowed_tags() {
1089
  function saswp_admin_link($tab = '', $args = array()){
1090
 
1091
  $page = 'structured_data_options';
 
1092
  if ( ! is_multisite() ) {
1093
  $link = admin_url( 'admin.php?page=' . $page );
1094
  }
@@ -1122,21 +1217,29 @@ add_action('plugins_loaded', 'saswp_defaultSettings' );
1122
 
1123
  $sd_data=array();
1124
  function saswp_defaultSettings(){
 
1125
  global $sd_data;
1126
  $sd_name = 'default';
1127
  $bloginfo = get_bloginfo('name', 'display');
 
1128
  if($bloginfo){
 
1129
  $sd_name =$bloginfo;
1130
- }
1131
- $current_url = get_home_url();
 
 
1132
  $custom_logo_id = get_theme_mod( 'custom_logo' );
1133
- $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
1134
 
1135
- $user_id = get_current_user_id();
1136
- $username = '';
 
1137
  if($user_id>0){
 
1138
  $user_info = get_userdata($user_id);
1139
  $username = $user_info->data->display_name;
 
1140
  }
1141
  $defaults = array(
1142
  //General Block
@@ -1148,67 +1251,70 @@ function saswp_defaultSettings(){
1148
  'sd_alt_name' => $sd_name,
1149
  'sd_url' => $current_url,
1150
  'sd_logo' => array(
1151
- 'url' =>$logo[0],
1152
- 'id' =>$custom_logo_id,
1153
- 'height' =>$logo[2],
1154
- 'width' =>$logo[1],
1155
- 'thumbnail' =>$logo[0]
1156
  ),
1157
- 'sd-person-name' => $username,
1158
  'sd-person-job-title'=> '',
1159
- 'sd-person-url' => $current_url,
1160
- 'sd-person-image' => array(
1161
  'url' =>'',
1162
  'id' =>'',
1163
  'height' =>'',
1164
  'width' =>'',
1165
- 'thumbnail' =>'' ),
1166
- 'sd-person-phone-number'=> '',
1167
- 'saswp_kb_telephone'=> '',
1168
- 'saswp_contact_type'=> '',
1169
- 'saswp_kb_contact_1'=> 0,
 
1170
  //Social
1171
- 'sd_facebook'=> '',
1172
- 'sd_twitter'=> '',
1173
- 'sd_google_plus'=> '',
1174
- 'sd_instagram'=> '',
1175
- 'sd_youtube'=> '',
1176
- 'sd_linkedin'=> '',
1177
- 'sd_pinterest'=> '',
1178
- 'sd_soundcloud'=> '',
1179
- 'sd_tumblr'=> '',
1180
 
1181
 
1182
  'sd-data-logo-ampforwp' => array(
1183
- 'url'=>$logo[0],
1184
- 'id'=>$custom_logo_id,
1185
- 'height'=>$logo[2],
1186
- 'width'=>$logo[1],
1187
- 'thumbnail'=>$logo[0]
 
 
1188
  ),
1189
 
1190
  //AMP Block
1191
- 'saswp-for-amp' => 1,
1192
- 'saswp-for-wordpress'=>1,
1193
- 'saswp-logo-width' => '60',
1194
- 'saswp-logo-height' => '60',
1195
 
1196
  'sd_default_image' => array(
1197
- 'url'=>$logo[0],
1198
- 'id'=>$custom_logo_id,
1199
- 'height'=>$logo[2],
1200
- 'width'=>$logo[1],
1201
- 'thumbnail'=>$logo[0]
1202
  ),
1203
- 'sd_default_image_width' =>$logo[1],
1204
- 'sd_default_image_height' =>$logo[2],
1205
- 'sd_initial_wizard_status' =>1,
1206
-
1207
-
1208
 
1209
  );
1210
- $sd_data = $settings = get_option( 'sd_data', $defaults);
 
1211
  return $settings;
 
1212
  }
1213
  function saswp_frontend_enqueue(){
1214
  wp_enqueue_style( 'saswp-style', SASWP_PLUGIN_URL . 'admin_section/css/saswp-style.css', false , SASWP_VERSION );
@@ -1217,13 +1323,19 @@ function saswp_frontend_enqueue(){
1217
  add_action( 'wp_enqueue_scripts', 'saswp_frontend_enqueue' );
1218
 
1219
  function saswp_enque_amp_script(){
 
1220
  global $sd_data;
1221
  $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
 
1222
  $saswp_review_item_enable = 0;
 
1223
  if(isset($saswp_review_details['saswp-review-item-enable'])){
 
1224
  $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
1225
- }
1226
- if($sd_data['saswp-review-module']==1 && $saswp_review_item_enable ==1){
 
 
1227
  ?>
1228
  .saswp-pc-wrap{
1229
  background-color: #004f74;
@@ -1338,21 +1450,21 @@ function saswp_frontend_enqueue(){
1338
  width: 20px;
1339
  height: 16px;
1340
  background-repeat: no-repeat;
1341
- background-image: url(<?php echo SASWP_DIR_URI.'/admin_section/images/half_star.png'; ?>);
1342
  }
1343
  .saswp-rvw-str .str-ic{
1344
  display:inline-block;
1345
  width: 20px;
1346
  height: 16px;
1347
  background-repeat: no-repeat;
1348
- background-image: url(<?php echo SASWP_DIR_URI.'/admin_section/images/full_star.png'; ?>);
1349
  }
1350
  .saswp-rvw-str .df-clr{
1351
  display:inline-block;
1352
  width: 20px;
1353
  height: 16px;
1354
  background-repeat: no-repeat;
1355
- background-image: url(<?php echo SASWP_DIR_URI.'/admin_section/images/blank_star.png'; ?>);
1356
  }
1357
  @media(max-width:500px){
1358
  .saswp-pc-wrap{
7
  */
8
  add_action('admin_init', 'saswp_import_all_settings_and_schema',9);
9
  function saswp_import_all_settings_and_schema(){
10
+
11
+ $url = get_option('saswp-file-upload_url');
12
  global $wpdb;
13
  $result ='';
14
+
15
  if($url){
16
+
17
+ $json_data = file_get_contents($url);
18
+ $json_array = json_decode($json_data, true);
19
  $all_schema_post = $json_array['posts'];
20
 
21
+ $sd_data = $json_array['sd_data'];
22
  $schema_post = array();
23
+
24
+
25
  if($all_schema_post){
26
  // begin transaction
27
  $wpdb->query('START TRANSACTION');
28
+
29
+ foreach($all_schema_post as $schema_post){
30
+
31
  $post_id = wp_insert_post($schema_post['post']);
32
+ $result = $post_id;
33
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
34
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
35
 
36
  if ( isset( $schema_post['schema_type'] ) ){
71
  * @global type $wpdb
72
  * @return boolean
73
  */
74
+ function saswp_export_all_settings_and_schema(){
75
+
76
+ $export_data = array();
77
  $export_data_all = array();
78
+ $schema_post = array();
79
+ $user_id = get_current_user_id();
80
+
81
  $all_schema_post = get_posts(
82
+
83
  array(
84
  'post_type' => 'saswp',
85
+ 'posts_per_page' => -1,
86
+ 'post_status' => 'any',
87
  )
88
+
89
+ );
90
+
91
+ if($all_schema_post){
92
+
93
  foreach($all_schema_post as $schema){
94
 
95
+ $schema_post = array(
96
+
97
+ 'post_author' => $user_id,
98
+ 'post_date' => $schema->post_date,
99
+ 'post_date_gmt' => $schema->post_date_gmt,
100
+ 'post_content' => $schema->post_content,
101
+ 'post_title' => $schema->post_title,
102
+ 'post_excerpt' => $schema->post_excerpt,
103
+ 'post_status' => $schema->post_status,
104
+ 'comment_status' => $schema->comment_status,
105
+ 'ping_status' => $schema->ping_status,
106
+ 'post_password' => $schema->post_password,
107
+ 'post_name' => $schema->post_name,
108
+ 'to_ping' => $schema->to_ping,
109
+ 'pinged' => $schema->pinged,
110
+ 'post_modified' => $schema->post_modified,
111
+ 'post_modified_gmt' => $schema->post_modified_gmt,
112
  'post_content_filtered' => $schema->post_content_filtered,
113
+ 'post_parent' => $schema->post_parent,
114
+ 'menu_order' => $schema->menu_order,
115
+ 'post_type' => 'saswp',
116
+ 'post_mime_type' => $schema->post_mime_type,
117
+ 'comment_count' => $schema->comment_count,
118
+ 'filter' => $schema->filter,
119
+
120
  );
121
+
122
  $export_data[$schema->ID]['post'] = $schema_post;
123
 
124
+ $post_meta = get_post_meta($schema->ID, $key='', true );
125
+
126
+ $schema_type = saswp_remove_warnings($post_meta, 'schema_type', 'saswp_array');
127
+ $local_business_type = saswp_remove_warnings($post_meta, 'saswp_business_type', 'saswp_array');
128
+ $local_business_sub_type = saswp_remove_warnings($post_meta, 'saswp_business_name', 'saswp_array');
 
129
 
130
 
131
+ $data_group_array = get_post_meta($schema->ID, $key='data_group_array', true );
132
+ $local_business_details = get_post_meta($schema->ID, $key='saswp_local_business_details', true );
133
+
134
+
135
+ $export_data[$schema->ID]['schema_type'] = $schema_type;
136
+ $export_data[$schema->ID]['saswp_business_type'] = $local_business_type;
137
+ $export_data[$schema->ID]['saswp_business_name'] = $local_business_sub_type;
138
+ $export_data[$schema->ID]['data_group_array'] = $data_group_array;
139
  $export_data[$schema->ID]['saswp_local_business_details'] = $local_business_details;
140
  }
141
 
144
  $export_data_all['sd_data'] =$get_sd_data;
145
  header('Content-type: application/json');
146
  header('Content-disposition: attachment; filename=structuredatabackup.json');
147
+ echo json_encode($export_data_all);
148
+
149
  }else{
150
+
151
  header('Content-type: application/json');
152
  header('Content-disposition: attachment; filename=structuredatabackup.json');
153
+ echo json_encode(array('message'=> 'Data is not available'));
154
+
155
  }
156
  wp_die();
157
  }
166
 
167
  $schema_post = array();
168
  global $wpdb;
169
+ $user_id = get_current_user_id();
170
+
171
  $all_schema_post = get_posts(
172
  array(
173
  'post_type' => 'schema',
175
  'post_status' => 'any',
176
  )
177
  );
178
+
179
  if($all_schema_post){
180
  // begin transaction
181
  $wpdb->query('START TRANSACTION');
182
  foreach($all_schema_post as $schema){
183
 
184
  $schema_post = array(
185
+
186
+ 'post_author' => $user_id,
187
+ 'post_date' => $schema->post_date,
188
+ 'post_date_gmt' => $schema->post_date_gmt,
189
+ 'post_content' => $schema->post_content,
190
+ 'post_title' => $schema->post_title. ' (Migrated from Schema plugin)',
191
+ 'post_excerpt' => $schema->post_excerpt,
192
+ 'post_status' => $schema->post_status,
193
+ 'comment_status' => $schema->comment_status,
194
+ 'ping_status' => $schema->ping_status,
195
+ 'post_password' => $schema->post_password,
196
+ 'post_name' => $schema->post_name,
197
+ 'to_ping' => $schema->to_ping,
198
+ 'pinged' => $schema->pinged,
199
+ 'post_modified' => $schema->post_modified,
200
+ 'post_modified_gmt' => $schema->post_modified_gmt,
201
  'post_content_filtered' => $schema->post_content_filtered,
202
+ 'post_parent' => $schema->post_parent,
203
+ 'menu_order' => $schema->menu_order,
204
+ 'post_type' => 'saswp',
205
+ 'post_mime_type' => $schema->post_mime_type,
206
+ 'comment_count' => $schema->comment_count,
207
+ 'filter' => $schema->filter,
208
+
209
  );
210
  $post_id = wp_insert_post($schema_post);
211
+ $result = $post_id;
212
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
213
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
214
 
215
+ $schema_post_meta = get_post_meta($schema->ID, $key='', true );
216
+ $schema_post_types = get_post_meta($schema->ID, $key='_schema_post_types', true );
217
+ $schema_post_meta_box = get_post_meta($schema->ID, $key='_schema_post_meta_box', true );
218
 
219
  $data_group_array = array();
220
+
221
  if($schema_post_types){
222
 
223
  $i=0;
236
 
237
  }
238
  }
239
+ $schema_type ='';
240
  $schema_article_type ='';
241
 
242
  if(isset($schema_post_meta['_schema_type'])){
259
  //Importing settings starts here
260
 
261
  $schema_plugin_options = get_option('schema_wp_settings');
262
+ $custom_logo_id = get_theme_mod( 'custom_logo' );
263
+ $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
264
 
265
  $saswp_plugin_options = array(
266
  'sd_logo' => array(
371
  $settings = WPPostsRateKeys_Settings::get_options();
372
 
373
  if(isset($settings['seop_home_social'])){
374
+
375
  foreach($settings['seop_home_social'] as $social){
376
 
377
  switch ($social['social_type']) {
378
+
379
  case 'Facebook':
380
 
381
  $social_fields['saswp-facebook-enable'] = 1;
425
  }
426
 
427
  if(isset($settings['seop_operating_hour'])){
428
+
429
  $hours = $settings['seop_operating_hour'];
430
+
431
  if(isset($hours['Mo'])){
432
  $opening_hours .='Mo-Mo'.' '.$hours['Mo']['from'].'-'.$hours['Mo']['to'].' ';
433
  }
452
  }
453
 
454
 
455
+ if(isset($settings)){
456
+
457
  $local_business_details = array();
458
  $wpdb->query('START TRANSACTION');
459
 
460
  $user_id = get_current_user_id();
461
 
462
+ if($settings['seop_local_name'] !=''){
463
+
464
  $schema_post = array(
465
  'post_author' => $user_id,
466
  'post_status' => 'publish',
467
+ 'post_type' => 'saswp',
468
+ );
469
+
470
  $schema_post['post_title'] = 'Organization (Migrated from SEO Pressor)';
471
 
472
  if(isset($settings['seop_local_name'])){
473
+
474
+ $schema_post['post_title'] = $settings['seop_local_name'].'(Migrated from WP SEO Plugin)';
475
+
476
  }
477
  if(isset($settings['seop_home_logo'])){
478
+
479
  $image_details = wp_get_attachment_image_src($settings['seop_home_logo'], 'full');
480
 
481
  $local_business_details['local_business_logo'] = array(
504
  $local_business_details['local_street_address'] = $settings['seop_local_address'];
505
  }
506
  $post_id = wp_insert_post($schema_post);
507
+ $result = $post_id;
508
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
509
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
510
 
511
+ $data_group_array = array();
512
+
513
  $data_group_array['group-0'] =array(
514
  'data_array' => array(
515
  array(
521
  );
522
 
523
  $saswp_meta_key = array(
524
+ 'schema_type' => 'local_business',
525
+ 'data_group_array' => $data_group_array,
526
+ 'imported_from' => 'wp_seo_schema',
527
+ 'saswp_local_business_details' => $local_business_details,
528
+ 'saswp_dayofweek' => $opening_hours,
529
  );
530
 
531
  foreach ($saswp_meta_key as $key => $val){
534
 
535
  }
536
 
537
+ $get_options = get_option('sd_data');
538
  $merge_options = array_merge($get_options, $social_fields);
539
+ $result = update_option('sd_data', $merge_options);
540
 
541
  if (is_wp_error($result) ){
542
  echo esc_attr($result->get_error_message());
549
  }
550
 
551
  function saswp_import_wp_seo_schema_plugin_data(){
552
+
553
  global $KcSeoWPSchema;
554
  global $wpdb;
555
  $settings = get_option($KcSeoWPSchema->options['settings']);
556
 
557
  if(isset($settings)){
558
+
559
+ $saswp_plugin_options = array();
560
  $local_business_details = array();
561
  $wpdb->query('START TRANSACTION');
562
 
567
  $schema_post = array(
568
  'post_author' => $user_id,
569
  'post_status' => 'publish',
570
+ 'post_type' => 'saswp',
571
  );
572
  $schema_post['post_title'] = 'Organization (Migrated from WP SEO Plugin)';
573
 
615
  }
616
 
617
  $post_id = wp_insert_post($schema_post);
618
+ $result = $post_id;
619
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
620
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
621
 
622
+ $data_group_array = array();
623
+
624
  $data_group_array['group-0'] =array(
625
  'data_array' => array(
626
  array(
632
  );
633
 
634
  $saswp_meta_key = array(
635
+ 'schema_type' => 'local_business',
636
+ 'data_group_array' => $data_group_array,
637
+ 'imported_from' => 'wp_seo_schema',
638
+ 'saswp_local_business_details' => $local_business_details
639
  );
640
 
641
  foreach ($saswp_meta_key as $key => $val){
689
  if(isset($settings['siteurl'])){
690
  $saswp_plugin_options['sd_url'] = $settings['sitename'];
691
  }
692
+ $get_options = get_option('sd_data');
693
  $merge_options = array_merge($get_options, $saswp_plugin_options);
694
+ $result = update_option('sd_data', $merge_options);
695
 
696
  if (is_wp_error($result) ){
697
  echo esc_attr($result->get_error_message());
709
  $schema_post = array();
710
  global $wpdb;
711
  $user_id = get_current_user_id();
712
+
713
  $all_schema_post = get_posts(
714
  array(
715
  'post_type' => 'aiosrs-schema',
716
+ 'posts_per_page' => -1,
717
+ 'post_status' => 'any',
718
  )
719
+ );
720
+
721
  if($all_schema_post){
722
  // begin transaction
723
  $wpdb->query('START TRANSACTION');
724
  foreach($all_schema_post as $schema){
725
 
726
  $schema_post = array(
727
+ 'post_author' => $user_id,
728
+ 'post_date' => $schema->post_date,
729
+ 'post_date_gmt' => $schema->post_date_gmt,
730
+ 'post_content' => $schema->post_content,
731
+ 'post_title' => $schema->post_title. ' (Migrated from Schema_pro plugin)',
732
+ 'post_excerpt' => $schema->post_excerpt,
733
+ 'post_status' => $schema->post_status,
734
+ 'comment_status' => $schema->comment_status,
735
+ 'ping_status' => $schema->ping_status,
736
+ 'post_password' => $schema->post_password,
737
+ 'post_name' => $schema->post_name,
738
+ 'to_ping' => $schema->to_ping,
739
+ 'pinged' => $schema->pinged,
740
+ 'post_modified' => $schema->post_modified,
741
+ 'post_modified_gmt' => $schema->post_modified_gmt,
742
  'post_content_filtered' => $schema->post_content_filtered,
743
+ 'post_parent' => $schema->post_parent,
744
+ 'menu_order' => $schema->menu_order,
745
+ 'post_type' => 'saswp',
746
+ 'post_mime_type' => $schema->post_mime_type,
747
+ 'comment_count' => $schema->comment_count,
748
+ 'filter' => $schema->filter,
749
+ );
750
+
751
  $post_id = wp_insert_post($schema_post);
752
+ $result = $post_id;
753
+ $guid = get_option('siteurl') .'/?post_type=saswp&p='.$post_id;
754
  $wpdb->get_results("UPDATE wp_posts SET guid ='".$guid."' WHERE ID ='".$post_id."'");
755
 
756
+ $schema_post_meta = get_post_meta($schema->ID, $key='', true );
757
+ $schema_post_types = get_post_meta($schema->ID, $key='bsf-aiosrs-schema-type', true );
758
+ $schema_post_meta_box = get_post_meta($schema->ID, $key='bsf-aiosrs-'.$schema_post_types, true );
759
+ $schema_enable_location = get_post_meta($schema->ID, $key='bsf-aiosrs-schema-location', true );
760
+ $schema_exclude_location = get_post_meta($schema->ID, $key='bsf-aiosrs-schema-exclusion', true );
 
761
 
762
  $data_array = array();
763
+
764
  if($schema_exclude_location){
765
 
766
  $exclude_rule = $schema_exclude_location['rule'];
767
  $fields = array_flip($exclude_rule);
768
+
769
  unset($fields['specifics']);
770
+
771
  $exclude_rule = array_flip($fields);
772
  $exclude_specific = $schema_exclude_location['specific'];
773
 
775
  foreach($exclude_rule as $rule){
776
 
777
  if($rule =='basic-singulars'){
778
+
779
  $data_array['data_array'][] =array(
780
  'key_1' => 'post_type',
781
  'key_2' => 'not_equal',
782
  'key_3' => 'post',
783
+ );
784
+
785
  }else{
786
+
787
  $explode = explode("|", $rule);
788
  $data_array['data_array'][] =array(
789
  'key_1' => 'post_type',
790
  'key_2' => 'not_equal',
791
  'key_3' => $explode[0],
792
+ );
793
+
794
  }
795
  }
796
 
802
 
803
  if($specific_post_name =='post'){
804
 
805
+ $specific_post_type = get_post_type($specific_post_id);
806
+
807
  $data_array['data_array'][] =array(
808
  'key_1' => $specific_post_type,
809
  'key_2' => 'not_equal',
810
  'key_3' => $specific_post_id,
811
  );
812
+
813
  }
814
 
815
  if($specific_post_name =='tax'){
816
+
817
  $data_array['data_array'][] =array(
818
  'key_1' => 'post_category',
819
  'key_2' => 'not_equal',
820
  'key_3' => $specific_post_id,
821
  );
822
+
823
  }
824
 
825
  }
826
 
827
  $temp_data_array = $data_array['data_array'];
828
  $temp_two_array = $data_array['data_array'];
829
+ $j =0;
830
+
831
  foreach($temp_two_array as $key => $val){
832
+
833
+ $index =0;
834
+
835
  foreach($temp_data_array as $t=>$tval){
836
 
837
  if(($val['key_1'] == $tval['key_1']) && ($val['key_2'] == $tval['key_2']) && ($val['key_3'] == $tval['key_3'])){
847
  }
848
 
849
  $data_group_array = array();
850
+
851
  if($schema_enable_location){
852
+
853
  $enable_rule = $schema_enable_location['rule'];
854
+ $fields = array_flip($enable_rule);
855
+
856
  unset($fields['specifics']);
857
+
858
+ $enable_rule = array_flip($fields);
859
  $enable_specific = $schema_enable_location['specific'];
860
 
861
  $i=0;
862
  foreach ($enable_rule as $rule){
863
 
864
  if($rule =='basic-singulars'){
865
+
866
  $data_group_array['group-'.$i] =array(
867
+
868
  'data_array' => array(
869
  array(
870
  'key_1' => 'post_type',
871
  'key_2' => 'equal',
872
  'key_3' => 'post',
873
  )
874
+ )
875
+
876
+ );
877
+
878
  }else{
879
+
880
  $explode = explode("|", $rule);
881
+
882
  $data_group_array['group-'.$i] =array(
883
+
884
  'data_array' => array(
885
  array(
886
  'key_1' => 'post_type',
887
  'key_2' => 'equal',
888
  'key_3' => $explode[0],
889
  )
890
+ )
891
+
892
+ );
893
+
894
  }
895
  if(isset($data_array['data_array'])){
896
+
897
+ $data_group_array['group-'.$i]['data_array'] = array_merge($data_group_array['group-'.$i]['data_array'],$data_array['data_array']);
898
+
899
  }
900
  $i++;
901
 
903
 
904
  foreach ($enable_specific as $rule){
905
 
906
+ $explode = explode("-", $rule);
907
  $specific_post_name = $explode[0];
908
  $specific_post_id = $explode[1];
909
 
910
  if($specific_post_name =='post'){
911
 
912
+ $specific_post_type = get_post_type($specific_post_id);
913
+
914
+ $data_group_array['group-'.$i] =array(
915
+
916
+ 'data_array' => array(
917
+ array(
918
+ 'key_1' => $specific_post_type,
919
+ 'key_2' => 'equal',
920
+ 'key_3' => $specific_post_id,
921
+ )
922
+ )
923
+
924
  );
925
  }
926
 
927
  if($specific_post_name =='tax'){
928
+
929
  $data_group_array['group-'.$i] =array(
930
+
931
+ 'data_array' => array(
932
+ array(
933
+ 'key_1' => 'post_category',
934
+ 'key_2' => 'equal',
935
+ 'key_3' => $specific_post_id,
936
+ )
937
+ )
938
+
939
  );
940
+
941
  }
942
  if(isset($data_array['data_array'])){
943
+
944
+ $data_group_array['group-'.$i]['data_array'] = array_merge($data_group_array['group-'.$i]['data_array'],$data_array['data_array']);
945
+
946
  }
947
 
948
  $i++;
949
 
950
  }
951
  }
952
+ $schema_type = '';
953
+ $local_name = '';
954
+ $local_image = '';
955
+ $local_phone = '';
956
+ $local_url = '';
957
+ $local_url = '';
958
+
959
  if(isset($schema_post_types)){
960
+
961
  $schema_type = ucfirst($schema_post_types);
962
 
963
+
964
  }
965
  if($schema_type =='Video-object'){
966
+
967
  $schema_type = 'VideoObject';
968
+
969
  }
970
  $local_business_details = array();
971
+
972
  if($schema_type =='Local-business'){
973
+
974
  $schema_type = 'local_business';
975
 
976
  if(isset($schema_post_meta_box['telephone'])){
979
  if(isset($schema_post_meta_box['image'])){
980
  $local_business_details['local_business_logo']['url'] = $schema_post_meta_box['image'];
981
  }
982
+ if(isset($schema_post_meta_box['price-range'])){
983
  $local_business_details['local_price_range'] = $schema_post_meta_box['price-range'];
984
  }
985
  if(isset($schema_post_meta_box['location-postal'])){
996
  }
997
  }
998
  $saswp_meta_key = array(
999
+
1000
+ 'schema_type' => $schema_type,
1001
+ 'data_group_array' => $data_group_array,
1002
+ 'imported_from' => 'schema_pro',
1003
+ 'saswp_local_business_details' => $local_business_details
1004
+
1005
  );
1006
 
1007
+ foreach ($saswp_meta_key as $key => $val){
1008
+
1009
  update_post_meta($post_id, $key, $val);
1010
+
1011
+ }
1012
+
1013
  }
1014
  //Importing settings starts here
1015
 
1016
  $schema_pro_general_settings = get_option('wp-schema-pro-general-settings');
1017
+ $schema_pro_social_profile = get_option('wp-schema-pro-social-profiles');
1018
+ $schema_pro_global_schemas = get_option('wp-schema-pro-global-schemas');
1019
+ $schema_pro_settings = get_option('aiosrs-pro-settings');
1020
+ $logo = wp_get_attachment_image_src( $schema_pro_general_settings['site-logo-custom'] , 'full' );
 
1021
 
1022
+ $saswp_plugin_options = array(
1023
+
1024
+ 'sd_logo' => array(
1025
+ 'url' => $logo[0],
1026
+ 'id' => $schema_pro_general_settings['site-logo-custom'],
1027
+ 'height' => $logo[1],
1028
+ 'width' => $logo[2],
1029
+ 'thumbnail' => $logo[0]
1030
+ ),
1031
+
1032
+ 'saswp_kb_contact_1' => 0,
1033
  //AMP Block
1034
+ 'saswp-for-amp' => 1,
1035
+ 'saswp-for-wordpress' => 1,
1036
+ 'saswp-logo-width' => '60',
1037
+ 'saswp-logo-height' => '60',
1038
+ 'sd_initial_wizard_status' => 1,
1039
 
1040
  );
1041
  if(isset($schema_pro_social_profile['facebook'])){
1183
  function saswp_admin_link($tab = '', $args = array()){
1184
 
1185
  $page = 'structured_data_options';
1186
+
1187
  if ( ! is_multisite() ) {
1188
  $link = admin_url( 'admin.php?page=' . $page );
1189
  }
1217
 
1218
  $sd_data=array();
1219
  function saswp_defaultSettings(){
1220
+
1221
  global $sd_data;
1222
  $sd_name = 'default';
1223
  $bloginfo = get_bloginfo('name', 'display');
1224
+
1225
  if($bloginfo){
1226
+
1227
  $sd_name =$bloginfo;
1228
+
1229
+ }
1230
+
1231
+ $current_url = get_home_url();
1232
  $custom_logo_id = get_theme_mod( 'custom_logo' );
1233
+ $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
1234
 
1235
+ $user_id = get_current_user_id();
1236
+ $username = '';
1237
+
1238
  if($user_id>0){
1239
+
1240
  $user_info = get_userdata($user_id);
1241
  $username = $user_info->data->display_name;
1242
+
1243
  }
1244
  $defaults = array(
1245
  //General Block
1251
  'sd_alt_name' => $sd_name,
1252
  'sd_url' => $current_url,
1253
  'sd_logo' => array(
1254
+ 'url' => $logo[0],
1255
+ 'id' => $custom_logo_id,
1256
+ 'height' => $logo[2],
1257
+ 'width' => $logo[1],
1258
+ 'thumbnail' => $logo[0]
1259
  ),
1260
+ 'sd-person-name' => $username,
1261
  'sd-person-job-title'=> '',
1262
+ 'sd-person-url' => $current_url,
1263
+ 'sd-person-image' => array(
1264
  'url' =>'',
1265
  'id' =>'',
1266
  'height' =>'',
1267
  'width' =>'',
1268
+ 'thumbnail' =>''
1269
+ ),
1270
+ 'sd-person-phone-number' => '',
1271
+ 'saswp_kb_telephone' => '',
1272
+ 'saswp_contact_type' => '',
1273
+ 'saswp_kb_contact_1' => 0,
1274
  //Social
1275
+ 'sd_facebook' => '',
1276
+ 'sd_twitter' => '',
1277
+ 'sd_google_plus' => '',
1278
+ 'sd_instagram' => '',
1279
+ 'sd_youtube' => '',
1280
+ 'sd_linkedin' => '',
1281
+ 'sd_pinterest' => '',
1282
+ 'sd_soundcloud' => '',
1283
+ 'sd_tumblr' => '',
1284
 
1285
 
1286
  'sd-data-logo-ampforwp' => array(
1287
+
1288
+ 'url' => $logo[0],
1289
+ 'id' => $custom_logo_id,
1290
+ 'height' => $logo[2],
1291
+ 'width' => $logo[1],
1292
+ 'thumbnail' => $logo[0]
1293
+
1294
  ),
1295
 
1296
  //AMP Block
1297
+ 'saswp-for-amp' => 1,
1298
+ 'saswp-for-wordpress' => 1,
1299
+ 'saswp-logo-width' => '60',
1300
+ 'saswp-logo-height' => '60',
1301
 
1302
  'sd_default_image' => array(
1303
+ 'url' => $logo[0],
1304
+ 'id' => $custom_logo_id,
1305
+ 'height' => $logo[2],
1306
+ 'width' => $logo[1],
1307
+ 'thumbnail' => $logo[0]
1308
  ),
1309
+ 'sd_default_image_width' => $logo[1],
1310
+ 'sd_default_image_height' => $logo[2],
1311
+ 'sd_initial_wizard_status' => 1,
 
 
1312
 
1313
  );
1314
+ $sd_data = $settings = get_option( 'sd_data', $defaults);
1315
+
1316
  return $settings;
1317
+
1318
  }
1319
  function saswp_frontend_enqueue(){
1320
  wp_enqueue_style( 'saswp-style', SASWP_PLUGIN_URL . 'admin_section/css/saswp-style.css', false , SASWP_VERSION );
1323
  add_action( 'wp_enqueue_scripts', 'saswp_frontend_enqueue' );
1324
 
1325
  function saswp_enque_amp_script(){
1326
+
1327
  global $sd_data;
1328
  $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
1329
+
1330
  $saswp_review_item_enable = 0;
1331
+
1332
  if(isset($saswp_review_details['saswp-review-item-enable'])){
1333
+
1334
  $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
1335
+
1336
+ }
1337
+
1338
+ if($sd_data['saswp-review-module']== 1 && $saswp_review_item_enable == 1){
1339
  ?>
1340
  .saswp-pc-wrap{
1341
  background-color: #004f74;
1450
  width: 20px;
1451
  height: 16px;
1452
  background-repeat: no-repeat;
1453
+ background-image: url(<?php echo esc_url(SASWP_DIR_URI.'/admin_section/images/half_star.png'); ?>);
1454
  }
1455
  .saswp-rvw-str .str-ic{
1456
  display:inline-block;
1457
  width: 20px;
1458
  height: 16px;
1459
  background-repeat: no-repeat;
1460
+ background-image: url(<?php echo esc_url(SASWP_DIR_URI.'/admin_section/images/full_star.png'); ?>);
1461
  }
1462
  .saswp-rvw-str .df-clr{
1463
  display:inline-block;
1464
  width: 20px;
1465
  height: 16px;
1466
  background-repeat: no-repeat;
1467
+ background-image: url(<?php echo esc_url(SASWP_DIR_URI.'/admin_section/images/blank_star.png'); ?>);
1468
  }
1469
  @media(max-width:500px){
1470
  .saswp-pc-wrap{
admin_section/css/main-style.css CHANGED
@@ -111,7 +111,6 @@ display: none !important;
111
  .saswp-query-error{
112
  color: #bf3322;
113
  }
114
-
115
  .saswp-tools table th{
116
  width: auto;
117
  padding: 0px;
@@ -155,9 +154,9 @@ Tooltip css starts here
155
  left: 50%;
156
  margin-left: -25px;
157
  }
158
- .saswp-tooltip:hover .saswp-tooltiptext {
159
  visibility: visible;
160
- }
161
 
162
  .saswp-tooltiptext::after {
163
  content: "";
@@ -550,4 +549,9 @@ input:checked + .saswp-slider:before {
550
  }
551
  /*
552
  On/Off Buttons ends here
553
- */
 
 
 
 
 
111
  .saswp-query-error{
112
  color: #bf3322;
113
  }
 
114
  .saswp-tools table th{
115
  width: auto;
116
  padding: 0px;
154
  left: 50%;
155
  margin-left: -25px;
156
  }
157
+ /*.saswp-tooltip:hover .saswp-tooltiptext {
158
  visibility: visible;
159
+ }*/
160
 
161
  .saswp-tooltiptext::after {
162
  content: "";
549
  }
550
  /*
551
  On/Off Buttons ends here
552
+ */
553
+ .saswp-wdi-rate-stars{display:inline-block;color:#ffb900;position:relative;top:3px;}
554
+ .saswp-wdi-rate-stars svg{fill:#ffb900;}
555
+ .saswp-wdi-rate-stars svg:hover{fill:#ffb900}
556
+ .saswp-wdi-rate-stars svg:hover ~ svg{fill:none;}
557
+
admin_section/fields-generator.php CHANGED
@@ -5,61 +5,96 @@
5
  class saswp_fields_generator {
6
 
7
  public function saswp_tooltip_message($meta_field_id){
8
- $tooltip_message='';
 
 
9
  switch ($meta_field_id) {
 
10
  case 'saswp_kb_type':
11
- //$tooltip_message = esc_html__('ss','schema-and-structured-data-for-wp');
12
  break;
13
 
14
  default:
15
  break;
16
  }
 
17
  return $tooltip_message;
18
  }
19
  public function saswp_field_generator( $meta_fields, $settings ) {
20
- $output = '';
21
- $tooltip_message='';
 
 
 
22
  foreach ( $meta_fields as $meta_field ) {
23
 
24
  $tooltip_message = $this->saswp_tooltip_message($meta_field['id']);
25
 
26
- $class = "";
27
- $note = "";
28
- $tooltip_element="";
29
- $hidden = array();
30
- $attribute = array();
31
  if(array_key_exists('class', $meta_field)){
32
- $class = $meta_field['class'];
 
 
33
  }
34
  if(array_key_exists('note', $meta_field)){
35
- $note = $meta_field['note'];
 
 
36
  }
37
  if(array_key_exists('hidden', $meta_field)){
38
- $hidden = $meta_field['hidden'];
 
 
39
  }
40
  if(array_key_exists('attributes', $meta_field)){
41
- $attribute = $meta_field['attributes'];
 
 
42
  }
43
  if($tooltip_message){
44
- $tooltip_element = '<span class="saswp-tooltiptext">'.$tooltip_message.'</span>';
 
 
 
 
 
 
45
  }
46
- $label = '<label class="saswp-tooltip" for="' . esc_attr($meta_field['id']) . '">' . esc_html__( $meta_field['label'], 'schema-and-structured-data-for-wp' ) .$tooltip_element.'</label>';
47
 
48
  switch ( $meta_field['type'] ) {
 
49
  case 'media':
 
 
 
 
 
 
 
 
 
50
  $mediavalue = array();
 
51
  if(isset($settings[$meta_field['id']])){
 
52
  $mediavalue = $settings[$meta_field['id']];
 
53
  }
54
 
55
  $input = sprintf(
56
- '<fieldset><input class="%s" style="width: 80%%" id="%s" name="%s" type="text" value="%s">'
57
  . '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
58
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_id" class="upload-id " name="sd_data['.esc_attr($meta_field['id']).'][id]" id="sd_data['.esc_attr($meta_field['id']).'][id]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'id', 'saswp_string')).'">'
59
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_height" class="upload-height" name="sd_data['.esc_attr($meta_field['id']).'][height]" id="sd_data['.esc_attr($meta_field['id']).'][height]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'height', 'saswp_string')).'">'
60
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_width" class="upload-width" name="sd_data['.esc_attr($meta_field['id']).'][width]" id="sd_data['.esc_attr($meta_field['id']).'][width]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'width', 'saswp_string')).'">'
61
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_thumbnail" class="upload-thumbnail" name="sd_data['.esc_attr($meta_field['id']).'][thumbnail]" id="sd_data['.esc_attr($meta_field['id']).'][thumbnail]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'thumbnail', 'saswp_string')).'">'
62
  . '</fieldset>',
 
63
  $class,
64
  esc_attr($meta_field['id']),
65
  esc_attr($meta_field['name']),
@@ -69,28 +104,43 @@ class saswp_fields_generator {
69
  );
70
  break;
71
  case 'checkbox':
 
72
  $attribute_str ='';
 
73
  foreach ($attribute as $key => $attr ){
 
74
  $attribute_str .=''.$key.'="'.$attr.'"';
 
75
  }
76
  $hiddenvalue ="";
 
77
  if(array_key_exists('id', $hidden) && isset($settings[$hidden['id']])){
78
- $hiddenvalue = $settings[$hidden['id']];
 
 
79
  }
80
  $hiddenfield="";
81
- if(!empty($hidden)){
 
 
82
  $hiddenfield = sprintf(
83
  '<input id="%s" name="%s" type="hidden" value="%s">',
84
  esc_attr($hidden['id']),
85
  esc_attr($hidden['name']),
86
  esc_attr($hiddenvalue)
87
- );
 
88
  }
89
  $message ='';
 
90
  if (! is_plugin_active('flexmls-idx/flexmls_connect.php')) {
 
91
  if($meta_field['id'] =='saswp_compativility_checkbox'){
92
- $note = 'Plugin is not activated';
93
- }
 
 
 
94
  }
95
 
96
  $input = sprintf(
@@ -131,7 +181,9 @@ class saswp_fields_generator {
131
  $stng_meta_field = '';
132
 
133
  if(isset($settings[$meta_field['id']])){
 
134
  $stng_meta_field = $settings[$meta_field['id']];
 
135
  }
136
 
137
  $input = sprintf(
5
  class saswp_fields_generator {
6
 
7
  public function saswp_tooltip_message($meta_field_id){
8
+
9
+ $tooltip_message = '';
10
+
11
  switch ($meta_field_id) {
12
+
13
  case 'saswp_kb_type':
14
+ //$tooltip_message = 'Test Message';
15
  break;
16
 
17
  default:
18
  break;
19
  }
20
+
21
  return $tooltip_message;
22
  }
23
  public function saswp_field_generator( $meta_fields, $settings ) {
24
+
25
+ $output = '';
26
+ $tooltip_message = '';
27
+
28
+
29
  foreach ( $meta_fields as $meta_field ) {
30
 
31
  $tooltip_message = $this->saswp_tooltip_message($meta_field['id']);
32
 
33
+ $class = "";
34
+ $note = "";
35
+ $hidden = array();
36
+ $attribute = array();
37
+
38
  if(array_key_exists('class', $meta_field)){
39
+
40
+ $class = $meta_field['class'];
41
+
42
  }
43
  if(array_key_exists('note', $meta_field)){
44
+
45
+ $note = $meta_field['note'];
46
+
47
  }
48
  if(array_key_exists('hidden', $meta_field)){
49
+
50
+ $hidden = $meta_field['hidden'];
51
+
52
  }
53
  if(array_key_exists('attributes', $meta_field)){
54
+
55
+ $attribute = $meta_field['attributes'];
56
+
57
  }
58
  if($tooltip_message){
59
+
60
+ $label = '<label class="saswp-tooltip" for="' . esc_attr($meta_field['id']) . '">' . esc_html__( $meta_field['label'], 'schema-and-structured-data-for-wp' ).' <span class="saswp-tooltiptext">'.esc_html__($tooltip_message, 'schema-and-structured-data-for-wp').'</span></label>';
61
+
62
+ }else{
63
+
64
+ $label = '<label class="saswp-tooltip" for="' . esc_attr($meta_field['id']) . '">' . esc_html__( $meta_field['label'], 'schema-and-structured-data-for-wp' ).' <span class="saswp-tooltiptext"></span></label>';
65
+
66
  }
67
+
68
 
69
  switch ( $meta_field['type'] ) {
70
+
71
  case 'media':
72
+
73
+ $attribute_str ='';
74
+
75
+ foreach ($attribute as $key => $attr ){
76
+
77
+ $attribute_str .=''.$key.'="'.$attr.'"';
78
+
79
+ }
80
+
81
  $mediavalue = array();
82
+
83
  if(isset($settings[$meta_field['id']])){
84
+
85
  $mediavalue = $settings[$meta_field['id']];
86
+
87
  }
88
 
89
  $input = sprintf(
90
+ '<fieldset><input %s class="%s" style="width: 80%%" id="%s" name="%s" type="text" value="%s">'
91
  . '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
92
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_id" class="upload-id " name="sd_data['.esc_attr($meta_field['id']).'][id]" id="sd_data['.esc_attr($meta_field['id']).'][id]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'id', 'saswp_string')).'">'
93
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_height" class="upload-height" name="sd_data['.esc_attr($meta_field['id']).'][height]" id="sd_data['.esc_attr($meta_field['id']).'][height]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'height', 'saswp_string')).'">'
94
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_width" class="upload-width" name="sd_data['.esc_attr($meta_field['id']).'][width]" id="sd_data['.esc_attr($meta_field['id']).'][width]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'width', 'saswp_string')).'">'
95
  . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_thumbnail" class="upload-thumbnail" name="sd_data['.esc_attr($meta_field['id']).'][thumbnail]" id="sd_data['.esc_attr($meta_field['id']).'][thumbnail]" value="'.esc_attr(saswp_remove_warnings($mediavalue, 'thumbnail', 'saswp_string')).'">'
96
  . '</fieldset>',
97
+ $attribute_str,
98
  $class,
99
  esc_attr($meta_field['id']),
100
  esc_attr($meta_field['name']),
104
  );
105
  break;
106
  case 'checkbox':
107
+
108
  $attribute_str ='';
109
+
110
  foreach ($attribute as $key => $attr ){
111
+
112
  $attribute_str .=''.$key.'="'.$attr.'"';
113
+
114
  }
115
  $hiddenvalue ="";
116
+
117
  if(array_key_exists('id', $hidden) && isset($settings[$hidden['id']])){
118
+
119
+ $hiddenvalue = $settings[$hidden['id']];
120
+
121
  }
122
  $hiddenfield="";
123
+
124
+ if(!empty($hidden)){
125
+
126
  $hiddenfield = sprintf(
127
  '<input id="%s" name="%s" type="hidden" value="%s">',
128
  esc_attr($hidden['id']),
129
  esc_attr($hidden['name']),
130
  esc_attr($hiddenvalue)
131
+ );
132
+
133
  }
134
  $message ='';
135
+
136
  if (! is_plugin_active('flexmls-idx/flexmls_connect.php')) {
137
+
138
  if($meta_field['id'] =='saswp_compativility_checkbox'){
139
+
140
+ $note = esc_html__('Plugin is not activated','schema-and-structured-data-for-wp');
141
+
142
+ }
143
+
144
  }
145
 
146
  $input = sprintf(
181
  $stng_meta_field = '';
182
 
183
  if(isset($settings[$meta_field['id']])){
184
+
185
  $stng_meta_field = $settings[$meta_field['id']];
186
+
187
  }
188
 
189
  $input = sprintf(
admin_section/js/main-script.js CHANGED
@@ -48,6 +48,7 @@ jQuery(document).ready(function($){
48
  if(schematype == 'Review'){
49
  $(".saswp-review-text-field-tr").show();
50
  $(".saswp-option-table-class tr").find('select').attr('disabled', false);
 
51
  }
52
  if(schematype == 'Product'){
53
  $(".saswp-product-text-field-tr").show();
@@ -309,6 +310,16 @@ jQuery(document).ready(function($){
309
  }
310
  break;
311
 
 
 
 
 
 
 
 
 
 
 
312
  default:
313
  break;
314
  }
@@ -319,26 +330,30 @@ jQuery(document).ready(function($){
319
  var datatype = $(this).val();
320
  for(var i=1;i<=11;i++){
321
  if(datatype ==="Person"){
322
- if(i<7){
323
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
324
  }else{
325
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
326
  }
327
  }else if(datatype ==="Organization"){
328
- if(i<7){
329
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
330
  }else{
331
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
332
- }
 
333
  }else{
334
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
335
  }
336
 
337
  }
338
- }).change();
 
 
339
  $(document).on("click", "input[data-id=media]" ,function(e) { // Application Icon upload
340
  e.preventDefault();
341
- var button = $(this);
 
342
  var id = button.attr('id').replace('_button', '');
343
  var saswpMediaUploader = wp.media({
344
  title: "Application Icon",
@@ -356,6 +371,14 @@ jQuery(document).ready(function($){
356
  $("input[data-id='"+id+"_height']").val(attachment.height);
357
  $("input[data-id='"+id+"_width']").val(attachment.width);
358
  $("input[data-id='"+id+"_thumbnail']").val(attachment.url);
 
 
 
 
 
 
 
 
359
  })
360
  .open();
361
  });
@@ -511,6 +534,49 @@ jQuery(document).ready(function($){
511
  }
512
  },'json');
513
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  function saswpAddTimepicker(){
515
  $('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
516
  }
@@ -528,6 +594,7 @@ jQuery(document).ready(function($){
528
  saswpAddTimepicker();
529
  saswp_schema_datepicker();
530
  saswp_enable_rating_review();
 
531
  });
532
 
533
  });
@@ -632,8 +699,11 @@ jQuery(document).ready(function($){
632
 
633
  //custom fields modify schema starts here
634
 
 
 
 
635
 
636
- $("#saswp_enable_custom_field").change(function(){
637
  if ($(this).is(':checked')) {
638
  $(".saswp-custom-fields-div").show();
639
  }else{
@@ -747,11 +817,7 @@ jQuery(document).ready(function($){
747
  }
748
 
749
  }
750
- saswp_enable_rating_review();
751
-
752
-
753
-
754
-
755
  //custom fields modify schema ends here
756
 
757
  });
48
  if(schematype == 'Review'){
49
  $(".saswp-review-text-field-tr").show();
50
  $(".saswp-option-table-class tr").find('select').attr('disabled', false);
51
+ saswp_item_reviewed_call();
52
  }
53
  if(schematype == 'Product'){
54
  $(".saswp-product-text-field-tr").show();
310
  }
311
  break;
312
 
313
+ case 'saswp-yoast-checkbox':
314
+
315
+ if ($(this).is(':checked')) {
316
+ $("#saswp-yoast").val(1);
317
+ }else{
318
+ $("#saswp-yoast").val(0);
319
+ }
320
+ break;
321
+
322
+
323
  default:
324
  break;
325
  }
330
  var datatype = $(this).val();
331
  for(var i=1;i<=11;i++){
332
  if(datatype ==="Person"){
333
+ if(i<6){
334
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
335
  }else{
336
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
337
  }
338
  }else if(datatype ==="Organization"){
339
+ if(i<6){
340
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).show();
341
  }else{
342
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
343
+ }
344
+ $( ".saswp-knowledge-base li:eq(11)" ).show();
345
  }else{
346
  $( ".saswp-knowledge-base li:eq('"+i+"')" ).hide();
347
  }
348
 
349
  }
350
+ }).change();
351
+
352
+
353
  $(document).on("click", "input[data-id=media]" ,function(e) { // Application Icon upload
354
  e.preventDefault();
355
+ var current = $(this);
356
+ var button = current;
357
  var id = button.attr('id').replace('_button', '');
358
  var saswpMediaUploader = wp.media({
359
  title: "Application Icon",
371
  $("input[data-id='"+id+"_height']").val(attachment.height);
372
  $("input[data-id='"+id+"_width']").val(attachment.width);
373
  $("input[data-id='"+id+"_thumbnail']").val(attachment.url);
374
+
375
+ if(current.attr('id') === 'sd_default_image_button'){
376
+
377
+ $("#sd_default_image_width").val(attachment.width);
378
+ $("#sd_default_image_height").val(attachment.height);
379
+
380
+ }
381
+
382
  })
383
  .open();
384
  });
534
  }
535
  },'json');
536
  });
537
+
538
+
539
+ function saswp_item_reviewed_call(){
540
+
541
+ $(".saswp-item-reviewed").change(function(e){
542
+ e.preventDefault();
543
+ var schema_type ="";
544
+
545
+ if($('select#schema_type option:selected').val()){
546
+ schema_type = $('select#schema_type option:selected').val();
547
+ }
548
+ if($(".saswp-tab-links.selected").attr('saswp-schema-type')){
549
+ schema_type = $(".saswp-tab-links.selected").attr('saswp-schema-type');
550
+ }
551
+
552
+ if(schema_type === 'Review'){
553
+
554
+ var current = $(this);
555
+ var item = $(this).val();
556
+ var post_id = saswp_localize_data.post_id;
557
+ var schema_id = $(current).attr('data-id');
558
+ var post_specific = $(current).attr('post-specific');
559
+ $.get(ajaxurl,
560
+ { 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},
561
+ function(response){
562
+
563
+ $(current).parent().parent().nextAll().remove(".saswp-review-tr");
564
+ $(current).parent().parent().after(response);
565
+
566
+ });
567
+
568
+ }
569
+
570
+
571
+ }).change();
572
+
573
+ }
574
+ saswp_item_reviewed_call();
575
+
576
+
577
+
578
+
579
+
580
  function saswpAddTimepicker(){
581
  $('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
582
  }
594
  saswpAddTimepicker();
595
  saswp_schema_datepicker();
596
  saswp_enable_rating_review();
597
+ saswp_item_reviewed_call();
598
  });
599
 
600
  });
699
 
700
  //custom fields modify schema starts here
701
 
702
+ //Changing the url of add new schema type
703
+ $('a[href="'+saswp_localize_data.new_url_selector+'"]').attr( 'href', saswp_localize_data.new_url_href);
704
+
705
 
706
+ $("#saswp_enable_custom_field").change(function(){
707
  if ($(this).is(':checked')) {
708
  $(".saswp-custom-fields-div").show();
709
  }else{
817
  }
818
 
819
  }
820
+ saswp_enable_rating_review();
 
 
 
 
821
  //custom fields modify schema ends here
822
 
823
  });
admin_section/js/saswp-newsletter.js ADDED
File without changes
admin_section/plugin-installer/install.php CHANGED
@@ -15,11 +15,11 @@
15
  $saswp_installer_config = array(
16
  'installer_dir' => 'plugin-installer',
17
  'plugin_title' => esc_html__( ucfirst( 'Schema & Structured Data for WP' ), 'schema-and-structured-data-for-wp'),
18
- 'start_steps' => 1,
19
- 'total_steps' => 5,
20
  'installerpage' => 'saswp-setup-wizard',
21
- 'dev_mode' => false,
22
- 'steps' => array(
23
  1=>array(
24
  'title'=>esc_html__('Welcome', 'schema-and-structured-data-for-wp'),
25
  'fields'=>'',
@@ -46,7 +46,7 @@
46
  'fields'=>'',
47
  ),
48
  ),
49
- 'current_step'=>array(
50
  'title'=>'',
51
  'step_id'=>1
52
  )
@@ -55,9 +55,12 @@
55
  add_action( 'admin_init', 'saswp_installer_init');
56
  add_action( 'admin_footer', 'saswp_svg_sprite');
57
  add_action( 'wp_ajax_saswp_save_installer', 'saswp_save_steps_data', 10, 0 );
 
58
  function saswp_add_admin_menu(){
 
59
  global $saswp_installer_config;
60
  saswp_installer_init();
 
61
  }
62
 
63
  function saswp_installer_init(){
@@ -78,6 +81,7 @@
78
  }
79
 
80
  function saswp_steps_call(){
 
81
  global $saswp_installer_config;
82
  if ( !wp_verify_nonce($_GET['_saswp_nonce'], 'saswp_install_wizard_nonce') || empty( $_GET['page'] ) || $saswp_installer_config['installerpage'] !== $_GET['page'] ) {
83
  return;
@@ -100,7 +104,7 @@
100
  wp_localize_script( 'saswp_install', 'saswp_install_params', array(
101
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
102
  'wpnonce' => wp_create_nonce( 'saswp_install_nonce' ),
103
- 'pluginurl' => SASWP_DIR_URI,
104
  ) );
105
 
106
 
@@ -125,7 +129,7 @@
125
 
126
  </div>
127
 
128
- <?php echo sprintf( '<a class="return-to-dashboard" href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=structured_data_options' ) ), esc_html( 'Return to dashboard' ) ); ?>
129
 
130
  </div>
131
 
@@ -134,6 +138,7 @@
134
  }
135
 
136
  function saswp_show_steps_body(){
 
137
  global $saswp_installer_config;
138
  if($saswp_installer_config['total_steps']==$saswp_installer_config['current_step']['step_id']){
139
  call_user_func('saswp_finish_page');
@@ -148,6 +153,7 @@
148
 
149
 
150
  function saswp_step1(){
 
151
  global $saswp_installer_config;
152
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
153
  ?>
@@ -160,20 +166,21 @@
160
 
161
  <h1><?php echo esc_attr($stepDetails['title']); ?></h1>
162
 
163
- <p><?php echo esc_html( 'This Installation Wizard helps you to setup the necessary options for schema & structured data. It is optional & should take only a few minutes.' ); ?></p>
164
 
165
  </div>
166
 
167
  <footer class="merlin__content__footer">
168
- <a href="<?php echo esc_url( admin_url( 'admin.php?page=structured_data_options' ) ); ?>" class="merlin__button merlin__button--skip"><?php echo esc_html( 'Cancel' ); ?></a>
169
 
170
- <a href="<?php echo esc_url( saswp_step_next_link() ); ?>" class="merlin__button merlin__button--next merlin__button--proceed merlin__button--colorchange"><?php echo esc_html( 'Start' ); ?></a>
171
  <?php wp_nonce_field( 'saswp_install_nonce' ); ?>
172
  </footer>
173
  <?php
174
  }
175
 
176
  function saswp_step2(){
 
177
  global $saswp_installer_config;
178
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
179
 
@@ -219,6 +226,7 @@
219
  }
220
 
221
  function saswp_step3(){
 
222
  global $saswp_installer_config;
223
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
224
  ?>
@@ -263,6 +271,7 @@
263
  }
264
 
265
  function saswp_step4(){
 
266
  global $saswp_installer_config;
267
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
268
  ?>
@@ -306,6 +315,7 @@
306
  }
307
 
308
  function saswp_step5(){
 
309
  global $saswp_installer_config;
310
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
311
  ?>
@@ -355,7 +365,8 @@
355
 
356
 
357
 
358
- function saswp_save_steps_data(){
 
359
  if ( ! isset( $_POST['wpnonce'] ) ){
360
  return;
361
  }
@@ -363,43 +374,57 @@
363
  return;
364
  }
365
  if(isset($_POST['sd_data'])){
 
366
  $pre_sd_data = get_option('sd_data');
367
  $pre_sd_data['sd_initial_wizard_status'] =1;
368
  $sd_data = $_POST['sd_data'];
 
369
  if($pre_sd_data){
 
370
  $sd_data = array_merge($pre_sd_data,$sd_data);
371
  }
372
  update_option('sd_data',$sd_data);
373
  }
374
 
375
  if(isset($_POST['sd_data_create__post_schema']) && isset($_POST['sd_data_create__post_schema_checkbox'])){
 
376
  $checkbox = array_filter($_POST['sd_data_create__post_schema_checkbox']);
377
  if(count($checkbox)>0){
 
378
  foreach ($checkbox as $key => $value) {
379
- $postType = $_POST['sd_data_create__post_schema'][$key]['posttype'];
 
380
  $schemaType = $_POST['sd_data_create__post_schema'][$key]['schema_type'];
381
 
382
  $postarr = array(
383
- 'post_type'=>'saswp',
384
- 'post_title'=> ucfirst($postType),
385
- 'post_status'=>'publish',
386
- );
 
387
  $insertedPageId = wp_insert_post( $postarr );
 
388
  if($insertedPageId){
389
- $data_group_array = array();
 
 
390
  $data_group_array['group-0'] =array(
 
391
  'data_array' => array(
392
  array(
393
  'key_1' => 'post_type',
394
  'key_2' => 'equal',
395
  'key_3' => $postType,
396
  )
397
- )
 
398
  );
 
399
  $schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
400
  update_post_meta( $insertedPageId, 'data_group_array', $data_group_array);
401
  update_post_meta( $insertedPageId, 'schema_type', $schemaType);
402
  update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
 
403
  }
404
  }
405
 
@@ -453,7 +478,7 @@
453
 
454
  <footer class="merlin__content__footer merlin__content__footer--fullwidth">
455
 
456
- <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=saswp&page=structured_data_options' ) ); ?>" class="merlin__button merlin__button--blue merlin__button--fullwidth merlin__button--popin"><?php echo esc_html( 'Let\'s Go' ); ?></a>
457
 
458
  <ul class="merlin__drawer merlin__drawer--extras">
459
 
@@ -527,12 +552,12 @@
527
  function saswp_makesvg( $args = array() ){
528
  // Make sure $args are an array.
529
  if ( empty( $args ) ) {
530
- return __( 'Please define default parameters in the form of an array.', 'accelerated-mobile-pages' );
531
  }
532
 
533
  // Define an icon.
534
  if ( false === array_key_exists( 'icon', $args ) ) {
535
- return __( 'Please define an SVG icon filename.', 'accelerated-mobile-pages' );
536
  }
537
 
538
  // Set defaults.
@@ -566,12 +591,12 @@
566
 
567
  // If there is a title, display it.
568
  if ( $args['title'] ) {
569
- $svg .= '<title>' . esc_html( $args['title'] ) . '</title>';
570
  }
571
 
572
  // If there is a description, display it.
573
  if ( $args['desc'] ) {
574
- $svg .= '<desc>' . esc_html( $args['desc'] ) . '</desc>';
575
  }
576
 
577
  $svg .= '<use xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use>';
@@ -636,12 +661,15 @@
636
 
637
 
638
  function saswp_general_setting_fields_callback(){
 
639
  global $sd_data;
640
  $settings = $sd_data;
641
  $saswp_kb_type ='';
 
642
  if(isset($sd_data['saswp_kb_type'])){
643
  $saswp_kb_type = $sd_data['saswp_kb_type'];
644
  }
 
645
  $returnHtml = '<li class="saswp_fields">
646
  <label>'.esc_html__('Data Type', 'schema-and-structured-data-for-wp').'</label>
647
  <select name="sd_data[saswp_kb_type]">
@@ -675,58 +703,53 @@ function saswp_general_setting_fields_callback(){
675
  }
676
 
677
  function saswp_social_profile_fields_callback(){
 
678
  global $sd_data;
679
- $settings = $sd_data;
680
- $sd_facebook ='';
681
- $sd_twitter ='';
682
- $sd_linkedin ='';
683
- $sd_instagram ='';
684
 
685
- if(isset($settings['sd_facebook'])){
686
- $sd_facebook = $settings['sd_facebook'];
687
- }
688
- if(isset($settings['sd_twitter'])){
689
- $sd_twitter = $settings['sd_twitter'];
690
- }
691
- if(isset($settings['sd_linkedin'])){
692
- $sd_linkedin = $settings['sd_linkedin'];
693
- }
694
- if(isset($settings['sd_instagram'])){
695
- $sd_instagram = $settings['sd_instagram'];
696
- }
697
  $returnHtml = '
698
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
699
  <input type="checkbox" name="sd_data[saswp-facebook-enable]" id="saswp-facebook-enable" class="checkbox" value="1" '.($sd_facebook!=''? 'checked': '').'>
700
  <label for="saswp-facebook-enable"><i></i><span>'.esc_html__('Facebook', 'schema-and-structured-data-for-wp').'</span></label>
701
- <input type="text" name="sd_data[sd_facebook]" value="'.$sd_facebook.'" placeholder="'.esc_html__('Enter Facebook Page UR', 'schema-and-structured-data-for-wp').'">
702
  </li>
703
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
704
  <input type="checkbox" name="sd_data[saswp-twitter-enable]" id="saswp-twitter-enable" class="checkbox" value="1" '.($sd_twitter!=''? 'checked': '').'>
705
  <label for="saswp-twitter-enable"><i></i><span>'.esc_html__('Twitter', 'schema-and-structured-data-for-wp').'</span></label>
706
- <input type="text" name="sd_data[sd_twitter]" value="'.$sd_twitter.'" placeholder="'.esc_html__('Enter Twitter Page UR', 'schema-and-structured-data-for-wp').'">
707
  </li>
708
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
709
  <input type="checkbox" name="sd_data[saswp-linkedin-enable]" id="saswp-linkedin-enable" class="checkbox" value="1" '.($sd_linkedin!=''? 'checked': '').'>
710
  <label for="saswp-linkedin-enable"><i></i><span>'.esc_html__('Linkedin', 'schema-and-structured-data-for-wp').'</span></label>
711
- <input type="text" name="sd_data[sd_linkedin]" value="'.$sd_linkedin.'" placeholder="'.esc_html__('Enter Linkedin Page UR', 'schema-and-structured-data-for-wp').'">
712
  </li>
713
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
714
  <input type="checkbox" name="sd_data[saswp-instagram-enable]" id="saswp-instagram-enable" class="checkbox" value="1" '.($sd_instagram!=''? 'checked': '').'>
715
  <label for="saswp-instagram-enable"><i></i><span>'.esc_html__('Instagram', 'schema-and-structured-data-for-wp').'</span></label>
716
- <input type="text" name="sd_data[sd_instagram]" value="'.$sd_instagram.'" placeholder="'.esc_html__('Enter Linkedin Page UR', 'schema-and-structured-data-for-wp').'">
717
  </li>';
718
  return $returnHtml;
719
  }
720
 
721
  function saswp_select_schema_fields_callback(){
 
722
  global $sd_data;
723
  $returnHtml = $post_types = '';
724
  $post_types = get_post_types( array( 'public' => true ), 'names' );
725
  // Remove Unsupported Post types
726
  unset($post_types['attachment'], $post_types['amp_acf'], $post_types['saswp']);
727
  $option = '';
 
728
  if(count($post_types)>0){
 
729
  foreach ($post_types as $key => $value) {
 
730
  $returnHtml .= '<li class="merlin__drawer--import-content__list-item status post-type-fields">
731
  <input type="checkbox" name="sd_data_create__post_schema_checkbox['.$key.']" id="sd_data_create__post_schema_'.$key.'" class="checkbox" value="1" >
732
  <label for="sd_data_create__post_schema_'.$key.'"><i></i><span>'.ucfirst($value).'</span></label>
15
  $saswp_installer_config = array(
16
  'installer_dir' => 'plugin-installer',
17
  'plugin_title' => esc_html__( ucfirst( 'Schema & Structured Data for WP' ), 'schema-and-structured-data-for-wp'),
18
+ 'start_steps' => 1,
19
+ 'total_steps' => 5,
20
  'installerpage' => 'saswp-setup-wizard',
21
+ 'dev_mode' => false,
22
+ 'steps' => array(
23
  1=>array(
24
  'title'=>esc_html__('Welcome', 'schema-and-structured-data-for-wp'),
25
  'fields'=>'',
46
  'fields'=>'',
47
  ),
48
  ),
49
+ 'current_step' =>array(
50
  'title'=>'',
51
  'step_id'=>1
52
  )
55
  add_action( 'admin_init', 'saswp_installer_init');
56
  add_action( 'admin_footer', 'saswp_svg_sprite');
57
  add_action( 'wp_ajax_saswp_save_installer', 'saswp_save_steps_data', 10, 0 );
58
+
59
  function saswp_add_admin_menu(){
60
+
61
  global $saswp_installer_config;
62
  saswp_installer_init();
63
+
64
  }
65
 
66
  function saswp_installer_init(){
81
  }
82
 
83
  function saswp_steps_call(){
84
+
85
  global $saswp_installer_config;
86
  if ( !wp_verify_nonce($_GET['_saswp_nonce'], 'saswp_install_wizard_nonce') || empty( $_GET['page'] ) || $saswp_installer_config['installerpage'] !== $_GET['page'] ) {
87
  return;
104
  wp_localize_script( 'saswp_install', 'saswp_install_params', array(
105
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
106
  'wpnonce' => wp_create_nonce( 'saswp_install_nonce' ),
107
+ 'pluginurl' => SASWP_DIR_URI,
108
  ) );
109
 
110
 
129
 
130
  </div>
131
 
132
+ <?php echo sprintf( '<a class="return-to-dashboard" href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=structured_data_options' ) ), esc_html__( 'Return to dashboard', 'schema-and-structured-data-for-wp' ) ); ?>
133
 
134
  </div>
135
 
138
  }
139
 
140
  function saswp_show_steps_body(){
141
+
142
  global $saswp_installer_config;
143
  if($saswp_installer_config['total_steps']==$saswp_installer_config['current_step']['step_id']){
144
  call_user_func('saswp_finish_page');
153
 
154
 
155
  function saswp_step1(){
156
+
157
  global $saswp_installer_config;
158
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
159
  ?>
166
 
167
  <h1><?php echo esc_attr($stepDetails['title']); ?></h1>
168
 
169
+ <p><?php echo esc_html__( 'This Installation Wizard helps you to setup the necessary options for schema & structured data. It is optional & should take only a few minutes.', 'schema-and-structured-data-for-wp' ); ?></p>
170
 
171
  </div>
172
 
173
  <footer class="merlin__content__footer">
174
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=structured_data_options' ) ); ?>" class="merlin__button merlin__button--skip"><?php echo esc_html__( 'Cancel', 'schema-and-structured-data-for-wp' ); ?></a>
175
 
176
+ <a href="<?php echo esc_url( saswp_step_next_link() ); ?>" class="merlin__button merlin__button--next merlin__button--proceed merlin__button--colorchange"><?php echo esc_html__( 'Start', 'schema-and-structured-data-for-wp' ); ?></a>
177
  <?php wp_nonce_field( 'saswp_install_nonce' ); ?>
178
  </footer>
179
  <?php
180
  }
181
 
182
  function saswp_step2(){
183
+
184
  global $saswp_installer_config;
185
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
186
 
226
  }
227
 
228
  function saswp_step3(){
229
+
230
  global $saswp_installer_config;
231
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
232
  ?>
271
  }
272
 
273
  function saswp_step4(){
274
+
275
  global $saswp_installer_config;
276
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
277
  ?>
315
  }
316
 
317
  function saswp_step5(){
318
+
319
  global $saswp_installer_config;
320
  $stepDetails = $saswp_installer_config['steps'][$saswp_installer_config['current_step']['step_id']];
321
  ?>
365
 
366
 
367
 
368
+ function saswp_save_steps_data(){
369
+
370
  if ( ! isset( $_POST['wpnonce'] ) ){
371
  return;
372
  }
374
  return;
375
  }
376
  if(isset($_POST['sd_data'])){
377
+
378
  $pre_sd_data = get_option('sd_data');
379
  $pre_sd_data['sd_initial_wizard_status'] =1;
380
  $sd_data = $_POST['sd_data'];
381
+
382
  if($pre_sd_data){
383
+
384
  $sd_data = array_merge($pre_sd_data,$sd_data);
385
  }
386
  update_option('sd_data',$sd_data);
387
  }
388
 
389
  if(isset($_POST['sd_data_create__post_schema']) && isset($_POST['sd_data_create__post_schema_checkbox'])){
390
+
391
  $checkbox = array_filter($_POST['sd_data_create__post_schema_checkbox']);
392
  if(count($checkbox)>0){
393
+
394
  foreach ($checkbox as $key => $value) {
395
+
396
+ $postType = $_POST['sd_data_create__post_schema'][$key]['posttype'];
397
  $schemaType = $_POST['sd_data_create__post_schema'][$key]['schema_type'];
398
 
399
  $postarr = array(
400
+ 'post_type' => 'saswp',
401
+ 'post_title' => ucfirst($postType),
402
+ 'post_status' => 'publish',
403
+ );
404
+
405
  $insertedPageId = wp_insert_post( $postarr );
406
+
407
  if($insertedPageId){
408
+
409
+ $data_group_array = array();
410
+
411
  $data_group_array['group-0'] =array(
412
+
413
  'data_array' => array(
414
  array(
415
  'key_1' => 'post_type',
416
  'key_2' => 'equal',
417
  'key_3' => $postType,
418
  )
419
+ )
420
+
421
  );
422
+
423
  $schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
424
  update_post_meta( $insertedPageId, 'data_group_array', $data_group_array);
425
  update_post_meta( $insertedPageId, 'schema_type', $schemaType);
426
  update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
427
+
428
  }
429
  }
430
 
478
 
479
  <footer class="merlin__content__footer merlin__content__footer--fullwidth">
480
 
481
+ <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=saswp&page=structured_data_options' ) ); ?>" class="merlin__button merlin__button--blue merlin__button--fullwidth merlin__button--popin"><?php echo esc_html__( 'Let\'s Go' ,'schema-and-structured-data-for-wp'); ?></a>
482
 
483
  <ul class="merlin__drawer merlin__drawer--extras">
484
 
552
  function saswp_makesvg( $args = array() ){
553
  // Make sure $args are an array.
554
  if ( empty( $args ) ) {
555
+ return __( 'Please define default parameters in the form of an array.', 'schema-and-structured-data-for-wp' );
556
  }
557
 
558
  // Define an icon.
559
  if ( false === array_key_exists( 'icon', $args ) ) {
560
+ return __( 'Please define an SVG icon filename.', 'schema-and-structured-data-for-wp' );
561
  }
562
 
563
  // Set defaults.
591
 
592
  // If there is a title, display it.
593
  if ( $args['title'] ) {
594
+ $svg .= '<title>' . esc_html__( $args['title'], 'schema-and-structured-data-for-wp' ) . '</title>';
595
  }
596
 
597
  // If there is a description, display it.
598
  if ( $args['desc'] ) {
599
+ $svg .= '<desc>' . esc_html__( $args['desc'], 'schema-and-structured-data-for-wp' ) . '</desc>';
600
  }
601
 
602
  $svg .= '<use xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use>';
661
 
662
 
663
  function saswp_general_setting_fields_callback(){
664
+
665
  global $sd_data;
666
  $settings = $sd_data;
667
  $saswp_kb_type ='';
668
+
669
  if(isset($sd_data['saswp_kb_type'])){
670
  $saswp_kb_type = $sd_data['saswp_kb_type'];
671
  }
672
+
673
  $returnHtml = '<li class="saswp_fields">
674
  <label>'.esc_html__('Data Type', 'schema-and-structured-data-for-wp').'</label>
675
  <select name="sd_data[saswp_kb_type]">
703
  }
704
 
705
  function saswp_social_profile_fields_callback(){
706
+
707
  global $sd_data;
 
 
 
 
 
708
 
709
+ $settings = $sd_data;
710
+ $sd_facebook = saswp_remove_warnings($settings, 'sd_facebook', 'saswp_string');
711
+ $sd_twitter = saswp_remove_warnings($settings, 'sd_twitter', 'saswp_string');
712
+ $sd_linkedin = saswp_remove_warnings($settings, 'sd_linkedin', 'saswp_string');
713
+ $sd_instagram = saswp_remove_warnings($settings, 'sd_instagram', 'saswp_string');
714
+
715
+
 
 
 
 
 
716
  $returnHtml = '
717
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
718
  <input type="checkbox" name="sd_data[saswp-facebook-enable]" id="saswp-facebook-enable" class="checkbox" value="1" '.($sd_facebook!=''? 'checked': '').'>
719
  <label for="saswp-facebook-enable"><i></i><span>'.esc_html__('Facebook', 'schema-and-structured-data-for-wp').'</span></label>
720
+ <input type="text" name="sd_data[sd_facebook]" value="'.esc_url($sd_facebook).'" placeholder="'.esc_html__('Enter Facebook Page UR', 'schema-and-structured-data-for-wp').'">
721
  </li>
722
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
723
  <input type="checkbox" name="sd_data[saswp-twitter-enable]" id="saswp-twitter-enable" class="checkbox" value="1" '.($sd_twitter!=''? 'checked': '').'>
724
  <label for="saswp-twitter-enable"><i></i><span>'.esc_html__('Twitter', 'schema-and-structured-data-for-wp').'</span></label>
725
+ <input type="text" name="sd_data[sd_twitter]" value="'.esc_url($sd_twitter).'" placeholder="'.esc_html__('Enter Twitter Page UR', 'schema-and-structured-data-for-wp').'">
726
  </li>
727
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
728
  <input type="checkbox" name="sd_data[saswp-linkedin-enable]" id="saswp-linkedin-enable" class="checkbox" value="1" '.($sd_linkedin!=''? 'checked': '').'>
729
  <label for="saswp-linkedin-enable"><i></i><span>'.esc_html__('Linkedin', 'schema-and-structured-data-for-wp').'</span></label>
730
+ <input type="text" name="sd_data[sd_linkedin]" value="'.esc_url($sd_linkedin).'" placeholder="'.esc_html__('Enter Linkedin Page UR', 'schema-and-structured-data-for-wp').'">
731
  </li>
732
  <li class="merlin__drawer--import-content__list-item status saswp-social-fields">
733
  <input type="checkbox" name="sd_data[saswp-instagram-enable]" id="saswp-instagram-enable" class="checkbox" value="1" '.($sd_instagram!=''? 'checked': '').'>
734
  <label for="saswp-instagram-enable"><i></i><span>'.esc_html__('Instagram', 'schema-and-structured-data-for-wp').'</span></label>
735
+ <input type="text" name="sd_data[sd_instagram]" value="'.esc_url($sd_instagram).'" placeholder="'.esc_html__('Enter Linkedin Page UR', 'schema-and-structured-data-for-wp').'">
736
  </li>';
737
  return $returnHtml;
738
  }
739
 
740
  function saswp_select_schema_fields_callback(){
741
+
742
  global $sd_data;
743
  $returnHtml = $post_types = '';
744
  $post_types = get_post_types( array( 'public' => true ), 'names' );
745
  // Remove Unsupported Post types
746
  unset($post_types['attachment'], $post_types['amp_acf'], $post_types['saswp']);
747
  $option = '';
748
+
749
  if(count($post_types)>0){
750
+
751
  foreach ($post_types as $key => $value) {
752
+
753
  $returnHtml .= '<li class="merlin__drawer--import-content__list-item status post-type-fields">
754
  <input type="checkbox" name="sd_data_create__post_schema_checkbox['.$key.']" id="sd_data_create__post_schema_'.$key.'" class="checkbox" value="1" >
755
  <label for="sd_data_create__post_schema_'.$key.'"><i></i><span>'.ucfirst($value).'</span></label>
admin_section/settings.php CHANGED
@@ -8,7 +8,7 @@ add_action( 'plugin_action_links_' . plugin_basename( SASWP_DIR_NAME_FILE ), 'sa
8
  function saswp_plugin_action_links( $links ) {
9
  $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
10
  $links[] = '<a href="' . esc_url( admin_url( 'edit.php?post_type=saswp&page=structured_data_options' ) ) . '">' . esc_html__( 'Settings', 'schema-and-structured-data-for-wp' ) . '</a>';
11
- $links[] = '<a href="'. esc_url(admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce).'">' . esc_html__( 'Start setup wizard &raquo;', 'schema-and-structured-data-for-wp' ) . '</a>';
12
  return $links;
13
  }
14
 
@@ -28,7 +28,7 @@ function saswp_admin_interface_render(){
28
  if ( isset( $_GET['settings-updated'] ) ) {
29
  settings_errors();
30
  }
31
- $is_amp =false;
32
  if ( is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') || is_plugin_active('amp/amp.php') ) {
33
  $is_amp = true;
34
  }
@@ -124,8 +124,8 @@ function saswp_admin_interface_render(){
124
  <h2><?php echo esc_html__( 'Leave A Feedback', 'schema-and-structured-data-for-wp' ); ?></h2>
125
 
126
  <ul>
127
- <li><a target="_blanl" href="https://wordpress.org/support/plugin/schema-and-structured-data-for-wp/reviews/#new-post"><?php echo esc_html__( 'I would like to review this plugin', 'schema-and-structured-data-for-wp' ); ?></a></li>
128
- <li><a target="_blanl" href="http://structured-data-for-wp.com/contact-us/"><?php echo esc_html__( 'I have ideas to improve this plugin', 'schema-and-structured-data-for-wp' ); ?></a></li>
129
  <li><a href="<?php echo esc_url( admin_url( 'admin.php?page=structured_data_options&tab=support' ) ); ?>"><?php echo esc_html__( 'I need help this plugin', 'schema-and-structured-data-for-wp' ); ?></a></li>
130
  </ul>
131
  <div class="saswp-social-sharing-buttons">
@@ -318,14 +318,17 @@ function saswp_amp_page_callback(){
318
  'name' => 'sd_data[saswp-for-amp]',
319
  )
320
  ) ;
 
321
 
322
- if ( !is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') || is_plugin_active('amp/amp.php') ) {
 
323
 
324
- $non_amp_enable_field['attributes'] = array(
325
  'disabled' => 'disabled'
326
  );
327
  $non_amp_enable_field['note'] = esc_html__('AMP Plugin is not activated','schema-and-structured-data-for-wp');
328
  $settings['saswp-for-amp'] = 0;
 
329
  }
330
 
331
  $meta_fields = array(
@@ -403,7 +406,7 @@ function saswp_general_page_callback(){
403
  'name' => 'sd_data[sd_about_page]',
404
  'id' => 'sd_about_page',
405
  'echo' => 0,
406
- 'show_option_none' => esc_attr( 'Select an item' ),
407
  'option_none_value' => '',
408
  'selected' => isset($settings['sd_about_page']) ? $settings['sd_about_page'] : '',
409
  )); ?>
@@ -424,7 +427,7 @@ function saswp_general_page_callback(){
424
  'name' => 'sd_data[sd_contact_page]',
425
  'id' => 'sd_contact_page-select',
426
  'echo' => 0,
427
- 'show_option_none' => esc_attr( 'Select an item' ),
428
  'option_none_value' => '',
429
  'selected' => isset($settings['sd_contact_page']) ? $settings['sd_contact_page'] : '',
430
  )); ?>
@@ -470,14 +473,7 @@ function saswp_knowledge_page_callback(){
470
  'name' => 'sd_data[sd_url]',
471
  'class' => 'regular-text',
472
  'type' => 'text',
473
- ),
474
- array(
475
- 'label' => 'Logo',
476
- 'id' => 'sd_logo',
477
- 'name' => 'sd_data[sd_logo][url]',
478
- 'class' => 'saswp-icon upload large-text',
479
- 'type' => 'media',
480
- ),
481
  array(
482
  'label' => 'Contact details',
483
  'id' => 'saswp_kb_contact_1_checkbox',
@@ -537,6 +533,9 @@ function saswp_knowledge_page_callback(){
537
  'name' => 'sd_data[sd-person-image][url]',
538
  'class' => 'upload large-text',
539
  'type' => 'media',
 
 
 
540
  ),
541
  array(
542
  'label' => 'Phone Number',
@@ -552,6 +551,17 @@ function saswp_knowledge_page_callback(){
552
  'class' => 'regular-text',
553
  'type' => 'text',
554
  ),
 
 
 
 
 
 
 
 
 
 
 
555
 
556
  );
557
  echo '<h2>'.esc_html__('Knowledge Base','schema-and-structured-data-for-wp').'</h2>';
@@ -771,27 +781,36 @@ function saswp_check_data_imported_from($plugin_post_type_name){
771
  return $imported_from;
772
  }
773
  function saswp_import_callback(){
774
- $message = '<p>'.esc_html__('This plugin\'s data already has been imported. Do you want to import again?. click on button above button.','schema-and-structured-data-for-wp').'</p>';
775
- $schema_message = '';
776
- $schema_pro_message = '';
 
777
  $wp_seo_schema_message = '';
778
- $seo_pressor_message = '';
779
- $schema_plugin = saswp_check_data_imported_from('schema');
780
- $schema_pro_plugin = saswp_check_data_imported_from('schema_pro');
781
- $wp_seo_schema_plugin = saswp_check_data_imported_from('wp_seo_schema');
782
- $seo_pressor = saswp_check_data_imported_from('seo_pressor');
783
 
784
  if($seo_pressor->post_count !=0){
785
- $seo_pressor_message =$message;
 
 
786
  }
787
  if($schema_plugin->post_count !=0){
788
- $schema_message =$message;
 
 
789
  }
790
  if($schema_pro_plugin->post_count !=0){
791
- $schema_pro_message =$message;
 
 
792
  }
793
  if($wp_seo_schema_plugin->post_count !=0){
794
- $wp_seo_schema_message =$message;
 
 
795
  }
796
 
797
  echo '<h2>'.esc_html__('Migration','schema-and-structured-data-for-wp').'</h2>';
@@ -799,22 +818,22 @@ function saswp_import_callback(){
799
  <ul>
800
  <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__('Schema Plugin','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="schema" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
801
  <p class="saswp-imported-message"></p>
802
- <?php echo $schema_message; ?>
803
  </div>
804
  </li>
805
  <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__('Schema Pro','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="schema_pro" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
806
  <p class="saswp-imported-message"></p>
807
- <?php echo $schema_pro_message; ?>
808
  </div>
809
  </li>
810
  <li><div class="saswp-tools-field-title"><div class="saswp-tooltip"><span class="saswp-tooltiptext"><?php echo esc_html__('All the settings and data you can import from this plugin when you click start importing','schema-and-structured-data-for-wp') ?></span><strong><?php echo esc_html__('WP SEO Schema','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="wp_seo_schema" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
811
  <p class="saswp-imported-message"></p>
812
- <?php echo $wp_seo_schema_message; ?>
813
  </div>
814
  </li>
815
  <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__('SEO Pressor','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="seo_pressor" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
816
  <p class="saswp-imported-message"></p>
817
- <?php echo $seo_pressor_message; ?>
818
  </div>
819
  </li>
820
 
@@ -840,7 +859,7 @@ function saswp_import_callback(){
840
  <li>
841
  <div class="saswp-tools-field-title">
842
  <div class="saswp-tooltip"><strong><?php echo esc_html__('Reset Plugin','schema-and-structured-data-for-wp'); ?></strong></div><a href="#"class="button saswp-reset-data"><?php echo esc_html__('Reset','schema-and-structured-data-for-wp'); ?></a>
843
- <p>This will reset your settings and schema types</p>
844
  </div>
845
  </li>
846
 
@@ -923,7 +942,25 @@ function saswp_compatibility_page_callback(){
923
  'name' => 'sd_data[saswp-dw-question-answer]',
924
  )
925
  );
 
 
 
 
 
 
 
 
 
 
 
926
 
 
 
 
 
 
 
 
927
 
928
  if(!is_plugin_active('kk-star-ratings/index.php')){
929
  $kk_star['attributes'] = array(
@@ -949,7 +986,7 @@ function saswp_compatibility_page_callback(){
949
  $extratheme['attributes'] = array(
950
  'disabled' => 'disabled'
951
  );
952
- $extratheme['note'] = esc_html__('Theme is not activated','schema-and-structured-data-for-wp');
953
  $settings['saswp-extra'] = 0;
954
  }
955
 
@@ -968,7 +1005,8 @@ function saswp_compatibility_page_callback(){
968
  $kk_star,
969
  $woocommerce,
970
  $extratheme,
971
- $dwquestiton,
 
972
 
973
  );
974
 
@@ -1116,9 +1154,11 @@ function saswp_enqueue_style_js( $hook ) {
1116
  wp_register_script( 'saswp-main-js', SASWP_PLUGIN_URL . 'admin_section/js/main-script.js', array('jquery'), SASWP_VERSION , true );
1117
 
1118
  $data = array(
1119
- 'post_id' => get_the_ID(),
1120
  'ajax_url' => admin_url( 'admin-ajax.php' ),
1121
- 'saswp_security_nonce' => wp_create_nonce('saswp_ajax_check_nonce')
 
 
1122
  );
1123
 
1124
  wp_localize_script( 'saswp-main-js', 'saswp_localize_data', $data );
8
  function saswp_plugin_action_links( $links ) {
9
  $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
10
  $links[] = '<a href="' . esc_url( admin_url( 'edit.php?post_type=saswp&page=structured_data_options' ) ) . '">' . esc_html__( 'Settings', 'schema-and-structured-data-for-wp' ) . '</a>';
11
+ $links[] = '<a href="'. esc_url( admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce).'">' . esc_html__( 'Start setup wizard &raquo;', 'schema-and-structured-data-for-wp' ) . '</a>';
12
  return $links;
13
  }
14
 
28
  if ( isset( $_GET['settings-updated'] ) ) {
29
  settings_errors();
30
  }
31
+ $is_amp = false;
32
  if ( is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') || is_plugin_active('amp/amp.php') ) {
33
  $is_amp = true;
34
  }
124
  <h2><?php echo esc_html__( 'Leave A Feedback', 'schema-and-structured-data-for-wp' ); ?></h2>
125
 
126
  <ul>
127
+ <li><a target="_blank" href="https://wordpress.org/support/plugin/schema-and-structured-data-for-wp/reviews/#new-post"><?php echo esc_html__( 'I would like to review this plugin', 'schema-and-structured-data-for-wp' ); ?></a></li>
128
+ <li><a target="_blank" href="http://structured-data-for-wp.com/contact-us/"><?php echo esc_html__( 'I have ideas to improve this plugin', 'schema-and-structured-data-for-wp' ); ?></a></li>
129
  <li><a href="<?php echo esc_url( admin_url( 'admin.php?page=structured_data_options&tab=support' ) ); ?>"><?php echo esc_html__( 'I need help this plugin', 'schema-and-structured-data-for-wp' ); ?></a></li>
130
  </ul>
131
  <div class="saswp-social-sharing-buttons">
318
  'name' => 'sd_data[saswp-for-amp]',
319
  )
320
  ) ;
321
+
322
 
323
+ if ( is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') || is_plugin_active('amp/amp.php') ) {
324
+ }else{
325
 
326
+ $non_amp_enable_field['attributes'] = array(
327
  'disabled' => 'disabled'
328
  );
329
  $non_amp_enable_field['note'] = esc_html__('AMP Plugin is not activated','schema-and-structured-data-for-wp');
330
  $settings['saswp-for-amp'] = 0;
331
+
332
  }
333
 
334
  $meta_fields = array(
406
  'name' => 'sd_data[sd_about_page]',
407
  'id' => 'sd_about_page',
408
  'echo' => 0,
409
+ 'show_option_none' => esc_html__( 'Select an item', 'schema-and-structured-data-for-wp' ),
410
  'option_none_value' => '',
411
  'selected' => isset($settings['sd_about_page']) ? $settings['sd_about_page'] : '',
412
  )); ?>
427
  'name' => 'sd_data[sd_contact_page]',
428
  'id' => 'sd_contact_page-select',
429
  'echo' => 0,
430
+ 'show_option_none' => esc_html( 'Select an item', 'schema-and-structured-data-for-wp' ),
431
  'option_none_value' => '',
432
  'selected' => isset($settings['sd_contact_page']) ? $settings['sd_contact_page'] : '',
433
  )); ?>
473
  'name' => 'sd_data[sd_url]',
474
  'class' => 'regular-text',
475
  'type' => 'text',
476
+ ),
 
 
 
 
 
 
 
477
  array(
478
  'label' => 'Contact details',
479
  'id' => 'saswp_kb_contact_1_checkbox',
533
  'name' => 'sd_data[sd-person-image][url]',
534
  'class' => 'upload large-text',
535
  'type' => 'media',
536
+ 'attributes' => array(
537
+ 'readonly' => 'readonly'
538
+ )
539
  ),
540
  array(
541
  'label' => 'Phone Number',
551
  'class' => 'regular-text',
552
  'type' => 'text',
553
  ),
554
+ array(
555
+ 'label' => 'Logo',
556
+ 'id' => 'sd_logo',
557
+ 'name' => 'sd_data[sd_logo][url]',
558
+ 'class' => 'saswp-icon upload large-text',
559
+ 'type' => 'media',
560
+ 'note' => 'According to google validation tool, Logo size must be 160*50',
561
+ 'attributes' => array(
562
+ 'readonly' => 'readonly'
563
+ )
564
+ ),
565
 
566
  );
567
  echo '<h2>'.esc_html__('Knowledge Base','schema-and-structured-data-for-wp').'</h2>';
781
  return $imported_from;
782
  }
783
  function saswp_import_callback(){
784
+
785
+ $message = 'This plugin\'s data already has been imported. Do you want to import again?. click on button above button.';
786
+ $schema_message = '';
787
+ $schema_pro_message = '';
788
  $wp_seo_schema_message = '';
789
+ $seo_pressor_message = '';
790
+ $schema_plugin = saswp_check_data_imported_from('schema');
791
+ $schema_pro_plugin = saswp_check_data_imported_from('schema_pro');
792
+ $wp_seo_schema_plugin = saswp_check_data_imported_from('wp_seo_schema');
793
+ $seo_pressor = saswp_check_data_imported_from('seo_pressor');
794
 
795
  if($seo_pressor->post_count !=0){
796
+
797
+ $seo_pressor_message = $message;
798
+
799
  }
800
  if($schema_plugin->post_count !=0){
801
+
802
+ $schema_message = $message;
803
+
804
  }
805
  if($schema_pro_plugin->post_count !=0){
806
+
807
+ $schema_pro_message = $message;
808
+
809
  }
810
  if($wp_seo_schema_plugin->post_count !=0){
811
+
812
+ $wp_seo_schema_message = $message;
813
+
814
  }
815
 
816
  echo '<h2>'.esc_html__('Migration','schema-and-structured-data-for-wp').'</h2>';
818
  <ul>
819
  <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__('Schema Plugin','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="schema" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
820
  <p class="saswp-imported-message"></p>
821
+ <?php echo '<p>'.esc_html__($schema_message, 'schema-and-structured-data-for-wp').'</p>'; ?>
822
  </div>
823
  </li>
824
  <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__('Schema Pro','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="schema_pro" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
825
  <p class="saswp-imported-message"></p>
826
+ <?php echo '<p>'.esc_html__($schema_pro_message, 'schema-and-structured-data-for-wp').'</p>'; ?>
827
  </div>
828
  </li>
829
  <li><div class="saswp-tools-field-title"><div class="saswp-tooltip"><span class="saswp-tooltiptext"><?php echo esc_html__('All the settings and data you can import from this plugin when you click start importing','schema-and-structured-data-for-wp') ?></span><strong><?php echo esc_html__('WP SEO Schema','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="wp_seo_schema" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
830
  <p class="saswp-imported-message"></p>
831
+ <?php echo '<p>'.esc_html__($wp_seo_schema_message, 'schema-and-structured-data-for-wp').'</p>'; ?>
832
  </div>
833
  </li>
834
  <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__('SEO Pressor','schema-and-structured-data-for-wp'); ?></strong></div><button data-id="seo_pressor" class="button saswp-import-plugins"><?php echo esc_html__('Start Importing','schema-and-structured-data-for-wp'); ?></button>
835
  <p class="saswp-imported-message"></p>
836
+ <?php echo '<p>'.esc_html__($seo_pressor_message, 'schema-and-structured-data-for-wp').'</p>'; ?>
837
  </div>
838
  </li>
839
 
859
  <li>
860
  <div class="saswp-tools-field-title">
861
  <div class="saswp-tooltip"><strong><?php echo esc_html__('Reset Plugin','schema-and-structured-data-for-wp'); ?></strong></div><a href="#"class="button saswp-reset-data"><?php echo esc_html__('Reset','schema-and-structured-data-for-wp'); ?></a>
862
+ <p><?php echo esc_html__('This will reset your settings and schema types','schema-and-structured-data-for-wp'); ?></p>
863
  </div>
864
  </li>
865
 
942
  'name' => 'sd_data[saswp-dw-question-answer]',
943
  )
944
  );
945
+ $yoast = array(
946
+ 'label' => 'Yoast SEO Plugin',
947
+ 'id' => 'saswp-yoast-checkbox',
948
+ 'name' => 'saswp-yoast-checkbox',
949
+ 'type' => 'checkbox',
950
+ 'class' => 'checkbox saswp-checkbox',
951
+ 'hidden' => array(
952
+ 'id' => 'saswp-yoast',
953
+ 'name' => 'sd_data[saswp-yoast]',
954
+ )
955
+ );
956
 
957
+ if(!is_plugin_active('wordpress-seo/wp-seo.php')){
958
+ $yoast['attributes'] = array(
959
+ 'disabled' => 'disabled'
960
+ );
961
+ $yoast['note'] = esc_html__('Plugin is not activated','schema-and-structured-data-for-wp');
962
+ $settings['saswp-yoast'] = 0;
963
+ }
964
 
965
  if(!is_plugin_active('kk-star-ratings/index.php')){
966
  $kk_star['attributes'] = array(
986
  $extratheme['attributes'] = array(
987
  'disabled' => 'disabled'
988
  );
989
+ $extratheme['note'] = esc_html__('Theme is not activated','schema-and-structured-data-for-wp');
990
  $settings['saswp-extra'] = 0;
991
  }
992
 
1005
  $kk_star,
1006
  $woocommerce,
1007
  $extratheme,
1008
+ $dwquestiton,
1009
+ $yoast
1010
 
1011
  );
1012
 
1154
  wp_register_script( 'saswp-main-js', SASWP_PLUGIN_URL . 'admin_section/js/main-script.js', array('jquery'), SASWP_VERSION , true );
1155
 
1156
  $data = array(
1157
+ 'post_id' => get_the_ID(),
1158
  'ajax_url' => admin_url( 'admin-ajax.php' ),
1159
+ 'saswp_security_nonce' => wp_create_nonce('saswp_ajax_check_nonce'),
1160
+ 'new_url_selector' => esc_url(admin_url()).'post-new.php?post_type=saswp',
1161
+ 'new_url_href' => htmlspecialchars_decode(wp_nonce_url(admin_url('index.php?page=saswp_add_new_data_type&'), '_wpnonce'))
1162
  );
1163
 
1164
  wp_localize_script( 'saswp-main-js', 'saswp_localize_data', $data );
admin_section/structure_admin.php CHANGED
@@ -1,4 +1,47 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  function saswp_reset_all_settings(){
3
 
4
  if ( ! isset( $_POST['saswp_security_nonce'] ) ){
@@ -9,10 +52,14 @@ function saswp_reset_all_settings(){
9
  }
10
  $result ='';
11
 
12
- update_option( 'sd_data', array());
 
13
  $allposts= get_posts( array('post_type'=>'saswp','numberposts'=>-1) );
 
14
  foreach ($allposts as $eachpost) {
 
15
  $result = wp_delete_post( $eachpost->ID, true );
 
16
  }
17
 
18
  if($result){
@@ -26,31 +73,29 @@ function saswp_reset_all_settings(){
26
  add_action('wp_ajax_saswp_reset_all_settings', 'saswp_reset_all_settings');
27
 
28
  function saswp_load_plugin_textdomain() {
 
29
  load_plugin_textdomain( 'schema-and-structured-data-for-wp', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
 
30
  }
31
  add_action( 'plugins_loaded', 'saswp_load_plugin_textdomain' );
32
 
33
- //FrontEnd
34
  function saswp_get_all_schema_posts(){
35
- $post_idArray = array();
36
- $query = new WP_Query(
37
- array(
38
- 'post_type' => 'saswp',
39
- 'post_status' => 'publish',
40
- 'posts_per_page' => -1,
41
- ));
42
- while ($query->have_posts()) {
43
- $query->the_post();
44
- $post_idArray[] = get_the_ID();
45
- }
46
- wp_reset_query();
47
- wp_reset_postdata();
48
-
49
- if(count($post_idArray)>0){
50
  $returnData = array();
51
- foreach ($post_idArray as $key => $post_id)
52
- {
 
53
  $unique_checker ='';
 
54
  $resultset = saswp_generate_field_data( $post_id );
55
 
56
  if($resultset){
@@ -62,66 +107,94 @@ function saswp_get_all_schema_posts(){
62
  $data = array_filter($result);
63
  $number_of_fields = count($data);
64
  $checker = 0;
65
- // Check if we have more then 1 fields.
66
  if ( $number_of_fields > 0 ) {
67
- // Check if all the arrays have TRUE setup, then send the value 1, if all the
68
- // values are same.
69
  $checker = count( array_unique($data) );
70
- // Check and make sure only all TRUE values only passed on, if all values are FALSE,
71
- // then making sure all FALSE are converting to 0, and returing false.
72
- // Code will not run.
73
  $array_is_false = in_array(false, $result);
 
74
  if ( $array_is_false ) {
 
75
  $checker = 0;
 
76
  }
 
77
  }
 
78
  $condition_array[] = $checker;
 
79
  }
80
  $array_is_true = in_array(true,$condition_array);
 
81
  if($array_is_true){
 
82
  $unique_checker = 1;
83
- }
 
 
84
  }else{
 
85
  $unique_checker ='notset';
 
86
  }
87
 
88
  if ( $unique_checker === 1 || $unique_checker === true || $unique_checker == 'notset') {
 
89
  $conditions = array();
90
 
91
  $data_group_array = get_post_meta( $post_id, 'data_group_array', true);
 
92
  if(isset($data_group_array['group-0'])){
93
- $conditions = $data_group_array['group-0']['data_array'];
 
 
94
  }
95
  if(isset($conditions[0])){
96
- $conditions = $conditions[0];
97
- }
 
 
 
98
  $returnData[] = array(
99
- 'schema_type' => get_post_meta( $post_id, 'schema_type', true),
100
- 'schema_options' => get_post_meta( $post_id, 'schema_options', true),
101
- 'conditions' => $conditions,
102
- 'post_id' => $post_id,
103
  );
 
104
  }
105
 
106
- }//foreach closed post_idArray
 
107
  return $returnData;
108
- }//iF Closed post_idArray
 
 
 
109
  return false;
110
  }
111
 
112
  function saswp_generate_field_data( $post_id ){
 
113
  $data_group_array = get_post_meta( $post_id, 'data_group_array', true);
114
  $output = array();
115
- if($data_group_array){
116
- foreach ($data_group_array as $gropu){
117
- $output[] = array_map('saswp_comparison_logic_checker', $gropu['data_array']);
118
- }
 
 
 
 
119
 
120
  }
121
  return $output;
 
122
  }
123
 
124
  function saswp_comparison_logic_checker($input){
 
125
  global $post;
126
  $type = $input['key_1'];
127
  $comparison = $input['key_2'];
@@ -132,13 +205,20 @@ function saswp_comparison_logic_checker($input){
132
  $user = wp_get_current_user();
133
 
134
  switch ($type) {
135
- case 'show_globally':
 
 
136
  $result = true;
 
137
  break;
138
  // Basic Controls ------------
139
  // Posts Type
140
  case 'post_type':
141
- $current_post_type = $post->post_type;
 
 
 
 
142
  if ( $comparison == 'equal' ) {
143
  if ( $current_post_type == $data ) {
144
  $result = true;
@@ -199,8 +279,14 @@ function saswp_comparison_logic_checker($input){
199
 
200
  // Post Category
201
  case 'post_category':
 
 
202
  $postcat = get_the_category( $post->ID );
203
- $current_category = $postcat[0]->cat_ID;
 
 
 
 
204
 
205
  if ( $comparison == 'equal') {
206
  if ( $data == $current_category ) {
@@ -344,20 +430,25 @@ function saswp_comparison_logic_checker($input){
344
  require_once( untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/ajax-selectbox.php' );
345
  //Back End
346
  if(is_admin()){
 
347
  add_action( 'init', 'saswp_create_post_type' );
 
348
  function saswp_create_post_type() {
 
349
  $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
350
  $not_found_button = '<div><span class="dashicons dashicons-thumbs-up"></span>'.esc_html__("Thank you for using Schema & Structured Data For WP plugin!",'schema-and-structured-data-for-wp').' <a href="'.esc_url(admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce).'">'.esc_html__("Start Quick Setup?",'schema-and-structured-data-for-wp').'</a></div>';
 
351
  register_post_type( 'saswp',
 
352
  array(
353
  'labels' => array(
354
  'name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
355
  'singular_name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
356
- 'add_new' => esc_html__( 'Add Schema Type', 'schema-and-structured-data-for-wp' ),
357
- 'add_new_item' => esc_html__( '', 'schema-and-structured-data-for-wp' ),
358
  'edit_item' => esc_html__( 'Edit Schema Type','schema-and-structured-data-for-wp'),
359
- 'all_items' => esc_html__( 'Schema Types', 'schema-and-structured-data-for-wp' ),
360
- 'not_found' => $not_found_button
361
  ),
362
  'public' => true,
363
  'has_archive' => false,
@@ -376,35 +467,27 @@ if(is_admin()){
376
 
377
  }
378
 
379
-
380
- add_action( 'admin_head','saswp_change_add_new_url');
381
- function saswp_change_add_new_url() {
382
-
383
- ?>
384
-
385
- <script type="text/javascript">
386
- jQuery(function($) {
387
- $('a[href="<?php echo esc_url(admin_url()); ?>post-new.php?post_type=saswp"]').attr( 'href', '<?php echo htmlspecialchars_decode(wp_nonce_url(admin_url('index.php?page=saswp_add_new_data_type&'), '_wpnonce')); ?>');
388
- });
389
- </script>
390
- <?php
391
- }
392
-
393
-
394
-
395
  function saswp_select_callback($post) {
396
 
397
  $data_group_array = esc_sql ( get_post_meta($post->ID, 'data_group_array', true) );
398
- $data_group_array = is_array($data_group_array)? array_values($data_group_array): array();
 
399
  if ( empty( $data_group_array ) ) {
 
400
  $data_group_array[0] =array(
 
401
  'data_array' => array(
 
402
  array(
 
403
  'key_1' => 'post_type',
404
  'key_2' => 'equal',
405
  'key_3' => 'none',
 
406
  )
407
- )
 
 
408
  );
409
  }
410
  //security check
@@ -414,33 +497,34 @@ function saswp_change_add_new_url() {
414
  // Type Select
415
  $choices = array(
416
  esc_html__("Basic",'schema-and-structured-data-for-wp') => array(
417
- 'post_type' => esc_html__("Post Type",'schema-and-structured-data-for-wp'),
418
- 'show_globally' => esc_html__("Show Globally",'ads-for-wp'),
419
- 'user_type' => esc_html__("Logged in User Type",'schema-and-structured-data-for-wp'),
420
  ),
421
  esc_html__("Post",'schema-and-structured-data-for-wp') => array(
422
- 'post' => esc_html__("Post",'schema-and-structured-data-for-wp'),
423
- 'post_category' => esc_html__("Post Category",'schema-and-structured-data-for-wp'),
424
- 'post_format' => esc_html__("Post Format",'schema-and-structured-data-for-wp'),
425
  ),
426
  esc_html__("Page",'schema-and-structured-data-for-wp') => array(
427
- 'page' => esc_html__("Page",'schema-and-structured-data-for-wp'),
428
- 'page_template' => esc_html__("Page Template",'schema-and-structured-data-for-wp'),
429
  ),
430
  esc_html__("Other",'schema-and-structured-data-for-wp') => array(
431
- 'ef_taxonomy' => esc_html__("Taxonomy Term",'schema-and-structured-data-for-wp'),
432
  )
433
  );
434
 
435
  $comparison = array(
436
- 'equal' => esc_html__( 'Equal to', 'schema-and-structured-data-for-wp'),
437
- 'not_equal' => esc_html__( 'Not Equal to (Exclude)', 'schema-and-structured-data-for-wp'),
438
  );
439
 
440
  $total_group_fields = count( $data_group_array ); ?>
441
  <div class="saswp-placement-groups">
442
 
443
  <?php for ($j=0; $j < $total_group_fields; $j++) {
 
444
  $data_array = $data_group_array[$j]['data_array'];
445
 
446
  $total_fields = count( $data_array );
@@ -514,7 +598,7 @@ function saswp_change_add_new_url() {
514
  <?php } ?>
515
 
516
 
517
- <a style="margin-left: 8px; margin-bottom: 8px;" class="button saswp-placement-or-group saswp-placement-button" href="#">Or</a>
518
  </div>
519
  <?php
520
  }
@@ -526,8 +610,11 @@ function saswp_change_add_new_url() {
526
  * so that it is after the script was enqueued.
527
  */
528
  function saswp_dequeue_script() {
 
529
  if(get_post_type() == 'saswp'){
 
530
  wp_dequeue_script( 'avada-fusion-options' );
 
531
  }
532
  }
533
  add_action( 'wp_print_scripts', 'saswp_dequeue_script', 100 );
@@ -536,39 +623,48 @@ add_action( 'wp_print_scripts', 'saswp_dequeue_script', 100 );
536
 
537
 
538
  function saswp_style_script_include($hook) {
 
539
  global $pagenow, $typenow;
540
 
541
  if (is_admin()) {
542
 
543
  if($hook == 'saswp' || get_post_type() == 'saswp'){
544
- wp_dequeue_script( 'avada-fusion-options' );
 
 
545
  }
546
 
547
  wp_register_script( 'structure_admin', plugin_dir_url(__FILE__) . '/js/structure_admin.js', array( 'jquery'), SASWP_VERSION, true );
 
548
  $post_type='';
549
  $current_screen = get_Current_screen();
 
550
  if(isset($current_screen->post_type)){
551
- $post_type = $current_screen->post_type;
552
- }
553
- $saswp_posts = get_posts(
554
- array(
555
- 'post_type' => 'saswp',
556
- 'posts_per_page' => -1,
557
- 'post_status' => 'publish',
558
- )
559
- );
560
  $post_found_status ='';
561
- if(!$saswp_posts){
 
 
 
 
562
  $post_found_status ='not_found';
 
563
  }
564
  $data_array = array(
565
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
 
566
  'post_found_status' => $post_found_status,
567
- 'post_type' =>$post_type,
568
- 'page_now' => $hook,
 
569
  );
 
570
  wp_localize_script( 'structure_admin', 'saswp_app_object', $data_array );
571
- wp_enqueue_script('structure_admin');
572
 
573
  wp_enqueue_script( 'saswp-timepicker-js', SASWP_PLUGIN_URL . 'admin_section/js/jquery.timepicker.js', false, SASWP_VERSION);
574
  //Main Css
@@ -580,8 +676,10 @@ add_action( 'wp_print_scripts', 'saswp_dequeue_script', 100 );
580
 
581
  //Enque select 2 script starts here
582
  if($hook == 'saswp' || get_post_type() == 'saswp'){
 
583
  wp_enqueue_style('saswp-select2-style', SASWP_PLUGIN_URL. 'admin_section/css/select2.min.css' , false, SASWP_VERSION);
584
  wp_enqueue_script('saswp-select2-script', SASWP_PLUGIN_URL. 'admin_section/js/select2.min.js', false, SASWP_VERSION);
 
585
  }
586
  //Enque select 2 script ends here
587
  }
@@ -589,7 +687,9 @@ add_action( 'wp_print_scripts', 'saswp_dequeue_script', 100 );
589
 
590
  // Save PHP Editor
591
  add_action ( 'save_post' , 'saswp_select_save_data' );
 
592
  function saswp_select_save_data ( $post_id ) {
 
593
  if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
594
 
595
  // if our nonce isn't there, or we can't verify it, bail
@@ -597,32 +697,45 @@ add_action( 'wp_print_scripts', 'saswp_dequeue_script', 100 );
597
 
598
  // if our current user can't edit this post, bail
599
  if( !current_user_can( 'edit_post' ) ) return;
 
600
  $meta_value = get_post_meta( $post_id, null, true );
 
601
  $post_data_group_array = array();
602
  $temp_condition_array = array();
603
- $show_globally =false;
 
604
  if(isset($_POST['data_group_array'])){
 
605
  $post_data_group_array = $_POST['data_group_array'];
 
606
  foreach($post_data_group_array as $groups){
 
607
  foreach($groups['data_array'] as $group ){
 
608
  if(array_search('show_globally', $group))
609
  {
 
610
  $temp_condition_array[0] = $group;
611
- $show_globally = true;
 
612
  }
613
  }
614
  }
615
  if($show_globally){
 
616
  unset($post_data_group_array);
617
  $post_data_group_array['group-0']['data_array'] = $temp_condition_array;
 
618
  }
619
  }
620
  if(isset($_POST['data_group_array'])){
 
621
  update_post_meta(
622
  $post_id,
623
  'data_group_array',
624
  $post_data_group_array
625
- );
 
626
  }
627
  }
628
 
@@ -646,6 +759,7 @@ add_action('wp','saswp_custom_breadcrumbs',99);
646
 
647
  // Breadcrumbs
648
  function saswp_custom_breadcrumbs() {
 
649
  global $sd_data;
650
  $variables1_titles = array();
651
  $variables2_links = array();
@@ -667,83 +781,91 @@ function saswp_custom_breadcrumbs() {
667
 
668
 
669
  if ( is_archive() && !is_tax() && !is_category() && !is_tag() && !is_author() ) {
670
- $archive_title = post_type_archive_title($prefix, false);
671
- $variables1_titles[] = $archive_title;
 
672
 
673
 
674
  } else if ( is_author() ) {
675
  global $author;
676
 
677
- $userdata = get_userdata( $author );
678
- $author_url= get_author_posts_url($userdata->ID);
679
 
680
  // author name
681
- $variables1_titles[]= $userdata->display_name;
682
- $variables2_links[]= $author_url;
683
 
684
  } else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
685
 
686
  // If post is a custom post type
687
- $post_type = get_post_type();
688
 
689
  // If it is a custom post type display name and link
690
- if($post_type != 'post') {
691
-
692
- $post_type_object = get_post_type_object($post_type);
693
- $post_type_archive = get_post_type_archive_link($post_type);
694
- $variables1_titles[] = $post_type_object->labels->name;
695
- $variables2_links[] = $post_type_archive;
696
-
697
- }
698
 
699
- $custom_tax_name = get_queried_object()->name;
700
- $variables1_titles[] = $custom_tax_name;
701
 
702
  } else if ( is_single() ) {
703
 
704
  // If post is a custom post type
705
- $post_type = get_post_type();
706
 
707
  // If it is a custom post type display name and link
708
  if($post_type != 'post') {
709
 
710
- $post_type_object = get_post_type_object($post_type);
711
- $post_type_archive = get_post_type_archive_link($post_type);
712
- $variables1_titles[]= $post_type_object->labels->name;
713
- $variables2_links[]= $post_type_archive;
714
  }
715
 
716
  // Get post category info
717
  $category = get_the_category();
718
 
719
  if(!empty($category)) {
 
720
  $category_values = array_values( $category );
 
721
  foreach ($category_values as $category_value) {
722
- $category_name = get_category($category_value);
723
- $cat_name = $category_name->name;
724
- $variables1_titles[]=$cat_name;
725
- $variables2_links[]=get_category_link( $category_value );
 
726
 
727
  }
728
 
729
  // Get last category post is in
730
- $last_category = end(($category));
731
- $category_name = get_category($last_category);
732
  // Get parent any categories and create array
733
  $get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
734
- $cat_parents = explode(',',$get_cat_parents);
735
 
736
  // Loop through parent categories and store in variable $cat_display
737
  $cat_display = '';
 
738
  foreach($cat_parents as $parents) {
 
739
  $cat_display .= '<li class="item-cat">'.esc_html__( $parents, 'schema-and-structured-data-for-wp' ).'</li>';
740
  $cat_display .= '<li class="separator"> ' . esc_html__( $separator, 'schema-and-structured-data-for-wp' ) . ' </li>';
 
741
  }
742
 
743
  }
744
 
745
  // If it's a custom post type within a custom taxonomy
746
  $taxonomy_exists = taxonomy_exists($custom_taxonomy);
 
747
  if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
748
 
749
  $taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
@@ -754,29 +876,38 @@ function saswp_custom_breadcrumbs() {
754
  }
755
 
756
  if(!empty($cat_id)) {
757
- $variables1_titles[]= $cat_name;
758
- $variables2_links[]=$cat_link;
759
-
 
760
  } else {
761
- if($post_type == 'post') {
 
 
762
  $variables1_titles[]= get_the_title();
763
  $variables2_links[] = get_permalink();
 
764
  }
 
765
  }
766
 
767
  } else if ( is_category() ) {
 
768
  $category = get_the_category();
769
 
770
- if(!empty($category)) {
771
- $category_values = array_values( $category );
772
- foreach ($category_values as $category_value) {
773
- $category_name = get_category($category_value);
774
- $cat_name = $category_name->name;
775
- $variables1_titles[]=$cat_name;
776
- $variables2_links[]=get_category_link( $category_value );
777
-
778
- }
779
- }
 
 
 
780
  } else if ( is_page() ) {
781
 
782
  // Standard page
@@ -790,19 +921,23 @@ function saswp_custom_breadcrumbs() {
790
 
791
  // Parent page loop
792
  if ( !isset( $parents ) ) $parents = null;
 
793
  foreach ( $anc as $ancestor ) {
 
794
  $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>';
795
  $parents .= '<li class="separator separator-' . esc_attr($ancestor) . '"> ' . esc_html__($separator, 'schema-and-structured-data-for-wp' ) . ' </li>';
796
- $variables1_titles[]= get_the_title($ancestor);
797
- $variables2_links[]=get_permalink($ancestor);
 
798
  }
799
 
800
- $variables1_titles[]= get_the_title();
801
- $variables2_links[]=get_permalink();
802
 
803
- } else {
804
- $variables1_titles[]=get_the_title();
805
- $variables2_links[]=get_permalink();
 
806
  }
807
 
808
  } else if ( is_tag() ) {
@@ -819,21 +954,21 @@ function saswp_custom_breadcrumbs() {
819
  // Tag name and link
820
 
821
  $variables1_titles[] = $get_term_name;
822
- $variables2_links[] = $term_link;
823
  }
824
 
825
- $sd_data['titles']= $variables1_titles;
826
- $sd_data['links']= $variables2_links;
827
 
828
  }
829
 
830
  }
831
 
832
-
833
  //Adding extra columns and displaying its data starts here
834
  function saswp_custom_column_set( $column, $post_id ) {
835
 
836
- switch ( $column ) {
 
837
  case 'saswp_schema_type' :
838
 
839
  $schema_type = get_post_meta( $post_id, $key='schema_type', true);
@@ -841,24 +976,48 @@ function saswp_custom_column_set( $column, $post_id ) {
841
 
842
  break;
843
  case 'saswp_target_location' :
 
844
  $enabled ='';
845
  $exclude ='';
846
  $data_group_array = get_post_meta( $post_id, $key='data_group_array', true);
 
 
847
  if($data_group_array){
 
848
  foreach ($data_group_array as $groups){
 
849
  foreach($groups['data_array'] as $group){
 
850
  if($group['key_2'] == 'equal'){
851
- $enabled .= $group['key_3'].', ';
 
 
 
 
 
 
 
 
 
 
852
  }else{
 
853
  $exclude .= $group['key_3']. ', ';
 
854
  }
 
855
  }
 
856
  }
857
  if($enabled){
858
- echo '<div><strong>'.esc_html__( 'Enable on: ', 'schema-and-structured-data-for-wp' ).'</strong> '.esc_attr($enabled).'</div>';
 
 
859
  }
860
  if($exclude){
861
- echo '<div><strong>'.esc_html__( 'Exclude from: ', 'schema-and-structured-data-for-wp' ).'</strong>'.esc_attr($exclude).'</div>';
 
 
862
  }
863
  }
864
 
@@ -876,9 +1035,10 @@ add_action( 'manage_saswp_posts_custom_column' , 'saswp_custom_column_set', 10,
876
  */
877
 
878
  function saswp_custom_columns($columns) {
 
879
  unset($columns['date']);
880
- $columns['saswp_schema_type'] = '<a>'.esc_html__( 'Type', 'schema-and-structured-data-for-wp' ).'<a>';
881
- $columns['saswp_target_location'] = '<a>'.esc_html__( 'Target Location', 'schema-and-structured-data-for-wp' ).'<a>';
882
 
883
  return $columns;
884
  }
@@ -898,8 +1058,9 @@ function saswp_send_query_message(){
898
  }
899
  if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
900
  return;
901
- }
902
- $message = sanitize_text_field($_POST['message']);
 
903
  $user = wp_get_current_user();
904
  $user_data = $user->data;
905
  $user_email = $user_data->user_email;
@@ -909,11 +1070,16 @@ function saswp_send_query_message(){
909
  $headers = 'From: '. esc_attr($user_email) . "\r\n" .
910
  'Reply-To: ' . esc_attr($user_email) . "\r\n";
911
  // Load WP components, no themes.
912
- $sent = wp_mail($sendto, $subject, strip_tags($message), $headers);
 
913
  if($sent){
914
- echo json_encode(array('status'=>'t'));
 
 
915
  }else{
916
- echo json_encode(array('status'=>'f'));
 
 
917
  }
918
  wp_die();
919
  }
@@ -935,7 +1101,9 @@ function saswp_import_plugin_data(){
935
  }
936
  $plugin_name = sanitize_text_field($_GET['plugin_name']);
937
  $result = '';
 
938
  switch ($plugin_name) {
 
939
  case 'schema':
940
  if ( is_plugin_active('schema/schema.php')) {
941
  $result = saswp_import_schema_plugin_data();
@@ -961,9 +1129,13 @@ function saswp_import_plugin_data(){
961
  break;
962
  }
963
  if($result){
964
- echo json_encode(array('status'=>'t', 'message'=>esc_html__('Data has been imported succeessfully','schema-and-structured-data-for-wp')));
 
 
965
  }else{
966
- echo json_encode(array('status'=>'f', 'message'=>esc_html__('Plugin data is not available or it is not activated','schema-and-structured-data-for-wp')));
 
 
967
  }
968
  wp_die();
969
  }
@@ -971,25 +1143,38 @@ function saswp_import_plugin_data(){
971
  add_action('wp_ajax_saswp_import_plugin_data', 'saswp_import_plugin_data');
972
 
973
 
974
- function saswp_feeback_no_thanks(){
975
- $result = update_option( "saswp_activation_never", 'never');
 
 
976
  if($result){
977
- echo json_encode(array('status'=>'t'));
 
 
978
  }else{
979
- echo json_encode(array('status'=>'f'));
980
- }
 
 
 
981
  wp_die();
982
  }
983
 
984
  add_action('wp_ajax_saswp_feeback_no_thanks', 'saswp_feeback_no_thanks');
985
 
986
 
987
- function saswp_feeback_remindme(){
988
- $result = update_option( "saswp_activation_date", date("Y-m-d"));
 
 
989
  if($result){
990
- echo json_encode(array('status'=>'t'));
 
 
991
  }else{
992
- echo json_encode(array('status'=>'f'));
 
 
993
  }
994
  wp_die();
995
  }
1
  <?php
2
+ /*
3
+ * Storing and updating all ads post ids in transient on different actions
4
+ * which we will fetch all ids from here to display our post
5
+ */
6
+ function saswp_published(){
7
+
8
+ $all_schema_post = get_posts(
9
+ array(
10
+ 'post_type' => 'saswp',
11
+ 'posts_per_page' => -1,
12
+ 'post_status' => 'publish',
13
+ )
14
+ );
15
+
16
+ $schema_post_ids = array();
17
+
18
+ foreach($all_schema_post as $val){
19
+
20
+ $schema_post_ids[] = $val->ID;
21
+
22
+ }
23
+
24
+ $schema_id_json = json_encode($schema_post_ids);
25
+ set_transient('saswp_transient_schema_ids', $schema_id_json);
26
+
27
+ }
28
+ function saswp_update_ids_on_trash(){
29
+
30
+ delete_transient('saswp_transient_schema_ids');
31
+ saswp_published();
32
+
33
+ }
34
+
35
+ function saswp_update_ids_on_untrash(){
36
+
37
+ saswp_published();
38
+
39
+ }
40
+
41
+ add_action( 'publish_saswp', 'saswp_published' );
42
+ add_action( 'trash_saswp', 'saswp_update_ids_on_trash' );
43
+ add_action( 'untrash_saswp', 'saswp_update_ids_on_untrash' );
44
+
45
  function saswp_reset_all_settings(){
46
 
47
  if ( ! isset( $_POST['saswp_security_nonce'] ) ){
52
  }
53
  $result ='';
54
 
55
+ update_option( 'sd_data', array());
56
+
57
  $allposts= get_posts( array('post_type'=>'saswp','numberposts'=>-1) );
58
+
59
  foreach ($allposts as $eachpost) {
60
+
61
  $result = wp_delete_post( $eachpost->ID, true );
62
+
63
  }
64
 
65
  if($result){
73
  add_action('wp_ajax_saswp_reset_all_settings', 'saswp_reset_all_settings');
74
 
75
  function saswp_load_plugin_textdomain() {
76
+
77
  load_plugin_textdomain( 'schema-and-structured-data-for-wp', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
78
+
79
  }
80
  add_action( 'plugins_loaded', 'saswp_load_plugin_textdomain' );
81
 
82
+
83
  function saswp_get_all_schema_posts(){
84
+
85
+ $schema_id_array = array();
86
+
87
+ $schema_id_array = json_decode(get_transient('saswp_transient_schema_ids'), true);
88
+
89
+ if($schema_id_array){
90
+
91
+ if(count($schema_id_array)>0){
92
+
 
 
 
 
 
 
93
  $returnData = array();
94
+
95
+ foreach ($schema_id_array as $post_id){
96
+
97
  $unique_checker ='';
98
+
99
  $resultset = saswp_generate_field_data( $post_id );
100
 
101
  if($resultset){
107
  $data = array_filter($result);
108
  $number_of_fields = count($data);
109
  $checker = 0;
110
+
111
  if ( $number_of_fields > 0 ) {
112
+
 
113
  $checker = count( array_unique($data) );
114
+
 
 
115
  $array_is_false = in_array(false, $result);
116
+
117
  if ( $array_is_false ) {
118
+
119
  $checker = 0;
120
+
121
  }
122
+
123
  }
124
+
125
  $condition_array[] = $checker;
126
+
127
  }
128
  $array_is_true = in_array(true,$condition_array);
129
+
130
  if($array_is_true){
131
+
132
  $unique_checker = 1;
133
+
134
+ }
135
+
136
  }else{
137
+
138
  $unique_checker ='notset';
139
+
140
  }
141
 
142
  if ( $unique_checker === 1 || $unique_checker === true || $unique_checker == 'notset') {
143
+
144
  $conditions = array();
145
 
146
  $data_group_array = get_post_meta( $post_id, 'data_group_array', true);
147
+
148
  if(isset($data_group_array['group-0'])){
149
+
150
+ $conditions = $data_group_array['group-0']['data_array'];
151
+
152
  }
153
  if(isset($conditions[0])){
154
+
155
+ $conditions = $conditions[0];
156
+
157
+ }
158
+
159
  $returnData[] = array(
160
+ 'schema_type' => get_post_meta( $post_id, 'schema_type', true),
161
+ 'schema_options' => get_post_meta( $post_id, 'schema_options', true),
162
+ 'conditions' => $conditions,
163
+ 'post_id' => $post_id,
164
  );
165
+
166
  }
167
 
168
+ }
169
+
170
  return $returnData;
171
+ }
172
+
173
+ }
174
+
175
  return false;
176
  }
177
 
178
  function saswp_generate_field_data( $post_id ){
179
+
180
  $data_group_array = get_post_meta( $post_id, 'data_group_array', true);
181
  $output = array();
182
+
183
+ if($data_group_array){
184
+
185
+ foreach ($data_group_array as $gropu){
186
+
187
+ $output[] = array_map('saswp_comparison_logic_checker', $gropu['data_array']);
188
+
189
+ }
190
 
191
  }
192
  return $output;
193
+
194
  }
195
 
196
  function saswp_comparison_logic_checker($input){
197
+
198
  global $post;
199
  $type = $input['key_1'];
200
  $comparison = $input['key_2'];
205
  $user = wp_get_current_user();
206
 
207
  switch ($type) {
208
+
209
+ case 'show_globally':
210
+
211
  $result = true;
212
+
213
  break;
214
  // Basic Controls ------------
215
  // Posts Type
216
  case 'post_type':
217
+
218
+ $current_post_type ='';
219
+ if(is_singular()){
220
+ $current_post_type = $post->post_type;
221
+ }
222
  if ( $comparison == 'equal' ) {
223
  if ( $current_post_type == $data ) {
224
  $result = true;
279
 
280
  // Post Category
281
  case 'post_category':
282
+
283
+ $current_category = '';
284
  $postcat = get_the_category( $post->ID );
285
+ if(!empty($postcat)){
286
+ if(is_object($postcat[0])){
287
+ $current_category = $postcat[0]->cat_ID;
288
+ }
289
+ }
290
 
291
  if ( $comparison == 'equal') {
292
  if ( $data == $current_category ) {
430
  require_once( untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/ajax-selectbox.php' );
431
  //Back End
432
  if(is_admin()){
433
+
434
  add_action( 'init', 'saswp_create_post_type' );
435
+
436
  function saswp_create_post_type() {
437
+
438
  $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
439
  $not_found_button = '<div><span class="dashicons dashicons-thumbs-up"></span>'.esc_html__("Thank you for using Schema & Structured Data For WP plugin!",'schema-and-structured-data-for-wp').' <a href="'.esc_url(admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce).'">'.esc_html__("Start Quick Setup?",'schema-and-structured-data-for-wp').'</a></div>';
440
+
441
  register_post_type( 'saswp',
442
+
443
  array(
444
  'labels' => array(
445
  'name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
446
  'singular_name' => esc_html__( 'Structured Data', 'schema-and-structured-data-for-wp' ),
447
+ 'add_new' => esc_html__( 'Add Schema Type', 'schema-and-structured-data-for-wp' ),
448
+ 'add_new_item' => '',
449
  'edit_item' => esc_html__( 'Edit Schema Type','schema-and-structured-data-for-wp'),
450
+ 'all_items' => esc_html__( 'Schema Types', 'schema-and-structured-data-for-wp' ),
451
+ 'not_found' => $not_found_button
452
  ),
453
  'public' => true,
454
  'has_archive' => false,
467
 
468
  }
469
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  function saswp_select_callback($post) {
471
 
472
  $data_group_array = esc_sql ( get_post_meta($post->ID, 'data_group_array', true) );
473
+ $data_group_array = is_array($data_group_array)? array_values($data_group_array): array();
474
+
475
  if ( empty( $data_group_array ) ) {
476
+
477
  $data_group_array[0] =array(
478
+
479
  'data_array' => array(
480
+
481
  array(
482
+
483
  'key_1' => 'post_type',
484
  'key_2' => 'equal',
485
  'key_3' => 'none',
486
+
487
  )
488
+
489
+ )
490
+
491
  );
492
  }
493
  //security check
497
  // Type Select
498
  $choices = array(
499
  esc_html__("Basic",'schema-and-structured-data-for-wp') => array(
500
+ 'post_type' => esc_html__("Post Type",'schema-and-structured-data-for-wp'),
501
+ 'show_globally' => esc_html__("Show Globally",'schema-and-structured-data-for-wp'),
502
+ 'user_type' => esc_html__("Logged in User Type",'schema-and-structured-data-for-wp'),
503
  ),
504
  esc_html__("Post",'schema-and-structured-data-for-wp') => array(
505
+ 'post' => esc_html__("Post",'schema-and-structured-data-for-wp'),
506
+ 'post_category' => esc_html__("Post Category",'schema-and-structured-data-for-wp'),
507
+ 'post_format' => esc_html__("Post Format",'schema-and-structured-data-for-wp'),
508
  ),
509
  esc_html__("Page",'schema-and-structured-data-for-wp') => array(
510
+ 'page' => esc_html__("Page",'schema-and-structured-data-for-wp'),
511
+ 'page_template' => esc_html__("Page Template",'schema-and-structured-data-for-wp'),
512
  ),
513
  esc_html__("Other",'schema-and-structured-data-for-wp') => array(
514
+ 'ef_taxonomy' => esc_html__("Taxonomy Term",'schema-and-structured-data-for-wp'),
515
  )
516
  );
517
 
518
  $comparison = array(
519
+ 'equal' => esc_html__( 'Equal to', 'schema-and-structured-data-for-wp'),
520
+ 'not_equal' => esc_html__( 'Not Equal to (Exclude)', 'schema-and-structured-data-for-wp'),
521
  );
522
 
523
  $total_group_fields = count( $data_group_array ); ?>
524
  <div class="saswp-placement-groups">
525
 
526
  <?php for ($j=0; $j < $total_group_fields; $j++) {
527
+
528
  $data_array = $data_group_array[$j]['data_array'];
529
 
530
  $total_fields = count( $data_array );
598
  <?php } ?>
599
 
600
 
601
+ <a style="margin-left: 8px; margin-bottom: 8px;" class="button saswp-placement-or-group saswp-placement-button" href="#"><?php echo esc_html__('Or','schema-and-structured-data-for-wp'); ?></a>
602
  </div>
603
  <?php
604
  }
610
  * so that it is after the script was enqueued.
611
  */
612
  function saswp_dequeue_script() {
613
+
614
  if(get_post_type() == 'saswp'){
615
+
616
  wp_dequeue_script( 'avada-fusion-options' );
617
+
618
  }
619
  }
620
  add_action( 'wp_print_scripts', 'saswp_dequeue_script', 100 );
623
 
624
 
625
  function saswp_style_script_include($hook) {
626
+
627
  global $pagenow, $typenow;
628
 
629
  if (is_admin()) {
630
 
631
  if($hook == 'saswp' || get_post_type() == 'saswp'){
632
+
633
+ wp_dequeue_script( 'avada-fusion-options' );
634
+
635
  }
636
 
637
  wp_register_script( 'structure_admin', plugin_dir_url(__FILE__) . '/js/structure_admin.js', array( 'jquery'), SASWP_VERSION, true );
638
+
639
  $post_type='';
640
  $current_screen = get_Current_screen();
641
+
642
  if(isset($current_screen->post_type)){
643
+
644
+ $post_type = $current_screen->post_type;
645
+
646
+ }
647
+
 
 
 
 
648
  $post_found_status ='';
649
+
650
+ $saswp_posts = json_decode(get_transient('saswp_transient_schema_ids'), true);
651
+
652
+ if(empty($saswp_posts)){
653
+
654
  $post_found_status ='not_found';
655
+
656
  }
657
  $data_array = array(
658
+
659
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
660
  'post_found_status' => $post_found_status,
661
+ 'post_type' => $post_type,
662
+ 'page_now' => $hook,
663
+
664
  );
665
+
666
  wp_localize_script( 'structure_admin', 'saswp_app_object', $data_array );
667
+ wp_enqueue_script( 'structure_admin' );
668
 
669
  wp_enqueue_script( 'saswp-timepicker-js', SASWP_PLUGIN_URL . 'admin_section/js/jquery.timepicker.js', false, SASWP_VERSION);
670
  //Main Css
676
 
677
  //Enque select 2 script starts here
678
  if($hook == 'saswp' || get_post_type() == 'saswp'){
679
+
680
  wp_enqueue_style('saswp-select2-style', SASWP_PLUGIN_URL. 'admin_section/css/select2.min.css' , false, SASWP_VERSION);
681
  wp_enqueue_script('saswp-select2-script', SASWP_PLUGIN_URL. 'admin_section/js/select2.min.js', false, SASWP_VERSION);
682
+
683
  }
684
  //Enque select 2 script ends here
685
  }
687
 
688
  // Save PHP Editor
689
  add_action ( 'save_post' , 'saswp_select_save_data' );
690
+
691
  function saswp_select_save_data ( $post_id ) {
692
+
693
  if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
694
 
695
  // if our nonce isn't there, or we can't verify it, bail
697
 
698
  // if our current user can't edit this post, bail
699
  if( !current_user_can( 'edit_post' ) ) return;
700
+
701
  $meta_value = get_post_meta( $post_id, null, true );
702
+
703
  $post_data_group_array = array();
704
  $temp_condition_array = array();
705
+ $show_globally = false;
706
+
707
  if(isset($_POST['data_group_array'])){
708
+
709
  $post_data_group_array = $_POST['data_group_array'];
710
+
711
  foreach($post_data_group_array as $groups){
712
+
713
  foreach($groups['data_array'] as $group ){
714
+
715
  if(array_search('show_globally', $group))
716
  {
717
+
718
  $temp_condition_array[0] = $group;
719
+ $show_globally = true;
720
+
721
  }
722
  }
723
  }
724
  if($show_globally){
725
+
726
  unset($post_data_group_array);
727
  $post_data_group_array['group-0']['data_array'] = $temp_condition_array;
728
+
729
  }
730
  }
731
  if(isset($_POST['data_group_array'])){
732
+
733
  update_post_meta(
734
  $post_id,
735
  'data_group_array',
736
  $post_data_group_array
737
+ );
738
+
739
  }
740
  }
741
 
759
 
760
  // Breadcrumbs
761
  function saswp_custom_breadcrumbs() {
762
+
763
  global $sd_data;
764
  $variables1_titles = array();
765
  $variables2_links = array();
781
 
782
 
783
  if ( is_archive() && !is_tax() && !is_category() && !is_tag() && !is_author() ) {
784
+
785
+ $archive_title = post_type_archive_title($prefix, false);
786
+ $variables1_titles[] = $archive_title;
787
 
788
 
789
  } else if ( is_author() ) {
790
  global $author;
791
 
792
+ $userdata = get_userdata( $author );
793
+ $author_url = get_author_posts_url($userdata->ID);
794
 
795
  // author name
796
+ $variables1_titles[] = $userdata->display_name;
797
+ $variables2_links[] = $author_url;
798
 
799
  } else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
800
 
801
  // If post is a custom post type
802
+ $post_type = get_post_type();
803
 
804
  // If it is a custom post type display name and link
805
+ if($post_type != 'post') {
806
+
807
+ $post_type_object = get_post_type_object($post_type);
808
+ $post_type_archive = get_post_type_archive_link($post_type);
809
+ $variables1_titles[] = $post_type_object->labels->name;
810
+ $variables2_links[] = $post_type_archive;
811
+
812
+ }
813
 
814
+ $custom_tax_name = get_queried_object()->name;
815
+ $variables1_titles[] = $custom_tax_name;
816
 
817
  } else if ( is_single() ) {
818
 
819
  // If post is a custom post type
820
+ $post_type = get_post_type();
821
 
822
  // If it is a custom post type display name and link
823
  if($post_type != 'post') {
824
 
825
+ $post_type_object = get_post_type_object($post_type);
826
+ $post_type_archive = get_post_type_archive_link($post_type);
827
+ $variables1_titles[]= $post_type_object->labels->name;
828
+ $variables2_links[] = $post_type_archive;
829
  }
830
 
831
  // Get post category info
832
  $category = get_the_category();
833
 
834
  if(!empty($category)) {
835
+
836
  $category_values = array_values( $category );
837
+
838
  foreach ($category_values as $category_value) {
839
+
840
+ $category_name = get_category($category_value);
841
+ $cat_name = $category_name->name;
842
+ $variables1_titles[] = $cat_name;
843
+ $variables2_links[] = get_category_link( $category_value );
844
 
845
  }
846
 
847
  // Get last category post is in
848
+ $last_category = end(($category));
849
+ $category_name = get_category($last_category);
850
  // Get parent any categories and create array
851
  $get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
852
+ $cat_parents = explode(',',$get_cat_parents);
853
 
854
  // Loop through parent categories and store in variable $cat_display
855
  $cat_display = '';
856
+
857
  foreach($cat_parents as $parents) {
858
+
859
  $cat_display .= '<li class="item-cat">'.esc_html__( $parents, 'schema-and-structured-data-for-wp' ).'</li>';
860
  $cat_display .= '<li class="separator"> ' . esc_html__( $separator, 'schema-and-structured-data-for-wp' ) . ' </li>';
861
+
862
  }
863
 
864
  }
865
 
866
  // If it's a custom post type within a custom taxonomy
867
  $taxonomy_exists = taxonomy_exists($custom_taxonomy);
868
+
869
  if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
870
 
871
  $taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
876
  }
877
 
878
  if(!empty($cat_id)) {
879
+
880
+ $variables1_titles[] = $cat_name;
881
+ $variables2_links[] = $cat_link;
882
+
883
  } else {
884
+
885
+ if($post_type == 'post') {
886
+
887
  $variables1_titles[]= get_the_title();
888
  $variables2_links[] = get_permalink();
889
+
890
  }
891
+
892
  }
893
 
894
  } else if ( is_category() ) {
895
+
896
  $category = get_the_category();
897
 
898
+ if(!empty($category)) {
899
+
900
+ $category_values = array_values( $category );
901
+
902
+ foreach ($category_values as $category_value) {
903
+
904
+ $category_name = get_category($category_value);
905
+ $cat_name = $category_name->name;
906
+ $variables1_titles[] = $cat_name;
907
+ $variables2_links[] = get_category_link( $category_value );
908
+
909
+ }
910
+ }
911
  } else if ( is_page() ) {
912
 
913
  // Standard page
921
 
922
  // Parent page loop
923
  if ( !isset( $parents ) ) $parents = null;
924
+
925
  foreach ( $anc as $ancestor ) {
926
+
927
  $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>';
928
  $parents .= '<li class="separator separator-' . esc_attr($ancestor) . '"> ' . esc_html__($separator, 'schema-and-structured-data-for-wp' ) . ' </li>';
929
+ $variables1_titles[] = get_the_title($ancestor);
930
+ $variables2_links[] = get_permalink($ancestor);
931
+
932
  }
933
 
934
+ $variables1_titles[] = get_the_title();
935
+ $variables2_links[] = get_permalink();
936
 
937
+ } else {
938
+
939
+ $variables1_titles[] = get_the_title();
940
+ $variables2_links[] = get_permalink();
941
  }
942
 
943
  } else if ( is_tag() ) {
954
  // Tag name and link
955
 
956
  $variables1_titles[] = $get_term_name;
957
+ $variables2_links[] = $term_link;
958
  }
959
 
960
+ $sd_data['titles'] = $variables1_titles;
961
+ $sd_data['links'] = $variables2_links;
962
 
963
  }
964
 
965
  }
966
 
 
967
  //Adding extra columns and displaying its data starts here
968
  function saswp_custom_column_set( $column, $post_id ) {
969
 
970
+ switch ( $column ) {
971
+
972
  case 'saswp_schema_type' :
973
 
974
  $schema_type = get_post_meta( $post_id, $key='schema_type', true);
976
 
977
  break;
978
  case 'saswp_target_location' :
979
+
980
  $enabled ='';
981
  $exclude ='';
982
  $data_group_array = get_post_meta( $post_id, $key='data_group_array', true);
983
+
984
+
985
  if($data_group_array){
986
+
987
  foreach ($data_group_array as $groups){
988
+
989
  foreach($groups['data_array'] as $group){
990
+
991
  if($group['key_2'] == 'equal'){
992
+
993
+ if($group['key_1'] == 'show_globally'){
994
+
995
+ $enabled .= 'Globally';
996
+
997
+ }else{
998
+
999
+ $enabled .= $group['key_3'].', ';
1000
+
1001
+ }
1002
+
1003
  }else{
1004
+
1005
  $exclude .= $group['key_3']. ', ';
1006
+
1007
  }
1008
+
1009
  }
1010
+
1011
  }
1012
  if($enabled){
1013
+
1014
+ echo '<div><strong>'.esc_html__( 'Enable on: ', 'schema-and-structured-data-for-wp' ).'</strong> '.esc_attr($enabled).'</div>';
1015
+
1016
  }
1017
  if($exclude){
1018
+
1019
+ echo '<div><strong>'.esc_html__( 'Exclude from: ', 'schema-and-structured-data-for-wp' ).'</strong>'.esc_attr($exclude).'</div>';
1020
+
1021
  }
1022
  }
1023
 
1035
  */
1036
 
1037
  function saswp_custom_columns($columns) {
1038
+
1039
  unset($columns['date']);
1040
+ $columns['saswp_schema_type'] = '<a>'.esc_html__( 'Type', 'schema-and-structured-data-for-wp' ).'<a>';
1041
+ $columns['saswp_target_location'] = '<a>'.esc_html__( 'Target Location', 'schema-and-structured-data-for-wp' ).'<a>';
1042
 
1043
  return $columns;
1044
  }
1058
  }
1059
  if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
1060
  return;
1061
+ }
1062
+
1063
+ $message = sanitize_textarea_field($_POST['message']);
1064
  $user = wp_get_current_user();
1065
  $user_data = $user->data;
1066
  $user_email = $user_data->user_email;
1070
  $headers = 'From: '. esc_attr($user_email) . "\r\n" .
1071
  'Reply-To: ' . esc_attr($user_email) . "\r\n";
1072
  // Load WP components, no themes.
1073
+ $sent = wp_mail($sendto, $subject, strip_tags($message), $headers);
1074
+
1075
  if($sent){
1076
+
1077
+ echo json_encode(array('status'=>'t'));
1078
+
1079
  }else{
1080
+
1081
+ echo json_encode(array('status'=>'f'));
1082
+
1083
  }
1084
  wp_die();
1085
  }
1101
  }
1102
  $plugin_name = sanitize_text_field($_GET['plugin_name']);
1103
  $result = '';
1104
+
1105
  switch ($plugin_name) {
1106
+
1107
  case 'schema':
1108
  if ( is_plugin_active('schema/schema.php')) {
1109
  $result = saswp_import_schema_plugin_data();
1129
  break;
1130
  }
1131
  if($result){
1132
+
1133
+ echo json_encode(array('status'=>'t', 'message'=>esc_html__('Data has been imported succeessfully','schema-and-structured-data-for-wp')));
1134
+
1135
  }else{
1136
+
1137
+ echo json_encode(array('status'=>'f', 'message'=>esc_html__('Plugin data is not available or it is not activated','schema-and-structured-data-for-wp')));
1138
+
1139
  }
1140
  wp_die();
1141
  }
1143
  add_action('wp_ajax_saswp_import_plugin_data', 'saswp_import_plugin_data');
1144
 
1145
 
1146
+ function saswp_feeback_no_thanks(){
1147
+
1148
+ $result = update_option( "saswp_activation_never", 'never');
1149
+
1150
  if($result){
1151
+
1152
+ echo json_encode(array('status'=>'t'));
1153
+
1154
  }else{
1155
+
1156
+ echo json_encode(array('status'=>'f'));
1157
+
1158
+ }
1159
+
1160
  wp_die();
1161
  }
1162
 
1163
  add_action('wp_ajax_saswp_feeback_no_thanks', 'saswp_feeback_no_thanks');
1164
 
1165
 
1166
+ function saswp_feeback_remindme(){
1167
+
1168
+ $result = update_option( "saswp_activation_date", date("Y-m-d"));
1169
+
1170
  if($result){
1171
+
1172
+ echo json_encode(array('status'=>'t'));
1173
+
1174
  }else{
1175
+
1176
+ echo json_encode(array('status'=>'f'));
1177
+
1178
  }
1179
  wp_die();
1180
  }
output/function.php CHANGED
@@ -9,30 +9,46 @@ function saswp_structured_data()
9
  remove_action( 'amp_post_template_head', 'amp_post_template_add_schemaorg_metadata',99,1);
10
  }
11
  add_action('wp_head', 'saswp_data_generator');
 
12
  function saswp_data_generator() {
 
13
  global $sd_data;
14
  global $post;
15
- $output ='';
 
 
16
  $contact_page_output = saswp_contact_page_output();
17
- $about_page_output = saswp_about_page_output();
 
18
  $author_output = saswp_author_output();
19
  $archive_output = saswp_archive_output();
20
- $kb_website_output = saswp_kb_website_output();
21
- $schema_breadcrumb_output = saswp_schema_breadcrumb_output($sd_data);
22
 
23
-
24
- $post_specific_enable = $option = get_option('modify_schema_post_enable_'.$post->ID);
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  if($post_specific_enable =='enable'){
27
- $schema_output = saswp_post_specific_schema_output();
 
 
28
  }else{
29
- $schema_output = saswp_schema_output();
 
 
30
  }
31
  if($schema_output || $schema_breadcrumb_output || $kb_website_output || $archive_output || $author_output || $about_page_output || $contact_page_output){
32
  add_filter( 'amp_post_template_metadata', 'saswp_remove_amp_default_structure_data');
33
- }
34
-
35
- $kb_schema_output = saswp_kb_schema_output();
36
 
37
  if( ( saswp_remove_warnings($sd_data, 'saswp-for-wordpress', 'saswp_string') ==''
38
  || 1 == saswp_remove_warnings($sd_data, 'saswp-for-wordpress', 'saswp_string') && saswp_non_amp() )
@@ -106,9 +122,13 @@ function saswp_data_generator() {
106
  }
107
 
108
  add_filter('the_content', 'saswp_paywall_data_for_login');
 
109
  function saswp_paywall_data_for_login($content){
 
110
  if( saswp_non_amp() ){
 
111
  return $content;
 
112
  }
113
  remove_filter('the_content', 'MeprAppCtrl::page_route', 60);
114
  $Conditionals = saswp_get_all_schema_posts();
@@ -118,30 +138,43 @@ function saswp_paywall_data_for_login($content){
118
  }else{
119
 
120
  $paywallenable ='';
121
- $className ='paywall';
122
  foreach($Conditionals as $schemaConditionals){
123
- $schema_options = $schemaConditionals['schema_options'];
 
124
 
125
  if(isset($schema_options['paywall_class_name'])){
126
- $className = $schema_options['paywall_class_name'];
 
 
127
  }
128
  if(isset($schema_options['notAccessibleForFree'])){
129
- $paywallenable = $schema_options['notAccessibleForFree'];
 
 
130
  break;
131
- }
 
 
132
  }
133
  if($paywallenable){
 
134
  if(strpos($content, '<!--more-->')!==false && !is_user_logged_in()){
 
135
  global $wp;
136
  $redirect = home_url( $wp->request );
137
  $breakedContent = explode("<!--more-->", $content);
138
  $content = $breakedContent[0].'<a href="'.wp_login_url( $redirect ) .'">'.esc_html__( 'Login', 'schema-and-structured-data-for-wp' ).'</a>';
 
139
  }elseif(strpos($content, '<!--more-->')!==false && is_user_logged_in()){
 
140
  global $wp;
141
  $redirect = home_url( $wp->request );
142
  $breakedContent = explode("<!--more-->", $content);
143
  $content = $breakedContent[0].'<div class="'.$className.'">'.$breakedContent[1].'</div>';
 
144
  }
 
145
  }
146
 
147
  }
@@ -151,7 +184,9 @@ function saswp_paywall_data_for_login($content){
151
  add_filter('memberpress_form_update', 'saswp_memberpress_form_update');
152
 
153
  function saswp_memberpress_form_update($form){
 
154
  if( !saswp_non_amp() ){
 
155
  add_action('amp_post_template_css',function(){
156
  echo '.amp-mem-login{background-color: #fef5c4;padding: 13px 30px 9px 30px;}';
157
  },11);
@@ -159,6 +194,7 @@ function saswp_memberpress_form_update($form){
159
  $redirect = home_url( $wp->request );
160
  $form = '<a class="amp-mem-login" href="'.wp_login_url( $redirect ) .'">'.esc_html__( 'Login', 'schema-and-structured-data-for-wp' ).'</a>';
161
  }
 
162
  return $form;
163
  }
164
 
9
  remove_action( 'amp_post_template_head', 'amp_post_template_add_schemaorg_metadata',99,1);
10
  }
11
  add_action('wp_head', 'saswp_data_generator');
12
+
13
  function saswp_data_generator() {
14
+
15
  global $sd_data;
16
  global $post;
17
+
18
+ $output = '';
19
+ $post_specific_enable = '';
20
  $contact_page_output = saswp_contact_page_output();
21
+ $about_page_output = saswp_about_page_output();
22
+
23
  $author_output = saswp_author_output();
24
  $archive_output = saswp_archive_output();
 
 
25
 
26
+ $schema_breadcrumb_output = saswp_schema_breadcrumb_output($sd_data);
27
+
28
+ if(saswp_remove_warnings($sd_data, 'saswp-yoast', 'saswp_string') != 1){
29
+
30
+ $kb_website_output = saswp_kb_website_output();
31
+ $kb_schema_output = saswp_kb_schema_output();
32
+ }
33
+
34
+ if(is_singular()){
35
+
36
+ $post_specific_enable = get_option('modify_schema_post_enable_'.$post->ID);
37
+
38
+ }
39
 
40
  if($post_specific_enable =='enable'){
41
+
42
+ $schema_output = saswp_post_specific_schema_output();
43
+
44
  }else{
45
+
46
+ $schema_output = saswp_schema_output();
47
+
48
  }
49
  if($schema_output || $schema_breadcrumb_output || $kb_website_output || $archive_output || $author_output || $about_page_output || $contact_page_output){
50
  add_filter( 'amp_post_template_metadata', 'saswp_remove_amp_default_structure_data');
51
+ }
 
 
52
 
53
  if( ( saswp_remove_warnings($sd_data, 'saswp-for-wordpress', 'saswp_string') ==''
54
  || 1 == saswp_remove_warnings($sd_data, 'saswp-for-wordpress', 'saswp_string') && saswp_non_amp() )
122
  }
123
 
124
  add_filter('the_content', 'saswp_paywall_data_for_login');
125
+
126
  function saswp_paywall_data_for_login($content){
127
+
128
  if( saswp_non_amp() ){
129
+
130
  return $content;
131
+
132
  }
133
  remove_filter('the_content', 'MeprAppCtrl::page_route', 60);
134
  $Conditionals = saswp_get_all_schema_posts();
138
  }else{
139
 
140
  $paywallenable ='';
141
+ $className ='paywall';
142
  foreach($Conditionals as $schemaConditionals){
143
+
144
+ $schema_options = $schemaConditionals['schema_options'];
145
 
146
  if(isset($schema_options['paywall_class_name'])){
147
+
148
+ $className = $schema_options['paywall_class_name'];
149
+
150
  }
151
  if(isset($schema_options['notAccessibleForFree'])){
152
+
153
+ $paywallenable = $schema_options['notAccessibleForFree'];
154
+
155
  break;
156
+
157
+ }
158
+
159
  }
160
  if($paywallenable){
161
+
162
  if(strpos($content, '<!--more-->')!==false && !is_user_logged_in()){
163
+
164
  global $wp;
165
  $redirect = home_url( $wp->request );
166
  $breakedContent = explode("<!--more-->", $content);
167
  $content = $breakedContent[0].'<a href="'.wp_login_url( $redirect ) .'">'.esc_html__( 'Login', 'schema-and-structured-data-for-wp' ).'</a>';
168
+
169
  }elseif(strpos($content, '<!--more-->')!==false && is_user_logged_in()){
170
+
171
  global $wp;
172
  $redirect = home_url( $wp->request );
173
  $breakedContent = explode("<!--more-->", $content);
174
  $content = $breakedContent[0].'<div class="'.$className.'">'.$breakedContent[1].'</div>';
175
+
176
  }
177
+
178
  }
179
 
180
  }
184
  add_filter('memberpress_form_update', 'saswp_memberpress_form_update');
185
 
186
  function saswp_memberpress_form_update($form){
187
+
188
  if( !saswp_non_amp() ){
189
+
190
  add_action('amp_post_template_css',function(){
191
  echo '.amp-mem-login{background-color: #fef5c4;padding: 13px 30px 9px 30px;}';
192
  },11);
194
  $redirect = home_url( $wp->request );
195
  $form = '<a class="amp-mem-login" href="'.wp_login_url( $redirect ) .'">'.esc_html__( 'Login', 'schema-and-structured-data-for-wp' ).'</a>';
196
  }
197
+
198
  return $form;
199
  }
200
 
output/output.php CHANGED
@@ -2,6 +2,7 @@
2
  if (! defined('ABSPATH') ) exit;
3
 
4
  function saswp_kb_schema_output() {
 
5
  global $sd_data;
6
  $input = array();
7
  // social profile
@@ -68,47 +69,39 @@ function saswp_kb_schema_output() {
68
 
69
 
70
  if ( saswp_remove_warnings($sd_data, 'saswp_kb_type', 'saswp_string') == 'Organization' ) {
71
- $logo ='';
72
- $height ='';
73
- $width ='';
74
- if(isset($sd_data['sd_logo'])){
75
- $logo = $sd_data['sd_logo']['url'];
76
- }
77
- $contact_1 = saswp_remove_warnings($sd_data, 'saswp_contact_type', 'saswp_string');
78
- $telephone_1 = saswp_remove_warnings($sd_data, 'saswp_kb_telephone', 'saswp_string');
79
 
80
- if(isset($sd_data['sd_logo'])){
81
- $height = $sd_data['sd_logo']['height'];
82
- $width = $sd_data['sd_logo']['width'];
83
- }
84
-
85
- if( '' == $logo && empty($logo) && isset($sd_data['sd_default_image'])){
86
- $logo = $sd_data['sd_default_image']['url'];
87
- }
88
-
89
- if( '' == $height && empty($height) && isset($sd_data['sd_default_image_height'])){
90
- $height = $sd_data['sd_default_image_height'];
91
- }
92
-
93
- if( '' == $width && empty($width) && isset($sd_data['sd_default_image_width'])){
94
- $width = $sd_data['sd_default_image_width'];
95
- }
96
-
97
  if( '' == $contact_1 && empty($contact_1) && isset($sd_data['saswp_contact_type'])){
98
  $contact_1 = $sd_data['saswp_contact_type'];
99
  }
100
 
101
  if( '' == $telephone_1 && empty($telephone_1) && isset($sd_data['saswp_kb_telephone'])){
102
  $telephone_1 = $sd_data['saswp_kb_telephone'];
103
- }
104
-
105
- // Contact Information
106
- $contact_info = array();
107
  $contact_info = array(
108
  'contactPoint' => array(
109
- '@type' => 'ContactPoint',
110
- 'contactType' => $contact_1,
111
- 'telephone' => $telephone_1,
112
  )
113
  );
114
 
@@ -117,25 +110,31 @@ function saswp_kb_schema_output() {
117
  '@type' => $sd_data['saswp_kb_type'],
118
  'name' => saswp_remove_warnings($sd_data, 'sd_name', 'saswp_string'),
119
  'url' => saswp_remove_warnings($sd_data, 'sd_url', 'saswp_string'),
120
- 'sameAs' => $platform,
121
- 'logo' => array(
122
- '@type' => 'ImageObject',
123
- 'url' => $logo,
124
- 'width' => $width,
125
- 'height' => $height,
126
- ),
127
  );
 
 
 
 
 
 
 
 
 
128
 
129
  if ( isset($sd_data['saswp_kb_contact_1'] ) && $sd_data['saswp_kb_contact_1'] ) {
 
130
  $input = array_merge($input, $contact_info);
 
131
  }
132
  }
133
  // Person
134
 
135
  if ( saswp_remove_warnings($sd_data, 'saswp_kb_type', 'saswp_string') == 'Person' ) {
136
- $image ='';
137
- $height ='';
138
- $width ='';
 
139
 
140
  if(isset($sd_data['sd-person-image'])){
141
  $image = $sd_data['sd-person-image']['url'];
@@ -169,6 +168,8 @@ function saswp_kb_schema_output() {
169
  'telephone' => $sd_data['sd-person-phone-number'],
170
  );
171
  }
 
 
172
  return json_encode($input);
173
  }
174
 
@@ -176,55 +177,48 @@ function sd_is_blog() {
176
  return ( is_author() || is_category() || is_tag() || is_date() || is_home() || is_single() ) && 'post' == get_post_type();
177
  }
178
 
179
- function saswp_schema_output() {
 
180
  global $sd_data;
181
 
182
- $Conditionals = saswp_get_all_schema_posts();
183
 
184
  if(!$Conditionals){
185
  return ;
186
- }
 
187
  $all_schema_output = array();
188
- foreach($Conditionals as $schemaConditionals){
189
 
190
- $logo ='';
191
- $height ='';
192
- $width ='';
193
- $site_name ='';
194
  $schema_options = saswp_remove_warnings($schemaConditionals, 'schema_options', 'saswp_string');
195
  $schema_type = saswp_remove_warnings($schemaConditionals, 'schema_type', 'saswp_string');
196
  $schema_post_id = saswp_remove_warnings($schemaConditionals, 'post_id', 'saswp_string');
 
 
 
 
 
 
 
 
197
 
198
- if(isset($sd_data['sd_logo'])){
199
- $logo = $sd_data['sd_logo']['url'];
 
 
 
 
200
  }
201
-
202
 
203
  if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
204
  $site_name = $sd_data['sd_name'];
205
  }else{
206
  $site_name = get_bloginfo();
207
- }
208
-
209
- if('' != $logo && !empty($logo)){
210
- $height = $sd_data['sd_logo']['height'];
211
- $width = $sd_data['sd_logo']['width'];
212
- }else{
213
- $sizes = array(
214
- 'width' => 600,
215
- 'height' => 60,
216
- 'crop' => false,
217
- );
218
- $custom_logo_id = get_theme_mod( 'custom_logo' );
219
- $custom_logo = wp_get_attachment_image_src( $custom_logo_id, $sizes);
220
- $logo = $custom_logo[0];
221
- $height =$custom_logo[1];
222
- $width =$custom_logo[2];
223
- }
224
-
225
- if(is_singular()){
226
  // Generate author id
227
- $author_id = get_the_author_meta('ID');
228
 
229
  // Blogposting Schema
230
  $image_id = get_post_thumbnail_id();
@@ -234,39 +228,53 @@ function saswp_schema_output() {
234
  $modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
235
  $aurthor_name = get_the_author();
236
 
237
- $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
238
- $aggregateRating = array();
 
239
  $kkstar_aggregateRating = array();
240
- $saswp_over_all_rating ='';
 
241
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
242
- $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
243
- }
 
 
 
244
  $saswp_review_item_enable = 0;
 
245
  if(isset($saswp_review_details['saswp-review-item-enable'])){
246
- $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
 
 
247
  }
 
248
  $saswp_review_count = "1";
249
 
250
 
251
  if($saswp_over_all_rating && $saswp_review_count && $saswp_review_item_enable ==1){
 
252
  $aggregateRating = array(
253
- "@type"=> "AggregateRating",
254
  "ratingValue" => $saswp_over_all_rating,
255
  "reviewCount" => $saswp_review_count
256
  );
 
257
  }
258
 
259
- $kkstar_rating_data = saswp_extract_kk_star_ratings(get_the_ID());
 
260
  if(!empty($kkstar_rating_data)){
 
261
  $kkstar_aggregateRating = array(
262
- "@type"=> "AggregateRating",
263
  "bestRating" => saswp_remove_warnings($kkstar_rating_data, 'best', 'saswp_string'),
264
  "ratingCount" => saswp_remove_warnings($kkstar_rating_data, 'votes', 'saswp_string'),
265
  "ratingValue" => saswp_remove_warnings($kkstar_rating_data, 'avg', 'saswp_string')
266
- );
 
267
  }
268
  $extra_theme_review = array();
269
- $service_object = new saswp_output_service();
270
  $extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
271
 
272
  if( 'Blogposting' === $schema_type){
@@ -277,7 +285,7 @@ function saswp_schema_output() {
277
 
278
  'mainEntityOfPage' => get_permalink(),
279
  'headline' => get_the_title(),
280
- 'description' => get_the_excerpt(),
281
  'name' => get_the_title(),
282
  'url' => get_permalink(),
283
  'datePublished' => $date,
@@ -362,44 +370,11 @@ function saswp_schema_output() {
362
  }
363
  }
364
 
365
- if( 'WebPage' === $schema_type){
366
-
367
- if(empty($image_details[0]) || $image_details[0] === NULL ){
368
- $image_details[0] = $logo;
369
- }
370
-
371
- $input1 = array(
372
- '@context' => 'http://schema.org',
373
- '@type' => $schema_type ,
374
- 'name' => get_the_title(),
375
- 'url' => get_permalink(),
376
- 'description' => get_the_excerpt(),
377
- 'mainEntity' => array(
378
- '@type' => 'Article',
379
- 'mainEntityOfPage' => get_permalink(),
380
- 'image' => $image_details[0],
381
- 'headline' => get_the_title(),
382
- 'description' => get_the_excerpt(),
383
- 'datePublished' => $date,
384
- 'dateModified' => $modified_date,
385
- 'author' => array(
386
- '@type' => 'Person',
387
- 'name' => $aurthor_name, ),
388
- 'Publisher' => array(
389
- '@type' => 'Organization',
390
- 'logo' => array(
391
- '@type' => 'ImageObject',
392
- 'url' => $logo,
393
- 'width' => $width,
394
- 'height' => $height,
395
- ),
396
- 'name' => $site_name,
397
- ),
398
-
399
- ),
400
-
401
 
402
- );
403
  if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
404
  $service = new saswp_output_service();
405
  $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
@@ -420,31 +395,9 @@ function saswp_schema_output() {
420
 
421
  if( 'Article' === $schema_type ){
422
 
423
- $input1 = array(
424
- '@context' => 'http://schema.org',
425
- '@type' => 'Article',
426
- 'mainEntityOfPage' => get_permalink(),
427
- 'image' => $image_details[0],
428
- 'headline' => get_the_title(),
429
- 'description' => get_the_excerpt(),
430
- 'datePublished' => $date,
431
- 'dateModified' => $modified_date,
432
- 'author' => array(
433
- '@type' => 'Person',
434
- 'name' => $aurthor_name
435
- ),
436
- 'Publisher' => array(
437
- '@type' => 'Organization',
438
- 'logo' => array(
439
- '@type' => 'ImageObject',
440
- 'url' => $logo,
441
- 'width' => $width,
442
- 'height' => $height,
443
- ),
444
- 'name' => $site_name,
445
- ),
446
-
447
- );
448
  if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
449
  $service = new saswp_output_service();
450
  $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
@@ -462,6 +415,7 @@ function saswp_schema_output() {
462
  if(empty($image_details[0]) || $image_details[0] === NULL ){
463
  $image_details[0] = $sd_data['sd_logo']['url'];
464
  }
 
465
  $input1 = array(
466
  '@context' => 'http://schema.org',
467
  '@type' => $schema_type ,
@@ -469,7 +423,7 @@ function saswp_schema_output() {
469
  'name' => get_the_title(),
470
  'datePublished' => $date,
471
  'dateModified' => $modified_date,
472
- 'description' => get_the_excerpt(),
473
  'mainEntity' => array(
474
  '@type' => 'WebPage',
475
  '@id' => get_permalink(),
@@ -599,7 +553,7 @@ function saswp_schema_output() {
599
  'name' => saswp_remove_warnings($schema_data, 'saswp_product_schema_name', 'saswp_string'),
600
  'sku' => saswp_remove_warnings($schema_data, 'saswp_product_schema_sku', 'saswp_string'),
601
  'description' => saswp_remove_warnings($schema_data, 'saswp_product_schema_description', 'saswp_string'),
602
- 'image' =>array(
603
  '@type' =>'ImageObject',
604
  'url' => isset($schema_data['saswp_product_schema_image']) ? $schema_data['saswp_product_schema_image']['url']:'' ,
605
  'width' => isset($schema_data['saswp_product_schema_image']) ? $schema_data['saswp_product_schema_image']['width']:'' ,
@@ -659,12 +613,16 @@ function saswp_schema_output() {
659
  }
660
 
661
  if( 'NewsArticle' === $schema_type ){
662
- $category_detail=get_the_category(get_the_ID());//$post->ID
 
663
  $article_section = '';
 
664
  foreach($category_detail as $cd){
665
- $article_section = $cd->cat_name;
 
 
666
  }
667
- $word_count = saswp_reading_time_and_word_count();
668
  $input1 = array(
669
  '@context' => 'http://schema.org',
670
  '@type' => $schema_type ,
@@ -673,9 +631,9 @@ function saswp_schema_output() {
673
  'mainEntityOfPage' => get_the_permalink(),
674
  'datePublished' => $date,
675
  'dateModified' => $modified_date,
676
- 'description' => get_the_excerpt(),
677
  'articleSection' => $article_section,
678
- 'articleBody' => get_the_excerpt(),
679
  'name' => get_the_title(),
680
  'thumbnailUrl' => saswp_remove_warnings($image_details, 0, 'saswp_string'),
681
  'wordCount' => saswp_remove_warnings($word_count, 'word_count', 'saswp_string'),
@@ -726,10 +684,10 @@ function saswp_schema_output() {
726
 
727
  if( 'Service' === $schema_type ){
728
 
729
- $schema_data = saswp_get_schema_data($schema_post_id, 'saswp_service_schema_details');
730
 
731
- $area_served_str = saswp_remove_warnings($schema_data, 'saswp_service_schema_area_served', 'saswp_string');
732
- $area_served_arr = explode(',', $area_served_str);
733
 
734
  $service_offer_str = saswp_remove_warnings($schema_data, 'saswp_service_schema_service_offer', 'saswp_string');
735
  $service_offer_arr = explode(',', $service_offer_str);
@@ -760,23 +718,31 @@ function saswp_schema_output() {
760
  'description' => saswp_remove_warnings($schema_data, 'saswp_service_schema_description', 'saswp_string'),
761
  );
762
  $areaServed = array();
 
763
  foreach($area_served_arr as $area){
 
764
  $areaServed[] = array(
765
  '@type' => 'City',
766
  'name' => $area
767
  );
 
768
  }
769
  $serviceOffer = array();
 
770
  foreach($service_offer_arr as $offer){
 
771
  $serviceOffer[] = array(
772
  '@type' => 'Offer',
773
  'name' => $offer
774
  );
 
775
  }
 
776
  $input1['areaServed'] = $areaServed;
 
777
  $input1['hasOfferCatalog'] = array(
778
- '@type' => 'OfferCatalog',
779
- 'name' => $schema_data['saswp_service_schema_name'],
780
  'itemListElement' => $serviceOffer
781
  );
782
 
@@ -788,7 +754,7 @@ function saswp_schema_output() {
788
  if(isset($schema_data['saswp_service_schema_enable_rating'])){
789
 
790
  $input1['aggregateRating'] = array(
791
- "@type"=> "AggregateRating",
792
  "ratingValue" => saswp_remove_warnings($schema_data, 'saswp_service_schema_rating', 'saswp_string'),
793
  "reviewCount" => saswp_remove_warnings($schema_data, 'saswp_service_schema_review_count', 'saswp_string')
794
  );
@@ -807,79 +773,227 @@ function saswp_schema_output() {
807
 
808
  if( 'Review' === $schema_type ){
809
 
810
- $schema_data = saswp_get_schema_data($schema_post_id, 'saswp_review_schema_details');
 
 
 
 
811
  $review_author = get_the_author();
 
812
  if(isset($schema_data['saswp_review_schema_author'])){
 
813
  $review_author = $schema_data['saswp_review_schema_author'];
 
814
  }
 
 
 
 
 
 
815
 
816
- $input1 = array(
817
- '@context' => 'http://schema.org',
818
- '@type' => $schema_type ,
819
- 'url' => get_permalink(),
820
- 'description' => get_the_excerpt(),
821
- 'reviewBody' => saswp_remove_warnings($schema_data, 'saswp_review_schema_description', 'saswp_string'),
822
- 'itemReviewed' => array(
823
- '@type' => saswp_remove_warnings($schema_data, 'saswp_review_schema_item_type', 'saswp_string'),
824
- 'name' => saswp_remove_warnings($schema_data, 'saswp_review_schema_name', 'saswp_string'),
825
- 'image' => array(
826
- '@type' =>'ImageObject',
827
- 'url' => isset($schema_data['saswp_review_schema_image']) ? $schema_data['saswp_review_schema_image']['url']:'' ,
828
- 'width' => isset($schema_data['saswp_review_schema_image']) ? $schema_data['saswp_review_schema_image']['width']:'' ,
829
- 'height' => isset($schema_data['saswp_review_schema_image']) ? $schema_data['saswp_review_schema_image']['height']:'' ,
830
- ),
831
- 'priceRange' => saswp_remove_warnings($schema_data, 'saswp_review_schema_price_range', 'saswp_string'),
832
- 'address' => array(
833
- '@type' => 'PostalAddress',
834
- 'streetAddress' => saswp_remove_warnings($schema_data, 'saswp_review_schema_street_address', 'saswp_string'),
835
- 'addressLocality' => saswp_remove_warnings($schema_data, 'saswp_review_schema_locality', 'saswp_string'),
836
- 'addressRegion' => saswp_remove_warnings($schema_data, 'saswp_review_schema_region', 'saswp_string'),
837
- 'postalCode' => saswp_remove_warnings($schema_data, 'saswp_review_schema_postal_code', 'saswp_string'),
838
- 'addressCountry' => saswp_remove_warnings($schema_data, 'saswp_review_schema_country', 'saswp_string'),
839
- ),
840
- 'telephone' => saswp_remove_warnings($schema_data, 'saswp_review_schema_telephone', 'saswp_string'),
841
- ),
842
- 'datePublished' => $date,
843
- 'dateModified' => $modified_date,
844
- 'author' => array(
845
- '@type' => 'Person',
846
- 'name' => $review_author,
847
- // 'Image' => array(
848
- // '@type' => 'ImageObject',
849
- // 'url' => $author_details['url'],
850
- // 'height' => $author_details['height'],
851
- // 'width' => $author_details['width']
852
- // ),
853
- ),
854
- 'Publisher' => array(
855
- '@type' => 'Organization',
856
- 'logo' => array(
857
- '@type' => 'ImageObject',
858
- 'url' => $logo,
859
- 'width' => $width,
860
- 'height' => $height,
861
- ),
862
- 'name' => $site_name,
863
- ),
864
-
865
-
866
- );
867
-
868
- if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
869
- $service = new saswp_output_service();
870
- $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
871
  }
872
 
873
- if(isset($schema_data['saswp_review_schema_enable_rating'])){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
 
875
  $input1['reviewRating'] = array(
876
  "@type"=> "Rating",
877
  "ratingValue" => saswp_remove_warnings($schema_data, 'saswp_review_schema_rating', 'saswp_string'),
878
- "bestRating" => saswp_remove_warnings($schema_data, 'saswp_review_schema_review_count', 'saswp_string')
879
  );
880
  }
 
 
 
 
 
 
 
 
 
881
 
882
- }
883
 
884
  if( 'VideoObject' === $schema_type){
885
 
@@ -894,7 +1008,7 @@ function saswp_schema_output() {
894
  'headline' => get_the_title(),
895
  'datePublished' => $date,
896
  'dateModified' => $modified_date,
897
- 'description' => get_the_excerpt(),
898
  'name' => get_the_title(),
899
  'uploadDate' => $date,
900
  'thumbnailUrl' => $image_details[0],
@@ -948,28 +1062,36 @@ function saswp_schema_output() {
948
  $business_type = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_type', true) );
949
  $business_name = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_name', true) );
950
  $business_details = esc_sql ( get_post_meta($schema_post_id, 'saswp_local_business_details', true) );
951
- $dayoftheweek = get_post_meta($schema_post_id, 'saswp_dayofweek', true);
952
- $dayoftheweek = explode( "\r\n", $dayoftheweek);
 
953
  if(empty($image_details[0]) || $image_details[0] === NULL ){
954
  $image_details[0] = $logo;
955
  }
956
  if(isset($business_details['local_business_logo'])){
 
957
  unset($image_details);
958
  $image_details[0] = isset($business_details['local_business_logo']) ? $business_details['local_business_logo']['url']:'';
959
  $image_details[1] = isset($business_details['local_business_logo']) ? $business_details['local_business_logo']['width']:'';
960
  $image_details[2] = isset($business_details['local_business_logo']) ? $business_details['local_business_logo']['height']:'';
 
961
  }
962
  if($business_name){
 
963
  $local_business = $business_name;
 
964
  }else{
 
965
  $local_business = $business_type;
966
- }
 
 
967
  $input1 = array(
968
  '@context' => 'http://schema.org',
969
  '@type' => $local_business ,
970
  'name' => saswp_remove_warnings($business_details, 'local_business_name', 'saswp_string'),
971
  'url' => get_permalink(),
972
- 'description' => get_the_excerpt(),
973
  'address' => array(
974
  "@type" => "PostalAddress",
975
  "streetAddress" => saswp_remove_warnings($business_details, 'local_street_address', 'saswp_string'),
@@ -990,7 +1112,7 @@ function saswp_schema_output() {
990
  if(isset($business_details['local_enable_rating'])){
991
 
992
  $input1['aggregateRating'] = array(
993
- "@type"=> "AggregateRating",
994
  "ratingValue" => saswp_remove_warnings($business_details, 'local_rating', 'saswp_string'),
995
  "reviewCount" => saswp_remove_warnings($business_details, 'local_review_count', 'saswp_string')
996
  );
@@ -1026,161 +1148,182 @@ function saswp_schema_output() {
1026
  //Check for Featured Image
1027
 
1028
  if( !empty($input1) && !isset($input1['image'])){
1029
-
1030
- if( is_array($image_details) ){
1031
- if(isset($image_details[1]) ){
1032
- $width = $image_details[1];
1033
- }
1034
- if(isset($image_details[2])){
1035
- $height = $image_details[2];
1036
- }
1037
- $input2 = array(
1038
- 'image' =>array(
1039
- '@type' =>'ImageObject',
1040
- 'url' =>$image_details[0],
1041
- 'width' =>$width,
1042
- 'height' =>$height,
1043
- ),
1044
- );
1045
- $input1 = array_merge($input1,$input2);
1046
- }
1047
- else{
1048
- $input2 = array(
1049
- 'image' =>array(
1050
- '@type' =>'ImageObject',
1051
- 'url' => $logo,
1052
- 'width' => $width,
1053
- 'height' => $height,
1054
- ),
1055
- );
1056
- $input1 = array_merge($input1,$input2);
1057
- }
1058
-
1059
  }
1060
 
1061
  if(isset($schema_options['notAccessibleForFree'])==1){
1062
 
1063
  add_filter( 'amp_post_template_data', 'saswp_structure_data_access_scripts');
1064
- $paywall_class_name = $schema_options['paywall_class_name'];
 
1065
  $isAccessibleForFree = isset($schema_options['isAccessibleForFree'])? $schema_options['isAccessibleForFree']: False;
1066
 
1067
- if($paywall_class_name!=""){
1068
- if(strpos($paywall_class_name, ".")==-1){
 
 
1069
  $paywall_class_name = ".".$paywall_class_name;
 
1070
  }
1071
  $paywallData = array("isAccessibleForFree"=> $isAccessibleForFree,
1072
- "hasPart"=>array(
1073
- "@type"=> "WebPageElement",
1074
- "isAccessibleForFree"=> $isAccessibleForFree,
1075
- "cssSelector" => $paywall_class_name
1076
- )
1077
- );
 
1078
  $input1 = array_merge($input1,$paywallData);
1079
  }
1080
  }
1081
 
1082
  if(!empty($input1)){
1083
- $all_schema_output[] = $input1;
1084
  }
1085
- }
1086
  }
1087
  return $all_schema_output;
1088
  }
1089
 
1090
  function saswp_post_specific_schema_output() {
 
1091
  global $post;
1092
  global $sd_data;
1093
- $all_schemas = get_posts(
1094
- array(
1095
- 'post_type' => 'saswp',
1096
- 'posts_per_page' => -1,
1097
- 'post_status' => 'publish',
1098
- )
1099
- );
1100
- $all_schema_output = array();
1101
 
1102
- $schema_enable = get_post_meta($post->ID, 'saswp_enable_disable_schema', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1103
 
1104
  foreach($all_schemas as $schema){
1105
- $schema_id = $schema->ID;
1106
- $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
 
1107
  $schema_post_id = $post->ID;
1108
- $all_post_meta = esc_sql ( get_post_meta($schema_post_id, $key='', true) );
1109
 
1110
  if(is_singular() && isset($schema_enable[$schema_id]) && $schema_enable[$schema_id] == 1 ){
1111
 
1112
  $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
1113
- $aggregateRating = array();
 
1114
  $saswp_over_all_rating ='';
 
1115
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
 
1116
  $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
 
1117
  }
1118
  $saswp_review_item_enable = 0;
 
1119
  if(isset($saswp_review_details['saswp-review-item-enable'])){
 
1120
  $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
 
1121
  }
1122
  $saswp_review_count = "1";
1123
 
1124
  if($saswp_over_all_rating && $saswp_review_count && $saswp_review_item_enable ==1){
 
1125
  $aggregateRating = array(
1126
  "@type"=> "AggregateRating",
1127
  "ratingValue" => $saswp_over_all_rating,
1128
  "reviewCount" => $saswp_review_count
1129
  );
 
1130
  }
1131
- $kkstar_rating_data = saswp_extract_kk_star_ratings(get_the_ID());
 
 
1132
  if(!empty($kkstar_rating_data)){
 
1133
  $kkstar_aggregateRating = array(
1134
  "@type"=> "AggregateRating",
1135
  "bestRating" => saswp_remove_warnings($kkstar_rating_data, 'best', 'saswp_string'),
1136
  "ratingCount" => saswp_remove_warnings($kkstar_rating_data, 'votes', 'saswp_string'),
1137
  "ratingValue" => saswp_remove_warnings($kkstar_rating_data, 'avg', 'saswp_string')
1138
- );
 
1139
  }
1140
  $extra_theme_review = array();
1141
- $service_object = new saswp_output_service();
1142
  $extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
1143
 
1144
 
1145
 
1146
- if( 'qanda' === $schema_type){
 
1147
  if(trim(saswp_remove_warnings($all_post_meta, 'saswp_qa_question_title_'.$schema_id, 'saswp_array')) ==''){
 
1148
  $service_object = new saswp_output_service();
1149
- $input1 = $service_object->saswp_dw_question_answers_details(get_the_ID());
 
1150
  }else{
 
1151
  $input1 = array(
1152
  '@context' => 'http://schema.org',
1153
  '@type' => 'QAPage' ,
1154
- 'mainEntity' => array(
1155
  '@type' => 'Question' ,
1156
  'name' => saswp_remove_warnings($all_post_meta, 'saswp_qa_question_title_'.$schema_id, 'saswp_array'),
1157
  'text' => saswp_remove_warnings($all_post_meta, 'saswp_qa_question_description_'.$schema_id, 'saswp_array'),
1158
  'upvoteCount' => saswp_remove_warnings($all_post_meta, 'saswp_qa_upvote_count_'.$schema_id, 'saswp_array'),
1159
  'dateCreated' => saswp_remove_warnings($all_post_meta, 'saswp_qa_date_created_'.$schema_id, 'saswp_array'),
1160
- 'author' => array('@type' => 'Person','name' =>saswp_remove_warnings($all_post_meta, 'saswp_qa_question_author_name_'.$schema_id, 'saswp_array')) ,
1161
  'answerCount' => 2 ,
1162
  'acceptedAnswer' => array(
1163
- '@type' => 'Answer',
1164
- 'upvoteCount' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_upvote_count_'.$schema_id, 'saswp_array'),
1165
- 'url' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_url_'.$schema_id, 'saswp_array'),
1166
- 'text' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_text_'.$schema_id, 'saswp_array'),
1167
- 'dateCreated' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_date_created_'.$schema_id, 'saswp_array'),
1168
- 'author' => array('@type' => 'Person', 'name' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_author_name_'.$schema_id, 'saswp_array')),
1169
  ) ,
1170
  'suggestedAnswer' => array(
1171
- '@type' => 'Answer',
1172
- 'upvoteCount' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_upvote_count_'.$schema_id, 'saswp_array'),
1173
- 'url' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_url_'.$schema_id, 'saswp_array'),
1174
- 'text' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_text_'.$schema_id, 'saswp_array'),
1175
- 'dateCreated' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_date_created_'.$schema_id, 'saswp_array'),
1176
- 'author' => array('@type' => 'Person', 'name' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_author_name_'.$schema_id, 'saswp_array')),
1177
  ) ,
1178
  )
1179
  );
1180
  }
1181
  }
1182
 
1183
- if( 'Blogposting' === $schema_type){
1184
 
1185
  $logo = get_post_meta( get_the_ID(), 'saswp_blogposting_organization_logo_'.$schema_id.'_detail',true);
1186
  $input1 = array(
@@ -1220,7 +1363,7 @@ function saswp_post_specific_schema_output() {
1220
  }
1221
  }
1222
 
1223
- if( 'AudioObject' === $schema_type){
1224
 
1225
  $input1 = array(
1226
  '@context' => 'http://schema.org',
@@ -1250,6 +1393,7 @@ function saswp_post_specific_schema_output() {
1250
  }
1251
 
1252
  if( 'WebPage' === $schema_type){
 
1253
  $logo = get_post_meta( get_the_ID(), 'saswp_webpage_organization_logo_'.$schema_id.'_detail',true);
1254
  $input1 = array(
1255
  '@context' => 'http://schema.org',
@@ -1283,19 +1427,26 @@ function saswp_post_specific_schema_output() {
1283
 
1284
  );
1285
  if(!empty($aggregateRating)){
 
1286
  $input1['mainEntity']['aggregateRating'] = $aggregateRating;
 
1287
  }
1288
  if(!empty($kkstar_aggregateRating)){
 
1289
  $input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
 
1290
  }
1291
  if(!empty($extra_theme_review)){
 
1292
  $input1 = array_merge($input1, $extra_theme_review);
 
1293
  }
1294
  }
1295
 
1296
  if( 'Article' === $schema_type ){
1297
 
1298
  $logo = get_post_meta( get_the_ID(), 'saswp_article_organization_logo_'.$schema_id.'_detail',true);
 
1299
  $input1 = array(
1300
  '@context' => 'http://schema.org',
1301
  '@type' => 'Article',
@@ -1322,34 +1473,47 @@ function saswp_post_specific_schema_output() {
1322
 
1323
  );
1324
  if(!empty($kkstar_aggregateRating)){
1325
- $input1['aggregateRating'] = $kkstar_aggregateRating;
 
 
1326
  }
1327
  if(!empty($extra_theme_review)){
 
1328
  $input1 = array_merge($input1, $extra_theme_review);
 
1329
  }
1330
  }
1331
 
1332
  if( 'Recipe' === $schema_type){
1333
- $recipe_logo = get_post_meta( get_the_ID(), 'saswp_article_organization_logo_'.$schema_id.'_detail',true);
1334
- $recipe_image = get_post_meta( get_the_ID(), 'saswp_recipe_author_image_'.$schema_id.'_detail',true);
1335
- $ingredient = array();
1336
- $instruction = array();
 
 
1337
 
1338
  if(isset($all_post_meta['saswp_recipe_ingredient_'.$schema_id])){
 
1339
  $explod = explode(';', $all_post_meta['saswp_recipe_ingredient_'.$schema_id][0]);
1340
  foreach ($explod as $val){
1341
  $ingredient[] = $val;
1342
- }
 
1343
  }
1344
 
1345
  if(isset($all_post_meta['saswp_recipe_instructions_'.$schema_id])){
1346
- $explod = explode(';', $all_post_meta['saswp_recipe_instructions_'.$schema_id][0]);
 
 
1347
  foreach ($explod as $val){
 
1348
  $instruction[] = array(
1349
  '@type' => "HowToStep",
1350
- 'text' => $val,
1351
  );
1352
- }
 
 
1353
  }
1354
 
1355
  $input1 = array(
@@ -1377,8 +1541,8 @@ function saswp_post_specific_schema_output() {
1377
  'recipeCategory' => saswp_remove_warnings($all_post_meta, 'saswp_recipe_category_'.$schema_id, 'saswp_array'),
1378
  'recipeCuisine' => saswp_remove_warnings($all_post_meta, 'saswp_recipe_cuisine_'.$schema_id, 'saswp_array'),
1379
  'nutrition' => array(
1380
- '@type' => "NutritionInformation",
1381
- 'calories' => saswp_remove_warnings($all_post_meta, 'saswp_recipe_nutrition_'.$schema_id, 'saswp_array'),
1382
  ),
1383
  'recipeIngredient' => $ingredient,
1384
  'recipeInstructions' => $instruction,
@@ -1425,7 +1589,7 @@ function saswp_post_specific_schema_output() {
1425
 
1426
  if( 'Product' === $schema_type){
1427
 
1428
- $product_image = get_post_meta( get_the_ID(), 'saswp_product_schema_image_'.$schema_id.'_detail',true);
1429
  $input1 = array(
1430
  '@context' => 'http://schema.org',
1431
  '@type' => 'Product',
@@ -1655,55 +1819,213 @@ function saswp_post_specific_schema_output() {
1655
  }
1656
  }
1657
 
1658
- if( 'Review' === $schema_type ){
 
 
 
1659
  $review_author = get_the_author();
1660
 
1661
  if(isset($all_post_meta['saswp_review_schema_author_'.$schema_id])){
1662
  $review_author = $all_post_meta['saswp_review_schema_author_'.$schema_id][0];
1663
  }
1664
-
1665
- $input1 = array(
1666
- '@context' => 'http://schema.org',
1667
- '@type' => 'Review' ,
1668
- 'url' => get_permalink(),
1669
- 'description' => get_the_excerpt(),
1670
- 'reviewBody' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_description_'.$schema_id, 'saswp_array'),
1671
- 'itemReviewed' => array(
1672
- '@type' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_item_type_'.$schema_id, 'saswp_array'),
1673
- 'name' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_name_'.$schema_id, 'saswp_array'),
1674
- 'image' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_image_'.$schema_id, 'saswp_array'),
1675
- 'priceRange' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_price_range_'.$schema_id, 'saswp_array'),
1676
- 'address' => array(
1677
- '@type' => 'PostalAddress',
1678
- 'streetAddress' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_street_address_'.$schema_id, 'saswp_array'),
1679
- 'addressLocality' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_locality_'.$schema_id, 'saswp_array'),
1680
- 'addressRegion' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_region_'.$schema_id, 'saswp_array'),
1681
- 'postalCode' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_postal_code_'.$schema_id, 'saswp_array'),
1682
- 'addressCountry' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_country_'.$schema_id, 'saswp_array'),
1683
- ),
1684
- 'telephone' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_telephone_'.$schema_id, 'saswp_array'),
1685
- ),
1686
-
1687
- 'datePublished' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_date_published_'.$schema_id, 'saswp_array'),
1688
- 'dateModified' => saswp_remove_warnings($all_post_meta, 'saswp_review_schema_date_modified_'.$schema_id, 'saswp_array'),
1689
- 'author' => array(
1690
- '@type' => 'Person',
1691
- 'name' => $review_author,
1692
- ),
1693
- 'Publisher' => array(
1694
- '@type' => 'Organization',
1695
- 'logo' => array(
1696
- '@type' => 'ImageObject',
1697
- 'url' => isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['url']:'',
1698
- 'width' => isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['width']:'',
1699
- 'height' => isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['height']:'',
1700
- ),
1701
- 'name' => saswp_remove_warnings($sd_data, 'sd_name', 'saswp_string'),
1702
- ),
1703
-
1704
-
1705
- );
1706
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1707
  if(saswp_remove_warnings($all_post_meta, 'saswp_review_schema_enable_rating_'.$schema_id, 'saswp_array') == 1){
1708
 
1709
  $input1['reviewRating'] = array(
@@ -1782,42 +2104,19 @@ function saswp_post_specific_schema_output() {
1782
  $input1['menu'] = $all_post_meta['local_menu_'.$schema_id][0];
1783
  }
1784
  }
1785
-
1786
- $image_id = get_post_thumbnail_id();
1787
- $image_details = wp_get_attachment_image_src($image_id, 'full');
1788
- global $sd_data;
1789
-
1790
- if(!empty($input1) && !isset($input1['image'])){
1791
-
1792
- if( is_array($image_details) ){
1793
- if(isset($image_details[1]) ){
1794
- $width = $image_details[1];
1795
- }
1796
- if(isset($image_details[2])){
1797
- $height = $image_details[2];
1798
- }
1799
- $input2 = array(
1800
- 'image' =>array(
1801
- '@type' =>'ImageObject',
1802
- 'url' =>$image_details[0],
1803
- 'width' =>$width,
1804
- 'height' =>$height,
1805
- ),
1806
- );
1807
- $input1 = array_merge($input1,$input2);
1808
- }else{
1809
- $input2 = array(
1810
- 'image' =>array(
1811
- '@type' =>'ImageObject',
1812
- 'url' => isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['url']:'',
1813
- 'width' => isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['width']:'',
1814
- 'height' => isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['height']:'',
1815
- ),
1816
- );
1817
- $input1 = array_merge($input1,$input2);
1818
- }
1819
 
1820
- }
1821
  if(!empty($input1)){
1822
  $all_schema_output[] = $input1;
1823
  }
@@ -1827,6 +2126,7 @@ function saswp_post_specific_schema_output() {
1827
  }
1828
 
1829
  function saswp_structure_data_access_scripts($data){
 
1830
  if ( empty( $data['amp_component_scripts']['amp-access'] ) ) {
1831
  $data['amp_component_scripts']['amp-access'] = 'https://cdn.ampproject.org/v0/amp-access-0.1.js';
1832
  }
@@ -1837,12 +2137,14 @@ function saswp_structure_data_access_scripts($data){
1837
  $data['amp_component_scripts']['amp-mustache'] = "https://cdn.ampproject.org/v0/amp-mustache-0.1.js";
1838
  }
1839
  return $data;
 
1840
  }
1841
 
1842
  function saswp_list_items_generator(){
 
1843
  global $sd_data;
1844
  $bc_titles = array();
1845
- $bc_links = array();
1846
  if(isset($sd_data['titles'])){
1847
  $bc_titles = $sd_data['titles'];
1848
  }
@@ -1850,9 +2152,10 @@ function saswp_list_items_generator(){
1850
  $bc_links = $sd_data['links'];
1851
  }
1852
 
1853
- $j=1;
1854
  $i = 0;
1855
- $breadcrumbslist = array();
 
1856
  if(is_single()){
1857
 
1858
  if(isset($bc_titles)){
@@ -1903,6 +2206,7 @@ function saswp_list_items_generator(){
1903
  }
1904
 
1905
  function saswp_schema_breadcrumb_output($sd_data){
 
1906
  global $sd_data;
1907
 
1908
  if(isset($sd_data['saswp_breadcrumb_schema']) && $sd_data['saswp_breadcrumb_schema'] == 1){
@@ -1924,9 +2228,11 @@ function saswp_schema_breadcrumb_output($sd_data){
1924
  }
1925
 
1926
  function saswp_kb_website_output(){
1927
- global $sd_data;
1928
- $site_url = get_site_url();
 
1929
  $site_name = get_bloginfo();
 
1930
  $input = array(
1931
  '@context' =>'http://schema.org',
1932
  '@type' => 'WebSite',
@@ -1944,41 +2250,21 @@ function saswp_kb_website_output(){
1944
  }
1945
  // For Archive
1946
  function saswp_archive_output(){
1947
- global $query_string, $sd_data;
1948
- $logo ='';
1949
- $height ='';
1950
- $width ='';
1951
  $site_name ='';
1952
-
1953
- if(isset($sd_data['sd_logo'])){
1954
- $logo = $sd_data['sd_logo']['url'];
1955
- }
1956
-
1957
  if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
1958
  $site_name = $sd_data['sd_name'];
1959
  }else{
1960
  $site_name = get_bloginfo();
1961
- }
1962
-
1963
-
1964
- if('' != $logo && !empty($logo)){
1965
- $height = $sd_data['sd_logo']['height'];
1966
- $width = $sd_data['sd_logo']['width'];
1967
- }else{
1968
- $sizes = array(
1969
- 'width' => 600,
1970
- 'height' => 60,
1971
- 'crop' => false,
1972
- );
1973
- $custom_logo_id = get_theme_mod( 'custom_logo' );
1974
- $custom_logo = wp_get_attachment_image_src( $custom_logo_id, $sizes);
1975
- $logo = $custom_logo[0];
1976
- $height =$custom_logo[1];
1977
- $width =$custom_logo[2];
1978
- }
1979
-
1980
-
1981
  if(isset($sd_data['saswp_archive_schema']) && $sd_data['saswp_archive_schema'] == 1){
 
 
 
 
1982
 
1983
  if ( is_category() ) {
1984
  $category_posts = array();
@@ -1986,32 +2272,33 @@ function saswp_archive_output(){
1986
  if ( $category_loop->have_posts() ):
1987
  while( $category_loop->have_posts() ): $category_loop->the_post();
1988
  $image_id = get_post_thumbnail_id();
1989
- $image_details = wp_get_attachment_image_src($image_id, 'full');
1990
  $publisher_info = array(
1991
  "type" => "Organization",
1992
  "name" => $site_name,
1993
  "logo" => array(
1994
- "@type" => "ImageObject",
1995
- "name" => $site_name,
1996
- "width" => $width,
1997
- "height"=> $height,
1998
- "url"=> $logo
1999
  )
2000
  );
2001
  $publisher_info['name'] = get_bloginfo('name');
2002
  $publisher_info['id'] = get_the_permalink();
2003
- $category_posts[] = array
2004
- (
2005
- '@type' => 'BlogPosting',
2006
- 'headline' => get_the_title(),
2007
- 'url' => get_the_permalink(),
2008
- 'datePublished' => get_the_date('c'),
2009
- 'dateModified' => get_the_modified_date('c'),
2010
- 'mainEntityOfPage' => get_the_permalink(),
2011
- 'author' => get_the_author(),
2012
- 'publisher' => $publisher_info,
2013
- 'image' => $image_details[0],
2014
- );
 
2015
 
2016
  endwhile;
2017
 
@@ -2090,58 +2377,38 @@ function saswp_author_output()
2090
  // For About Page
2091
  function saswp_about_page_output()
2092
  {
2093
- global $sd_data;
2094
- $image_id = get_post_thumbnail_id();
2095
- $image_details = wp_get_attachment_image_src($image_id, 'full');
2096
- if(isset($image_details['url'])){
2097
- $image_url = $image_details['url'];
2098
- }
2099
- $about_page = saswp_remove_warnings($sd_data, 'sd_about_page', 'saswp_string');
2100
 
2101
- if((isset($sd_data['sd_about_page'])) && $sd_data['sd_about_page'] == get_the_ID()){
2102
- $logo = $sd_data['sd_logo']['url'];
2103
- $height = $sd_data['sd_logo']['height'];
2104
- $width = $sd_data['sd_logo']['width'];
2105
-
2106
- if( '' == $image_details && empty($image_details) && isset($sd_data['sd_default_image'])){
2107
- $image_url = $sd_data['sd_default_image']['url'];
2108
- }
2109
-
2110
- if( '' == $image_details && empty($image_details) && isset($sd_data['sd_default_image_height'])){
2111
- $height = $sd_data['sd_default_image_height'];
2112
- }
2113
-
2114
- if( '' == $image_details && empty($image_details) && isset($sd_data['sd_default_image_width'])){
2115
- $width = $sd_data['sd_default_image_width'];
2116
- }
2117
  $input = array(
2118
- "@context" => "http://schema.org",
2119
- "@type" => "AboutPage",
2120
  "mainEntityOfPage" => array(
2121
- "@type" => "WebPage",
2122
- "@id" => get_permalink(),
2123
- ),
2124
- "url" => $about_page,
2125
- "headline" => get_the_title(),
2126
- "image" => array(
2127
- "@type" => "ImageObject",
2128
- "url" => $image_url,
2129
- "width" => $width,
2130
- "height" => $height,
2131
- ),
2132
- 'Publisher' => array(
2133
- '@type' => 'Organization',
2134
- 'logo' => array(
2135
- '@type' => 'ImageObject',
2136
- 'url' => $logo,
2137
- 'width' => $width,
2138
- 'height' => $height,
2139
- ),
2140
- 'name' => $sd_data['sd_name'],
2141
  ),
2142
- 'description' => get_the_excerpt(),
 
 
2143
  );
2144
-
 
 
 
 
 
 
 
 
 
 
2145
  return json_encode($input);
2146
  }
2147
 
@@ -2149,59 +2416,41 @@ function saswp_about_page_output()
2149
 
2150
  // For Contact Page
2151
  function saswp_contact_page_output()
2152
- {
2153
- global $sd_data;
2154
- $image_id = get_post_thumbnail_id();
2155
- $image_details = wp_get_attachment_image_src($image_id, 'full');
2156
- if(isset($image_details['url'])){
2157
- $image_url = $image_details['url'];
2158
- }
2159
- $contact_page = saswp_remove_warnings($sd_data, 'sd_contact_page', 'saswp_string');
2160
  if(isset($sd_data['sd_contact_page']) && $sd_data['sd_contact_page'] == get_the_ID()){
2161
-
2162
- $logo = isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['url']:'';
2163
- $height = isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['height']:'';
2164
- $width = isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['width']:'';
2165
-
2166
- if( '' == $image_details && empty($image_details) && isset($sd_data['sd_default_image'])){
2167
- $image_url = $sd_data['sd_default_image']['url'];
2168
- }
2169
-
2170
- if( '' == $image_details && empty($image_details) && isset($sd_data['sd_default_image_height'])){
2171
- $height = $sd_data['sd_default_image_height'];
2172
- }
2173
-
2174
- if( '' == $image_details && empty($image_details) && isset($sd_data['sd_default_image_width'])){
2175
- $width = $sd_data['sd_default_image_width'];
2176
- }
2177
  $input = array(
 
2178
  "@context" => "http://schema.org",
2179
  "@type" => "ContactPage",
2180
  "mainEntityOfPage" => array(
2181
  "@type" => "WebPage",
2182
  "@id" => get_permalink(),
2183
  ),
2184
- "url" => $contact_page,
2185
- "headline" => get_the_title(),
2186
- "image" => array(
2187
- "@type" => "ImageObject",
2188
- "url" => $image_url,
2189
- "width" => $width,
2190
- "height" => $height,
2191
- ),
2192
- 'Publisher' => array(
2193
- '@type' => 'Organization',
2194
- 'logo' => array(
2195
- '@type' => 'ImageObject',
2196
- 'url' => $logo,
2197
- 'width' => $width,
2198
- 'height' => $height,
2199
- ),
2200
- 'name' => $sd_data['sd_name'],
2201
- ),
2202
- 'description' => get_the_excerpt(),
2203
  );
2204
-
 
 
 
 
 
 
 
 
 
 
 
2205
  return json_encode($input);
2206
 
2207
  }
@@ -2282,7 +2531,7 @@ function saswp_reading_time_and_word_count() {
2282
  $words_per_second = $words_per_minute / 60;
2283
 
2284
  // Count the words in the content.
2285
- $word_count =0;
2286
  $text = trim( strip_tags( get_the_content() ) );
2287
  $word_count = substr_count( "$text ", ' ' );
2288
 
2
  if (! defined('ABSPATH') ) exit;
3
 
4
  function saswp_kb_schema_output() {
5
+
6
  global $sd_data;
7
  $input = array();
8
  // social profile
69
 
70
 
71
  if ( saswp_remove_warnings($sd_data, 'saswp_kb_type', 'saswp_string') == 'Organization' ) {
72
+
73
+ $logo = '';
74
+ $height = '';
75
+ $width = '';
76
+ $contact_info = array();
 
 
 
77
 
78
+ $service_object = new saswp_output_service();
79
+ $default_logo = $service_object->saswp_get_publisher(true);
80
+
81
+ if(!empty($default_logo)){
82
+
83
+ $logo = $default_logo['url'];
84
+ $height = $default_logo['height'];
85
+ $width = $default_logo['width'];
86
+
87
+ }
88
+
89
+ $contact_1 = saswp_remove_warnings($sd_data, 'saswp_contact_type', 'saswp_string');
90
+ $telephone_1 = saswp_remove_warnings($sd_data, 'saswp_kb_telephone', 'saswp_string');
91
+
 
 
 
92
  if( '' == $contact_1 && empty($contact_1) && isset($sd_data['saswp_contact_type'])){
93
  $contact_1 = $sd_data['saswp_contact_type'];
94
  }
95
 
96
  if( '' == $telephone_1 && empty($telephone_1) && isset($sd_data['saswp_kb_telephone'])){
97
  $telephone_1 = $sd_data['saswp_kb_telephone'];
98
+ }
99
+
 
 
100
  $contact_info = array(
101
  'contactPoint' => array(
102
+ '@type' => 'ContactPoint',
103
+ 'contactType' => $contact_1,
104
+ 'telephone' => $telephone_1,
105
  )
106
  );
107
 
110
  '@type' => $sd_data['saswp_kb_type'],
111
  'name' => saswp_remove_warnings($sd_data, 'sd_name', 'saswp_string'),
112
  'url' => saswp_remove_warnings($sd_data, 'sd_url', 'saswp_string'),
113
+ 'sameAs' => $platform,
 
 
 
 
 
 
114
  );
115
+
116
+ if($logo !='' && $width !='' && $height !=''){
117
+
118
+ $input['logo']['@type'] = 'ImageObject';
119
+ $input['logo']['url'] = $logo;
120
+ $input['logo']['width'] = $width;
121
+ $input['logo']['height'] = $height;
122
+
123
+ }
124
 
125
  if ( isset($sd_data['saswp_kb_contact_1'] ) && $sd_data['saswp_kb_contact_1'] ) {
126
+
127
  $input = array_merge($input, $contact_info);
128
+
129
  }
130
  }
131
  // Person
132
 
133
  if ( saswp_remove_warnings($sd_data, 'saswp_kb_type', 'saswp_string') == 'Person' ) {
134
+
135
+ $image = '';
136
+ $height = '';
137
+ $width = '';
138
 
139
  if(isset($sd_data['sd-person-image'])){
140
  $image = $sd_data['sd-person-image']['url'];
168
  'telephone' => $sd_data['sd-person-phone-number'],
169
  );
170
  }
171
+
172
+
173
  return json_encode($input);
174
  }
175
 
177
  return ( is_author() || is_category() || is_tag() || is_date() || is_home() || is_single() ) && 'post' == get_post_type();
178
  }
179
 
180
+ function saswp_schema_output() {
181
+
182
  global $sd_data;
183
 
184
+ $Conditionals = saswp_get_all_schema_posts();
185
 
186
  if(!$Conditionals){
187
  return ;
188
+ }
189
+
190
  $all_schema_output = array();
 
191
 
192
+ foreach($Conditionals as $schemaConditionals){
193
+
 
 
194
  $schema_options = saswp_remove_warnings($schemaConditionals, 'schema_options', 'saswp_string');
195
  $schema_type = saswp_remove_warnings($schemaConditionals, 'schema_type', 'saswp_string');
196
  $schema_post_id = saswp_remove_warnings($schemaConditionals, 'post_id', 'saswp_string');
197
+
198
+ $logo ='';
199
+ $height ='';
200
+ $width ='';
201
+ $site_name ='';
202
+
203
+ $service_object = new saswp_output_service();
204
+ $default_logo = $service_object->saswp_get_publisher(true);
205
 
206
+ if(!empty($default_logo)){
207
+
208
+ $logo = $default_logo['url'];
209
+ $height = $default_logo['height'];
210
+ $width = $default_logo['width'];
211
+
212
  }
 
213
 
214
  if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
215
  $site_name = $sd_data['sd_name'];
216
  }else{
217
  $site_name = get_bloginfo();
218
+ }
219
+ //if(is_singular()){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  // Generate author id
221
+ $author_id = get_the_author_meta('ID');
222
 
223
  // Blogposting Schema
224
  $image_id = get_post_thumbnail_id();
228
  $modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
229
  $aurthor_name = get_the_author();
230
 
231
+ $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
232
+
233
+ $aggregateRating = array();
234
  $kkstar_aggregateRating = array();
235
+ $saswp_over_all_rating ='';
236
+
237
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
238
+
239
+ $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
240
+
241
+ }
242
+
243
  $saswp_review_item_enable = 0;
244
+
245
  if(isset($saswp_review_details['saswp-review-item-enable'])){
246
+
247
+ $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
248
+
249
  }
250
+
251
  $saswp_review_count = "1";
252
 
253
 
254
  if($saswp_over_all_rating && $saswp_review_count && $saswp_review_item_enable ==1){
255
+
256
  $aggregateRating = array(
257
+ "@type" => "AggregateRating",
258
  "ratingValue" => $saswp_over_all_rating,
259
  "reviewCount" => $saswp_review_count
260
  );
261
+
262
  }
263
 
264
+ $kkstar_rating_data = saswp_extract_kk_star_ratings(get_the_ID());
265
+
266
  if(!empty($kkstar_rating_data)){
267
+
268
  $kkstar_aggregateRating = array(
269
+ "@type" => "AggregateRating",
270
  "bestRating" => saswp_remove_warnings($kkstar_rating_data, 'best', 'saswp_string'),
271
  "ratingCount" => saswp_remove_warnings($kkstar_rating_data, 'votes', 'saswp_string'),
272
  "ratingValue" => saswp_remove_warnings($kkstar_rating_data, 'avg', 'saswp_string')
273
+ );
274
+
275
  }
276
  $extra_theme_review = array();
277
+ $service_object = new saswp_output_service();
278
  $extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
279
 
280
  if( 'Blogposting' === $schema_type){
285
 
286
  'mainEntityOfPage' => get_permalink(),
287
  'headline' => get_the_title(),
288
+ 'description' => strip_tags(get_the_excerpt()),
289
  'name' => get_the_title(),
290
  'url' => get_permalink(),
291
  'datePublished' => $date,
370
  }
371
  }
372
 
373
+ if( 'WebPage' === $schema_type){
374
+
375
+ $service = new saswp_output_service();
376
+ $input1 = $service->saswp_schema_markup_generator($schema_type);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
 
 
378
  if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
379
  $service = new saswp_output_service();
380
  $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
395
 
396
  if( 'Article' === $schema_type ){
397
 
398
+ $service = new saswp_output_service();
399
+ $input1 = $service->saswp_schema_markup_generator($schema_type);
400
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
402
  $service = new saswp_output_service();
403
  $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
415
  if(empty($image_details[0]) || $image_details[0] === NULL ){
416
  $image_details[0] = $sd_data['sd_logo']['url'];
417
  }
418
+
419
  $input1 = array(
420
  '@context' => 'http://schema.org',
421
  '@type' => $schema_type ,
423
  'name' => get_the_title(),
424
  'datePublished' => $date,
425
  'dateModified' => $modified_date,
426
+ 'description' => strip_tags(get_the_excerpt()),
427
  'mainEntity' => array(
428
  '@type' => 'WebPage',
429
  '@id' => get_permalink(),
553
  'name' => saswp_remove_warnings($schema_data, 'saswp_product_schema_name', 'saswp_string'),
554
  'sku' => saswp_remove_warnings($schema_data, 'saswp_product_schema_sku', 'saswp_string'),
555
  'description' => saswp_remove_warnings($schema_data, 'saswp_product_schema_description', 'saswp_string'),
556
+ 'image' => array(
557
  '@type' =>'ImageObject',
558
  'url' => isset($schema_data['saswp_product_schema_image']) ? $schema_data['saswp_product_schema_image']['url']:'' ,
559
  'width' => isset($schema_data['saswp_product_schema_image']) ? $schema_data['saswp_product_schema_image']['width']:'' ,
613
  }
614
 
615
  if( 'NewsArticle' === $schema_type ){
616
+
617
+ $category_detail = get_the_category(get_the_ID());//$post->ID
618
  $article_section = '';
619
+
620
  foreach($category_detail as $cd){
621
+
622
+ $article_section = $cd->cat_name;
623
+
624
  }
625
+ $word_count = saswp_reading_time_and_word_count();
626
  $input1 = array(
627
  '@context' => 'http://schema.org',
628
  '@type' => $schema_type ,
631
  'mainEntityOfPage' => get_the_permalink(),
632
  'datePublished' => $date,
633
  'dateModified' => $modified_date,
634
+ 'description' => strip_tags(get_the_excerpt()),
635
  'articleSection' => $article_section,
636
+ 'articleBody' => strip_tags(get_the_excerpt()),
637
  'name' => get_the_title(),
638
  'thumbnailUrl' => saswp_remove_warnings($image_details, 0, 'saswp_string'),
639
  'wordCount' => saswp_remove_warnings($word_count, 'word_count', 'saswp_string'),
684
 
685
  if( 'Service' === $schema_type ){
686
 
687
+ $schema_data = saswp_get_schema_data($schema_post_id, 'saswp_service_schema_details');
688
 
689
+ $area_served_str = saswp_remove_warnings($schema_data, 'saswp_service_schema_area_served', 'saswp_string');
690
+ $area_served_arr = explode(',', $area_served_str);
691
 
692
  $service_offer_str = saswp_remove_warnings($schema_data, 'saswp_service_schema_service_offer', 'saswp_string');
693
  $service_offer_arr = explode(',', $service_offer_str);
718
  'description' => saswp_remove_warnings($schema_data, 'saswp_service_schema_description', 'saswp_string'),
719
  );
720
  $areaServed = array();
721
+
722
  foreach($area_served_arr as $area){
723
+
724
  $areaServed[] = array(
725
  '@type' => 'City',
726
  'name' => $area
727
  );
728
+
729
  }
730
  $serviceOffer = array();
731
+
732
  foreach($service_offer_arr as $offer){
733
+
734
  $serviceOffer[] = array(
735
  '@type' => 'Offer',
736
  'name' => $offer
737
  );
738
+
739
  }
740
+
741
  $input1['areaServed'] = $areaServed;
742
+
743
  $input1['hasOfferCatalog'] = array(
744
+ '@type' => 'OfferCatalog',
745
+ 'name' => $schema_data['saswp_service_schema_name'],
746
  'itemListElement' => $serviceOffer
747
  );
748
 
754
  if(isset($schema_data['saswp_service_schema_enable_rating'])){
755
 
756
  $input1['aggregateRating'] = array(
757
+ "@type" => "AggregateRating",
758
  "ratingValue" => saswp_remove_warnings($schema_data, 'saswp_service_schema_rating', 'saswp_string'),
759
  "reviewCount" => saswp_remove_warnings($schema_data, 'saswp_service_schema_review_count', 'saswp_string')
760
  );
773
 
774
  if( 'Review' === $schema_type ){
775
 
776
+ $schema_data = saswp_get_schema_data($schema_post_id, 'saswp_review_schema_details');
777
+
778
+ if(isset($schema_data['saswp_review_schema_item_type'])){
779
+
780
+
781
  $review_author = get_the_author();
782
+
783
  if(isset($schema_data['saswp_review_schema_author'])){
784
+
785
  $review_author = $schema_data['saswp_review_schema_author'];
786
+
787
  }
788
+
789
+ $input1['@context'] = 'http://schema.org';
790
+ $input1['@type'] = $schema_type;
791
+ $input1['url'] = get_permalink();
792
+ $input1['datePublished'] = $date;
793
+ $input1['dateModified'] = $modified_date;
794
 
795
+ if($review_author){
796
+
797
+ $input1['author']['@type'] = 'Person';
798
+ $input1['author']['name'] = $review_author;
799
+
800
+ if(isset($schema_data['saswp_review_schema_author_sameas'])){
801
+
802
+ $input1['author']['sameAs'] = $schema_data['saswp_review_schema_author_sameas'];
803
+
804
+ }
805
+
806
+ }
807
+
808
+ if($site_name && $logo && $width && $height){
809
+
810
+ $input1['Publisher']['@type'] = 'Organization';
811
+ $input1['Publisher']['name'] = $site_name;
812
+ $input1['Publisher']['logo']['@type'] = 'ImageObject';
813
+ $input1['Publisher']['logo']['url'] = $logo;
814
+ $input1['Publisher']['logo']['width'] = $width;
815
+ $input1['Publisher']['logo']['height'] = $height;
816
+
817
+ }
818
+
819
+ if(isset($schema_data['saswp_review_schema_description'])){
820
+
821
+ $input1['reviewBody'] = $schema_data['saswp_review_schema_description'];
822
+ $input1['description'] = $schema_data['saswp_review_schema_description'];
823
+ }else {
824
+ $input1['reviewBody'] = strip_tags(get_the_excerpt());
825
+ $input1['description'] = strip_tags(get_the_excerpt());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
826
  }
827
 
828
+ if(isset($schema_data['saswp_review_schema_item_type'])){
829
+ $input1['itemReviewed']['@type'] = $schema_data['saswp_review_schema_item_type'];
830
+ }
831
+ if(isset($schema_data['saswp_review_schema_name'])){
832
+ $input1['itemReviewed']['name'] = $schema_data['saswp_review_schema_name'];
833
+ }
834
+ if(isset($schema_data['saswp_review_schema_url'])){
835
+ $input1['itemReviewed']['url'] = $schema_data['saswp_review_schema_url'];
836
+ }
837
+
838
+ if(isset($schema_data['saswp_review_schema_price_range'])){
839
+
840
+ $input1['itemReviewed']['priceRange'] = $schema_data['saswp_review_schema_price_range'];
841
+
842
+ }
843
+
844
+ if(isset($schema_data['saswp_review_schema_telephone'])){
845
+
846
+ $input1['itemReviewed']['telephone'] = $schema_data['saswp_review_schema_telephone'];
847
+
848
+ }
849
+
850
+ if(isset($schema_data['saswp_review_schema_servescuisine'])){
851
+
852
+ $input1['itemReviewed']['servesCuisine'] = $schema_data['saswp_review_schema_servescuisine'];
853
+
854
+ }
855
+
856
+ if(isset($schema_data['saswp_review_schema_itemreviewed_sameas'])){
857
+
858
+ $input1['itemReviewed']['sameAs'] = $schema_data['saswp_review_schema_itemreviewed_sameas'];
859
+
860
+ }
861
+
862
+
863
+ if(isset($schema_data['saswp_review_schema_director'])){
864
+
865
+ $input1['itemReviewed']['director'] = $schema_data['saswp_review_schema_director'];
866
+
867
+ }
868
+ if(isset($schema_data['saswp_review_schema_date_created'])){
869
+
870
+ $input1['itemReviewed']['dateCreated'] = date_format(date_create($schema_data['saswp_review_schema_date_created']), "Y-m-d\TH:i:s\Z");
871
+
872
+ }
873
+
874
+
875
+ if(isset($schema_data['saswp_review_schema_image'])){
876
+
877
+ $input1['itemReviewed']['image']['@type'] = 'ImageObject';
878
+ $input1['itemReviewed']['image']['url'] = $schema_data['saswp_review_schema_image'];
879
+ $input1['itemReviewed']['image']['width'] = $schema_data['saswp_review_schema_image_detail']['width'];
880
+ $input1['itemReviewed']['image']['height']= $schema_data['saswp_review_schema_image_detail']['height'];
881
+
882
+ }
883
+
884
+ if(saswp_remove_warnings($schema_data, 'saswp_review_schema_street_address', 'saswp_string') !='' || saswp_remove_warnings($schema_data, 'saswp_review_schema_locality', 'saswp_string') !=''){
885
+
886
+ $input1['itemReviewed']['address']['@type'] = 'PostalAddress';
887
+ $input1['itemReviewed']['address']['streetAddress'] = saswp_remove_warnings($schema_data, 'saswp_review_schema_street_address', 'saswp_string');
888
+ $input1['itemReviewed']['address']['addressLocality'] = saswp_remove_warnings($schema_data, 'saswp_review_schema_locality', 'saswp_string');
889
+ $input1['itemReviewed']['address']['addressRegion'] = saswp_remove_warnings($schema_data, 'saswp_review_schema_region', 'saswp_string');
890
+ $input1['itemReviewed']['address']['postalCode'] = saswp_remove_warnings($schema_data, 'saswp_review_schema_postal_code', 'saswp_string');
891
+ $input1['itemReviewed']['address']['addressCountry'] = saswp_remove_warnings($schema_data, 'saswp_review_schema_country', 'saswp_string');
892
+
893
+ }
894
+
895
+ $service = new saswp_output_service();
896
+
897
+
898
+ switch ($schema_data['saswp_review_schema_item_type']) {
899
+
900
+ case 'Article':
901
+
902
+ $markup = $service->saswp_schema_markup_generator($schema_data['saswp_review_schema_item_type']);
903
+ $input1['itemReviewed'] = $markup;
904
+
905
+ break;
906
+ case 'Adultentertainment':
907
+ $input1 = $input1;
908
+ break;
909
+ case 'Blog':
910
+ $input1 = $input1;
911
+ break;
912
+ case 'Book':
913
+
914
+ if(isset($schema_data['saswp_review_schema_isbn'])){
915
+
916
+ $input1['itemReviewed']['isbn'] = $schema_data['saswp_review_schema_isbn'];
917
+
918
+ }
919
+ if($review_author) {
920
+
921
+ $input1['itemReviewed']['author']['@type'] = 'Person';
922
+ $input1['itemReviewed']['author']['name'] = $review_author;
923
+ $input1['itemReviewed']['author']['sameAs'] = $schema_data['saswp_review_schema_author_sameas'];
924
+ }
925
+
926
+ break;
927
+ case 'Casino':
928
+ break;
929
+ case 'Diet':
930
+ break;
931
+ case 'Episode':
932
+ break;
933
+ case 'ExercisePlan':
934
+ break;
935
+ case 'Game':
936
+ break;
937
+ case 'Movie':
938
+
939
+ if($review_author){
940
+
941
+ $input1['author']['sameAs'] = get_permalink();
942
+
943
+ }
944
+
945
+
946
+ break;
947
+ case 'MusicPlaylist':
948
+ break;
949
+ case 'MusicRecording':
950
+ break;
951
+ case 'Photograph':
952
+ break;
953
+ case 'Recipe':
954
+ break;
955
+ case 'Restaurant':
956
+ break;
957
+ case 'Series':
958
+ break;
959
+ case 'SoftwareApplication':
960
+ break;
961
+ case 'VisualArtwork':
962
+ break;
963
+ case 'WebPage':
964
+
965
+ $markup = $service->saswp_schema_markup_generator($schema_data['saswp_review_schema_item_type']);
966
+ $input1['itemReviewed'] = $markup;
967
+
968
+ break;
969
+ case 'WebSite':
970
+ break;
971
+
972
+
973
+ default:
974
+ $input1 = $input1;
975
+ break;
976
+ }
977
+
978
+ if(isset($schema_data['saswp_review_schema_enable_rating']) && saswp_remove_warnings($schema_data, 'saswp_review_schema_rating', 'saswp_string') !='' && saswp_remove_warnings($schema_data, 'saswp_review_schema_review_count', 'saswp_string') !=''){
979
 
980
  $input1['reviewRating'] = array(
981
  "@type"=> "Rating",
982
  "ratingValue" => saswp_remove_warnings($schema_data, 'saswp_review_schema_rating', 'saswp_string'),
983
+ "bestRating" => saswp_remove_warnings($schema_data, 'saswp_review_schema_review_count', 'saswp_string'),
984
  );
985
  }
986
+
987
+ if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
988
+ $service = new saswp_output_service();
989
+ $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
990
+ }
991
+
992
+
993
+ }
994
+
995
 
996
+ }
997
 
998
  if( 'VideoObject' === $schema_type){
999
 
1008
  'headline' => get_the_title(),
1009
  'datePublished' => $date,
1010
  'dateModified' => $modified_date,
1011
+ 'description' => strip_tags(get_the_excerpt()),
1012
  'name' => get_the_title(),
1013
  'uploadDate' => $date,
1014
  'thumbnailUrl' => $image_details[0],
1062
  $business_type = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_type', true) );
1063
  $business_name = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_name', true) );
1064
  $business_details = esc_sql ( get_post_meta($schema_post_id, 'saswp_local_business_details', true) );
1065
+ $dayoftheweek = get_post_meta($schema_post_id, 'saswp_dayofweek', true);
1066
+ $dayoftheweek = explode( "\r\n", $dayoftheweek);
1067
+
1068
  if(empty($image_details[0]) || $image_details[0] === NULL ){
1069
  $image_details[0] = $logo;
1070
  }
1071
  if(isset($business_details['local_business_logo'])){
1072
+
1073
  unset($image_details);
1074
  $image_details[0] = isset($business_details['local_business_logo']) ? $business_details['local_business_logo']['url']:'';
1075
  $image_details[1] = isset($business_details['local_business_logo']) ? $business_details['local_business_logo']['width']:'';
1076
  $image_details[2] = isset($business_details['local_business_logo']) ? $business_details['local_business_logo']['height']:'';
1077
+
1078
  }
1079
  if($business_name){
1080
+
1081
  $local_business = $business_name;
1082
+
1083
  }else{
1084
+
1085
  $local_business = $business_type;
1086
+
1087
+ }
1088
+
1089
  $input1 = array(
1090
  '@context' => 'http://schema.org',
1091
  '@type' => $local_business ,
1092
  'name' => saswp_remove_warnings($business_details, 'local_business_name', 'saswp_string'),
1093
  'url' => get_permalink(),
1094
+ 'description' => strip_tags(get_the_excerpt()),
1095
  'address' => array(
1096
  "@type" => "PostalAddress",
1097
  "streetAddress" => saswp_remove_warnings($business_details, 'local_street_address', 'saswp_string'),
1112
  if(isset($business_details['local_enable_rating'])){
1113
 
1114
  $input1['aggregateRating'] = array(
1115
+ "@type" => "AggregateRating",
1116
  "ratingValue" => saswp_remove_warnings($business_details, 'local_rating', 'saswp_string'),
1117
  "reviewCount" => saswp_remove_warnings($business_details, 'local_review_count', 'saswp_string')
1118
  );
1148
  //Check for Featured Image
1149
 
1150
  if( !empty($input1) && !isset($input1['image'])){
1151
+
1152
+ $service_object = new saswp_output_service();
1153
+ $input2 = $service_object->saswp_get_fetaure_image();
1154
+
1155
+ if(!empty($input2)){
1156
+
1157
+ $input1 = array_merge($input1,$input2);
1158
+
1159
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1160
  }
1161
 
1162
  if(isset($schema_options['notAccessibleForFree'])==1){
1163
 
1164
  add_filter( 'amp_post_template_data', 'saswp_structure_data_access_scripts');
1165
+
1166
+ $paywall_class_name = $schema_options['paywall_class_name'];
1167
  $isAccessibleForFree = isset($schema_options['isAccessibleForFree'])? $schema_options['isAccessibleForFree']: False;
1168
 
1169
+ if($paywall_class_name != ""){
1170
+
1171
+ if(strpos($paywall_class_name, ".") == -1){
1172
+
1173
  $paywall_class_name = ".".$paywall_class_name;
1174
+
1175
  }
1176
  $paywallData = array("isAccessibleForFree"=> $isAccessibleForFree,
1177
+ "hasPart"=>array(
1178
+ "@type" => "WebPageElement",
1179
+ "isAccessibleForFree" => $isAccessibleForFree,
1180
+ "cssSelector" => $paywall_class_name
1181
+ )
1182
+ );
1183
+
1184
  $input1 = array_merge($input1,$paywallData);
1185
  }
1186
  }
1187
 
1188
  if(!empty($input1)){
1189
+ $all_schema_output[] = $input1;
1190
  }
1191
+ //}
1192
  }
1193
  return $all_schema_output;
1194
  }
1195
 
1196
  function saswp_post_specific_schema_output() {
1197
+
1198
  global $post;
1199
  global $sd_data;
 
 
 
 
 
 
 
 
1200
 
1201
+
1202
+ $logo ='';
1203
+ $height ='';
1204
+ $width ='';
1205
+ $site_name ='';
1206
+
1207
+ $service_object = new saswp_output_service();
1208
+ $default_logo = $service_object->saswp_get_publisher(true);
1209
+
1210
+ if(!empty($default_logo)){
1211
+
1212
+ $logo = $default_logo['url'];
1213
+ $height = $default_logo['height'];
1214
+ $width = $default_logo['width'];
1215
+
1216
+ }
1217
+
1218
+ if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
1219
+ $site_name = $sd_data['sd_name'];
1220
+ }else{
1221
+ $site_name = get_bloginfo();
1222
+ }
1223
+
1224
+
1225
+ $all_schema_output = array();
1226
+ $all_schemas = json_decode(get_transient('saswp_transient_schema_ids'), true);
1227
+ $schema_enable = get_post_meta($post->ID, 'saswp_enable_disable_schema', true);
1228
 
1229
  foreach($all_schemas as $schema){
1230
+
1231
+ $schema_id = $schema;
1232
+ $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
1233
  $schema_post_id = $post->ID;
1234
+ $all_post_meta = esc_sql ( get_post_meta($schema_post_id, $key='', true) );
1235
 
1236
  if(is_singular() && isset($schema_enable[$schema_id]) && $schema_enable[$schema_id] == 1 ){
1237
 
1238
  $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
1239
+
1240
+ $aggregateRating = array();
1241
  $saswp_over_all_rating ='';
1242
+
1243
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
1244
+
1245
  $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
1246
+
1247
  }
1248
  $saswp_review_item_enable = 0;
1249
+
1250
  if(isset($saswp_review_details['saswp-review-item-enable'])){
1251
+
1252
  $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
1253
+
1254
  }
1255
  $saswp_review_count = "1";
1256
 
1257
  if($saswp_over_all_rating && $saswp_review_count && $saswp_review_item_enable ==1){
1258
+
1259
  $aggregateRating = array(
1260
  "@type"=> "AggregateRating",
1261
  "ratingValue" => $saswp_over_all_rating,
1262
  "reviewCount" => $saswp_review_count
1263
  );
1264
+
1265
  }
1266
+
1267
+ $kkstar_rating_data = saswp_extract_kk_star_ratings(get_the_ID());
1268
+
1269
  if(!empty($kkstar_rating_data)){
1270
+
1271
  $kkstar_aggregateRating = array(
1272
  "@type"=> "AggregateRating",
1273
  "bestRating" => saswp_remove_warnings($kkstar_rating_data, 'best', 'saswp_string'),
1274
  "ratingCount" => saswp_remove_warnings($kkstar_rating_data, 'votes', 'saswp_string'),
1275
  "ratingValue" => saswp_remove_warnings($kkstar_rating_data, 'avg', 'saswp_string')
1276
+ );
1277
+
1278
  }
1279
  $extra_theme_review = array();
1280
+ $service_object = new saswp_output_service();
1281
  $extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
1282
 
1283
 
1284
 
1285
+ if( 'qanda' === $schema_type){
1286
+
1287
  if(trim(saswp_remove_warnings($all_post_meta, 'saswp_qa_question_title_'.$schema_id, 'saswp_array')) ==''){
1288
+
1289
  $service_object = new saswp_output_service();
1290
+ $input1 = $service_object->saswp_dw_question_answers_details(get_the_ID());
1291
+
1292
  }else{
1293
+
1294
  $input1 = array(
1295
  '@context' => 'http://schema.org',
1296
  '@type' => 'QAPage' ,
1297
+ 'mainEntity' => array(
1298
  '@type' => 'Question' ,
1299
  'name' => saswp_remove_warnings($all_post_meta, 'saswp_qa_question_title_'.$schema_id, 'saswp_array'),
1300
  'text' => saswp_remove_warnings($all_post_meta, 'saswp_qa_question_description_'.$schema_id, 'saswp_array'),
1301
  'upvoteCount' => saswp_remove_warnings($all_post_meta, 'saswp_qa_upvote_count_'.$schema_id, 'saswp_array'),
1302
  'dateCreated' => saswp_remove_warnings($all_post_meta, 'saswp_qa_date_created_'.$schema_id, 'saswp_array'),
1303
+ 'author' => array('@type' => 'Person','name' =>saswp_remove_warnings($all_post_meta, 'saswp_qa_question_author_name_'.$schema_id, 'saswp_array')) ,
1304
  'answerCount' => 2 ,
1305
  'acceptedAnswer' => array(
1306
+ '@type' => 'Answer',
1307
+ 'upvoteCount' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_upvote_count_'.$schema_id, 'saswp_array'),
1308
+ 'url' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_url_'.$schema_id, 'saswp_array'),
1309
+ 'text' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_text_'.$schema_id, 'saswp_array'),
1310
+ 'dateCreated' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_answer_date_created_'.$schema_id, 'saswp_array'),
1311
+ 'author' => array('@type' => 'Person', 'name' => saswp_remove_warnings($all_post_meta, 'saswp_qa_accepted_author_name_'.$schema_id, 'saswp_array')),
1312
  ) ,
1313
  'suggestedAnswer' => array(
1314
+ '@type' => 'Answer',
1315
+ 'upvoteCount' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_upvote_count_'.$schema_id, 'saswp_array'),
1316
+ 'url' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_url_'.$schema_id, 'saswp_array'),
1317
+ 'text' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_text_'.$schema_id, 'saswp_array'),
1318
+ 'dateCreated' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_answer_date_created_'.$schema_id, 'saswp_array'),
1319
+ 'author' => array('@type' => 'Person', 'name' => saswp_remove_warnings($all_post_meta, 'saswp_qa_suggested_author_name_'.$schema_id, 'saswp_array')),
1320
  ) ,
1321
  )
1322
  );
1323
  }
1324
  }
1325
 
1326
+ if( 'Blogposting' === $schema_type){
1327
 
1328
  $logo = get_post_meta( get_the_ID(), 'saswp_blogposting_organization_logo_'.$schema_id.'_detail',true);
1329
  $input1 = array(
1363
  }
1364
  }
1365
 
1366
+ if( 'AudioObject' === $schema_type){
1367
 
1368
  $input1 = array(
1369
  '@context' => 'http://schema.org',
1393
  }
1394
 
1395
  if( 'WebPage' === $schema_type){
1396
+
1397
  $logo = get_post_meta( get_the_ID(), 'saswp_webpage_organization_logo_'.$schema_id.'_detail',true);
1398
  $input1 = array(
1399
  '@context' => 'http://schema.org',
1427
 
1428
  );
1429
  if(!empty($aggregateRating)){
1430
+
1431
  $input1['mainEntity']['aggregateRating'] = $aggregateRating;
1432
+
1433
  }
1434
  if(!empty($kkstar_aggregateRating)){
1435
+
1436
  $input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
1437
+
1438
  }
1439
  if(!empty($extra_theme_review)){
1440
+
1441
  $input1 = array_merge($input1, $extra_theme_review);
1442
+
1443
  }
1444
  }
1445
 
1446
  if( 'Article' === $schema_type ){
1447
 
1448
  $logo = get_post_meta( get_the_ID(), 'saswp_article_organization_logo_'.$schema_id.'_detail',true);
1449
+
1450
  $input1 = array(
1451
  '@context' => 'http://schema.org',
1452
  '@type' => 'Article',
1473
 
1474
  );
1475
  if(!empty($kkstar_aggregateRating)){
1476
+
1477
+ $input1['aggregateRating'] = $kkstar_aggregateRating;
1478
+
1479
  }
1480
  if(!empty($extra_theme_review)){
1481
+
1482
  $input1 = array_merge($input1, $extra_theme_review);
1483
+
1484
  }
1485
  }
1486
 
1487
  if( 'Recipe' === $schema_type){
1488
+
1489
+ $recipe_logo = get_post_meta( get_the_ID(), 'saswp_article_organization_logo_'.$schema_id.'_detail',true);
1490
+ $recipe_image = get_post_meta( get_the_ID(), 'saswp_recipe_author_image_'.$schema_id.'_detail',true);
1491
+
1492
+ $ingredient = array();
1493
+ $instruction = array();
1494
 
1495
  if(isset($all_post_meta['saswp_recipe_ingredient_'.$schema_id])){
1496
+
1497
  $explod = explode(';', $all_post_meta['saswp_recipe_ingredient_'.$schema_id][0]);
1498
  foreach ($explod as $val){
1499
  $ingredient[] = $val;
1500
+ }
1501
+
1502
  }
1503
 
1504
  if(isset($all_post_meta['saswp_recipe_instructions_'.$schema_id])){
1505
+
1506
+ $explod = explode(';', $all_post_meta['saswp_recipe_instructions_'.$schema_id][0]);
1507
+
1508
  foreach ($explod as $val){
1509
+
1510
  $instruction[] = array(
1511
  '@type' => "HowToStep",
1512
+ 'text' => $val,
1513
  );
1514
+
1515
+ }
1516
+
1517
  }
1518
 
1519
  $input1 = array(
1541
  'recipeCategory' => saswp_remove_warnings($all_post_meta, 'saswp_recipe_category_'.$schema_id, 'saswp_array'),
1542
  'recipeCuisine' => saswp_remove_warnings($all_post_meta, 'saswp_recipe_cuisine_'.$schema_id, 'saswp_array'),
1543
  'nutrition' => array(
1544
+ '@type' => "NutritionInformation",
1545
+ 'calories' => saswp_remove_warnings($all_post_meta, 'saswp_recipe_nutrition_'.$schema_id, 'saswp_array'),
1546
  ),
1547
  'recipeIngredient' => $ingredient,
1548
  'recipeInstructions' => $instruction,
1589
 
1590
  if( 'Product' === $schema_type){
1591
 
1592
+ $product_image = get_post_meta( get_the_ID(), 'saswp_product_schema_image_'.$schema_id.'_detail',true);
1593
  $input1 = array(
1594
  '@context' => 'http://schema.org',
1595
  '@type' => 'Product',
1819
  }
1820
  }
1821
 
1822
+ if( 'Review' === $schema_type ){
1823
+
1824
+ $service = new saswp_output_service();
1825
+
1826
  $review_author = get_the_author();
1827
 
1828
  if(isset($all_post_meta['saswp_review_schema_author_'.$schema_id])){
1829
  $review_author = $all_post_meta['saswp_review_schema_author_'.$schema_id][0];
1830
  }
1831
+
1832
+ $input1['@context'] = 'http://schema.org';
1833
+ $input1['@type'] = $schema_type;
1834
+ $input1['url'] = get_permalink();
1835
+ $input1['datePublished'] = get_the_date("Y-m-d\TH:i:s\Z");
1836
+ $input1['dateModified'] = get_the_modified_date("Y-m-d\TH:i:s\Z");
1837
+
1838
+ if($review_author){
1839
+
1840
+ $input1['author']['@type'] = 'Person';
1841
+ $input1['author']['name'] = $review_author;
1842
+
1843
+ if(isset($all_post_meta['saswp_review_schema_author_sameas_'.$schema_id])){
1844
+
1845
+ $input1['author']['sameAs'] = $all_post_meta['saswp_review_schema_author_sameas_'.$schema_id][0];
1846
+
1847
+ }
1848
+
1849
+ }
1850
+
1851
+ if($site_name && $logo && $width && $height){
1852
+
1853
+ $input1['Publisher']['@type'] = 'Organization';
1854
+ $input1['Publisher']['name'] = $site_name;
1855
+ $input1['Publisher']['logo']['@type'] = 'ImageObject';
1856
+ $input1['Publisher']['logo']['url'] = $logo;
1857
+ $input1['Publisher']['logo']['width'] = $width;
1858
+ $input1['Publisher']['logo']['height'] = $height;
1859
+
1860
+ }
1861
+
1862
+ if(isset($all_post_meta['saswp_review_schema_description_'.$schema_id])){
1863
+
1864
+ $input1['reviewBody'] = $all_post_meta['saswp_review_schema_description_'.$schema_id][0];
1865
+ $input1['description'] = $all_post_meta['saswp_review_schema_description_'.$schema_id][0];
1866
+ }else {
1867
+ $input1['reviewBody'] = strip_tags(get_the_excerpt());
1868
+ $input1['description'] = strip_tags(get_the_excerpt());
1869
+ }
1870
+
1871
+ if(isset($all_post_meta['saswp_review_schema_item_type_'.$schema_id])){
1872
+ $input1['itemReviewed']['@type'] = $all_post_meta['saswp_review_schema_item_type_'.$schema_id][0];
1873
+ }
1874
+ if(isset($all_post_meta['saswp_review_schema_name_'.$schema_id])){
1875
+ $input1['itemReviewed']['name'] = $all_post_meta['saswp_review_schema_name_'.$schema_id][0];
1876
+ }
1877
+ if(isset($all_post_meta['saswp_review_schema_url_'.$schema_id])){
1878
+ $input1['itemReviewed']['url'] = $all_post_meta['saswp_review_schema_url_'.$schema_id][0];
1879
+ }
1880
+
1881
+ if(isset($all_post_meta['saswp_review_schema_price_range_'.$schema_id])){
1882
+
1883
+ $input1['itemReviewed']['priceRange'] = $all_post_meta['saswp_review_schema_price_range_'.$schema_id][0];
1884
+
1885
+ }
1886
+
1887
+ if(isset($all_post_meta['saswp_review_schema_telephone_'.$schema_id])){
1888
+
1889
+ $input1['itemReviewed']['telephone'] = $all_post_meta['saswp_review_schema_telephone_'.$schema_id][0];
1890
+
1891
+ }
1892
+
1893
+ if(isset($all_post_meta['saswp_review_schema_servescuisine_'.$schema_id])){
1894
+
1895
+ $input1['itemReviewed']['servesCuisine'] = $all_post_meta['saswp_review_schema_servescuisine_'.$schema_id][0];
1896
+
1897
+ }
1898
+
1899
+ if(isset($all_post_meta['saswp_review_schema_itemreviewed_sameas_'.$schema_id])){
1900
+
1901
+ $input1['itemReviewed']['sameAs'] = $all_post_meta['saswp_review_schema_itemreviewed_sameas_'.$schema_id][0];
1902
+
1903
+ }
1904
+
1905
+
1906
+ if(isset($all_post_meta['saswp_review_schema_director_'.$schema_id])){
1907
+
1908
+ $input1['itemReviewed']['director'] = $all_post_meta['saswp_review_schema_director_'.$schema_id][0];
1909
+
1910
+ }
1911
+ if(isset($all_post_meta['saswp_review_schema_date_created_'.$schema_id])){
1912
+
1913
+ $input1['itemReviewed']['dateCreated'] = date_format(date_create($all_post_meta['saswp_review_schema_date_created_'.$schema_id][0]), "Y-m-d\TH:i:s\Z");
1914
+
1915
+ }
1916
+
1917
+
1918
+ if(isset($all_post_meta['saswp_review_schema_image_'.$schema_id])){
1919
+
1920
+ $input1['itemReviewed']['image']['@type'] = 'ImageObject';
1921
+ $input1['itemReviewed']['image']['url'] = $all_post_meta['saswp_review_schema_image_'.$schema_id];
1922
+ $input1['itemReviewed']['image']['width'] = $all_post_meta['saswp_review_schema_image_detail_'.$schema_id]['width'];
1923
+ $input1['itemReviewed']['image']['height']= $all_post_meta['saswp_review_schema_image_detail_'.$schema_id]['height'];
1924
+
1925
+ }
1926
+
1927
+
1928
+ if(saswp_remove_warnings($all_post_meta, 'saswp_review_schema_street_address_'.$schema_id, 'saswp_array') !='' || saswp_remove_warnings($all_post_meta, 'saswp_review_schema_locality_'.$schema_id, 'saswp_array') !=''){
1929
+
1930
+
1931
+ $input1['itemReviewed']['address']['@type'] = 'PostalAddress';
1932
+ $input1['itemReviewed']['address']['streetAddress'] = saswp_remove_warnings($all_post_meta, 'saswp_review_schema_street_address_'.$schema_id, 'saswp_array');
1933
+ $input1['itemReviewed']['address']['addressLocality'] = saswp_remove_warnings($all_post_meta, 'saswp_review_schema_locality_'.$schema_id, 'saswp_array');
1934
+ $input1['itemReviewed']['address']['addressRegion'] = saswp_remove_warnings($all_post_meta, 'saswp_review_schema_region_'.$schema_id, 'saswp_array');
1935
+ $input1['itemReviewed']['address']['postalCode'] = saswp_remove_warnings($all_post_meta, 'saswp_review_schema_postal_code_'.$schema_id, 'saswp_array');
1936
+ $input1['itemReviewed']['address']['addressCountry'] = saswp_remove_warnings($all_post_meta, 'saswp_review_schema_country_'.$schema_id, 'saswp_array');
1937
+
1938
+
1939
+ }
1940
+
1941
+
1942
+
1943
+
1944
+ switch ($all_post_meta['saswp_review_schema_item_type_'.$schema_id][0]) {
1945
+
1946
+ case 'Article':
1947
+
1948
+ $markup = $service->saswp_schema_markup_generator($all_post_meta['saswp_review_schema_item_type_'.$schema_id][0]);
1949
+ $input1['itemReviewed'] = $markup;
1950
+
1951
+ break;
1952
+ case 'Adultentertainment':
1953
+ $input1 = $input1;
1954
+ break;
1955
+ case 'Blog':
1956
+ $input1 = $input1;
1957
+ break;
1958
+ case 'Book':
1959
+
1960
+ if(isset($all_post_meta['saswp_review_schema_isbn_'.$schema_id])){
1961
+
1962
+ $input1['itemReviewed']['isbn'] = $all_post_meta['saswp_review_schema_isbn_'.$schema_id];
1963
+
1964
+ }
1965
+ if($review_author) {
1966
+
1967
+ $input1['itemReviewed']['author']['@type'] = 'Person';
1968
+ $input1['itemReviewed']['author']['name'] = $review_author;
1969
+ $input1['itemReviewed']['author']['sameAs'] = $all_post_meta['saswp_review_schema_author_sameas_'.$schema_id][0];
1970
+ }
1971
+
1972
+ break;
1973
+ case 'Casino':
1974
+ break;
1975
+ case 'Diet':
1976
+ break;
1977
+ case 'Episode':
1978
+ break;
1979
+ case 'ExercisePlan':
1980
+ break;
1981
+ case 'Game':
1982
+ break;
1983
+ case 'Movie':
1984
+
1985
+ if($review_author){
1986
+
1987
+ $input1['author']['sameAs'] = get_permalink();
1988
+
1989
+ }
1990
+
1991
+
1992
+ break;
1993
+ case 'MusicPlaylist':
1994
+ break;
1995
+ case 'MusicRecording':
1996
+ break;
1997
+ case 'Photograph':
1998
+ break;
1999
+ case 'Recipe':
2000
+ break;
2001
+ case 'Restaurant':
2002
+ break;
2003
+ case 'Series':
2004
+ break;
2005
+ case 'SoftwareApplication':
2006
+ break;
2007
+ case 'VisualArtwork':
2008
+ break;
2009
+ case 'WebPage':
2010
+
2011
+ $markup = $service->saswp_schema_markup_generator($all_post_meta['saswp_review_schema_item_type_'.$schema_id][0]);
2012
+ $input1['itemReviewed'] = $markup;
2013
+
2014
+ break;
2015
+ case 'WebSite':
2016
+ break;
2017
+
2018
+ default:
2019
+ $input1 = $input1;
2020
+ break;
2021
+ }
2022
+
2023
+
2024
+
2025
+
2026
+
2027
+
2028
+
2029
  if(saswp_remove_warnings($all_post_meta, 'saswp_review_schema_enable_rating_'.$schema_id, 'saswp_array') == 1){
2030
 
2031
  $input1['reviewRating'] = array(
2104
  $input1['menu'] = $all_post_meta['local_menu_'.$schema_id][0];
2105
  }
2106
  }
2107
+
2108
+ if( !empty($input1) && !isset($input1['image'])){
2109
+
2110
+ $service_object = new saswp_output_service();
2111
+ $input2 = $service_object->saswp_get_fetaure_image();
2112
+
2113
+ if(!empty($input2)){
2114
+
2115
+ $input1 = array_merge($input1,$input2);
2116
+
2117
+ }
2118
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2119
 
 
2120
  if(!empty($input1)){
2121
  $all_schema_output[] = $input1;
2122
  }
2126
  }
2127
 
2128
  function saswp_structure_data_access_scripts($data){
2129
+
2130
  if ( empty( $data['amp_component_scripts']['amp-access'] ) ) {
2131
  $data['amp_component_scripts']['amp-access'] = 'https://cdn.ampproject.org/v0/amp-access-0.1.js';
2132
  }
2137
  $data['amp_component_scripts']['amp-mustache'] = "https://cdn.ampproject.org/v0/amp-mustache-0.1.js";
2138
  }
2139
  return $data;
2140
+
2141
  }
2142
 
2143
  function saswp_list_items_generator(){
2144
+
2145
  global $sd_data;
2146
  $bc_titles = array();
2147
+ $bc_links = array();
2148
  if(isset($sd_data['titles'])){
2149
  $bc_titles = $sd_data['titles'];
2150
  }
2152
  $bc_links = $sd_data['links'];
2153
  }
2154
 
2155
+ $j = 1;
2156
  $i = 0;
2157
+ $breadcrumbslist = array();
2158
+
2159
  if(is_single()){
2160
 
2161
  if(isset($bc_titles)){
2206
  }
2207
 
2208
  function saswp_schema_breadcrumb_output($sd_data){
2209
+
2210
  global $sd_data;
2211
 
2212
  if(isset($sd_data['saswp_breadcrumb_schema']) && $sd_data['saswp_breadcrumb_schema'] == 1){
2228
  }
2229
 
2230
  function saswp_kb_website_output(){
2231
+
2232
+ global $sd_data;
2233
+ $site_url = get_site_url();
2234
  $site_name = get_bloginfo();
2235
+
2236
  $input = array(
2237
  '@context' =>'http://schema.org',
2238
  '@type' => 'WebSite',
2250
  }
2251
  // For Archive
2252
  function saswp_archive_output(){
2253
+
2254
+ global $query_string, $sd_data;
 
 
2255
  $site_name ='';
2256
+
 
 
 
 
2257
  if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
2258
  $site_name = $sd_data['sd_name'];
2259
  }else{
2260
  $site_name = get_bloginfo();
2261
+ }
2262
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2263
  if(isset($sd_data['saswp_archive_schema']) && $sd_data['saswp_archive_schema'] == 1){
2264
+
2265
+ $service_object = new saswp_output_service();
2266
+ $logo = $service_object->saswp_get_publisher(true);
2267
+
2268
 
2269
  if ( is_category() ) {
2270
  $category_posts = array();
2272
  if ( $category_loop->have_posts() ):
2273
  while( $category_loop->have_posts() ): $category_loop->the_post();
2274
  $image_id = get_post_thumbnail_id();
2275
+ $image_details = wp_get_attachment_image_src($image_id, 'full');
2276
  $publisher_info = array(
2277
  "type" => "Organization",
2278
  "name" => $site_name,
2279
  "logo" => array(
2280
+ "@type" => "ImageObject",
2281
+ "name" => $site_name,
2282
+ "width" => $logo['width'],
2283
+ "height" => $logo['height'],
2284
+ "url" => $logo['url']
2285
  )
2286
  );
2287
  $publisher_info['name'] = get_bloginfo('name');
2288
  $publisher_info['id'] = get_the_permalink();
2289
+
2290
+ $category_posts[] = array(
2291
+
2292
+ '@type' => 'BlogPosting',
2293
+ 'headline' => get_the_title(),
2294
+ 'url' => get_the_permalink(),
2295
+ 'datePublished' => get_the_date('c'),
2296
+ 'dateModified' => get_the_modified_date('c'),
2297
+ 'mainEntityOfPage' => get_the_permalink(),
2298
+ 'author' => get_the_author(),
2299
+ 'publisher' => $publisher_info,
2300
+ 'image' => $image_details[0],
2301
+ );
2302
 
2303
  endwhile;
2304
 
2377
  // For About Page
2378
  function saswp_about_page_output()
2379
  {
2380
+ global $sd_data;
2381
+ $feature_image = array();
2382
+ $publisher = array();
 
 
 
 
2383
 
2384
+ if((isset($sd_data['sd_about_page'])) && $sd_data['sd_about_page'] == get_the_ID()){
2385
+
2386
+ $service_object = new saswp_output_service();
2387
+ $feature_image = $service_object->saswp_get_fetaure_image();
2388
+ $publisher = $service_object->saswp_get_publisher();
2389
+
 
 
 
 
 
 
 
 
 
 
2390
  $input = array(
2391
+ "@context" => "http://schema.org",
2392
+ "@type" => "AboutPage",
2393
  "mainEntityOfPage" => array(
2394
+ "@type" => "WebPage",
2395
+ "@id" => get_permalink(),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2396
  ),
2397
+ "url" => get_permalink(),
2398
+ "headline" => get_the_title(),
2399
+ 'description' => strip_tags(get_the_excerpt()),
2400
  );
2401
+
2402
+ if(!empty($feature_image)){
2403
+
2404
+ $input = array_merge($input, $feature_image);
2405
+
2406
+ }
2407
+ if(!empty($publisher)){
2408
+
2409
+ $input = array_merge($input, $publisher);
2410
+
2411
+ }
2412
  return json_encode($input);
2413
  }
2414
 
2416
 
2417
  // For Contact Page
2418
  function saswp_contact_page_output()
2419
+ {
2420
+ global $sd_data;
2421
+ $feature_image = array();
2422
+ $publisher = array();
2423
+
 
 
 
2424
  if(isset($sd_data['sd_contact_page']) && $sd_data['sd_contact_page'] == get_the_ID()){
2425
+
2426
+ $service_object = new saswp_output_service();
2427
+ $feature_image = $service_object->saswp_get_fetaure_image();
2428
+ $publisher = $service_object->saswp_get_publisher();
2429
+
 
 
 
 
 
 
 
 
 
 
 
2430
  $input = array(
2431
+
2432
  "@context" => "http://schema.org",
2433
  "@type" => "ContactPage",
2434
  "mainEntityOfPage" => array(
2435
  "@type" => "WebPage",
2436
  "@id" => get_permalink(),
2437
  ),
2438
+ "url" => get_permalink(),
2439
+ "headline" => get_the_title(),
2440
+ 'description' => strip_tags(get_the_excerpt()),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2441
  );
2442
+
2443
+ if(!empty($feature_image)){
2444
+
2445
+ $input = array_merge($input, $feature_image);
2446
+
2447
+ }
2448
+
2449
+ if(!empty($publisher)){
2450
+
2451
+ $input = array_merge($input, $publisher);
2452
+
2453
+ }
2454
  return json_encode($input);
2455
 
2456
  }
2531
  $words_per_second = $words_per_minute / 60;
2532
 
2533
  // Count the words in the content.
2534
+ $word_count = 0;
2535
  $text = trim( strip_tags( get_the_content() ) );
2536
  $word_count = substr_count( "$text ", ' ' );
2537
 
output/review-output.php CHANGED
@@ -9,26 +9,33 @@ Class saswp_review_output{
9
  }
10
 
11
  public function saswp_review_display_via_shortcode($attr){
 
12
  $review_id = $attr['id'];
 
13
  if(isset($review_id)){
 
14
  $result = $this->saswp_get_review_box_content();
15
  return $result;
 
16
  }
17
 
18
  }
19
 
20
 
21
  public function saswp_get_review_box_content(){
22
- $saswp_review_details = array();
23
- $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
24
- $saswp_review_item_feature = array();
25
- $saswp_review_item_star_rating = array();
26
- $saswp_review_title = '';
 
27
  $saswp_review_description_title = '';
 
28
  $saswp_review_description = get_post_meta( get_the_ID(), 'saswp-review-item-description', true );
29
- $saswp_review_props = get_post_meta( get_the_ID(), 'saswp-review-item-props', true );
30
- $saswp_review_cons = get_post_meta( get_the_ID(), 'saswp-review-item-cons', true );
31
- $saswp_over_all_rating = '';
 
32
  if(isset($saswp_review_details['saswp-review-item-feature'])){
33
  $saswp_review_item_feature = $saswp_review_details['saswp-review-item-feature'];
34
  }
@@ -45,8 +52,11 @@ Class saswp_review_output{
45
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
46
  $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
47
  }
 
48
  $boxdata ='';
 
49
  if($saswp_review_props !='' || $saswp_review_cons != '' ){
 
50
  $boxdata .='
51
  <div class="saswp-pc-wrap">
52
  <div class="saswp-lst">
@@ -58,36 +68,50 @@ Class saswp_review_output{
58
  '.wpautop( stripslashes ( $saswp_review_cons ) ).'
59
  </div>
60
  </div>';
 
61
  }
62
 
63
  if(!empty($saswp_review_item_feature) || $saswp_review_description !=''){
 
64
  $boxdata.='<table class="saswp-rvw">
65
  <tbody>
66
  <div class="saswp-rvw-hd">
67
  <span>'.esc_html__('REVIEW OVERVIEW', 'schema-and-structured-data-for-wp').'</span>
68
- </div>';
 
69
  if(isset($saswp_review_item_feature)){
 
70
  for($i=0; $i<count($saswp_review_item_feature); $i++){
 
71
  $boxdata.='<tr>
72
  <td>'.esc_attr($saswp_review_item_feature[$i]).'</td>
73
  <td>
74
  <div class="saswp-rvw-str">';
75
- for($j=0; $j<5; $j++){
 
76
  if($saswp_review_item_star_rating[$i] >$j){
77
 
78
- $explod = explode('.', $saswp_review_item_star_rating[$i]);
79
- if(isset($explod[1])){
80
- if($j <$explod[0]){
81
- $boxdata.='<span class="str-ic"></span>';
82
- }else{
83
- $boxdata.='<span class="half-str"></span>';
84
- }
85
- }else{
86
- $boxdata.='<span class="str-ic"></span>';
87
- }
 
 
 
 
 
 
 
 
88
 
89
  } else{
90
- $boxdata.='<span class="df-clr"></span>';
91
  }
92
  }
93
 
@@ -108,30 +132,32 @@ Class saswp_review_output{
108
  <div class="saswp-rvw-fs">'.esc_attr(number_format($saswp_over_all_rating, 2, '.', '')).'</div>';
109
 
110
  if($saswp_over_all_rating !=''){
 
111
  $boxdata.='<div class="tvw-fnl-str saswp-rvw-str">';
112
- $explod = explode('.', $saswp_over_all_rating);
 
113
  for($x=0;$x<5;$x++) {
114
 
115
- if(isset($explod[1])){
116
-
117
- if($saswp_over_all_rating >$x){
118
-
119
- if($x <$explod[0]){
120
- $boxdata.='<span class="str-ic"></span>';
121
- }else{
122
- $boxdata.='<span class="half-str"></span>';
123
- }
124
-
125
- }else{
126
- $boxdata.='<span class="df-clr"></span>';
127
- }
128
- }else{
129
- if($saswp_over_all_rating >$x){
130
- $boxdata.='<span class="str-ic"></span>';
131
- } else{
132
- $boxdata.='<span class="df-clr"></span>';
133
- }
134
- }
135
  }
136
  $boxdata.='</div><span class="ovs">'.esc_html__('OVERALL SCORE', 'schema-and-structured-data-for-wp').'</span>';
137
  }
@@ -146,13 +172,16 @@ Class saswp_review_output{
146
 
147
  }
148
  public function saswp_display_review_box($content){
 
149
  global $sd_data;
150
- $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
151
  $saswp_review_item_enable = 0;
 
152
  if(isset($saswp_review_details['saswp-review-item-enable'])){
153
  $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
154
  }
155
  $review_module = 0;
 
156
  if(isset($sd_data['saswp-review-module'])){
157
  $review_module = $sd_data['saswp-review-module'];
158
  }
@@ -162,6 +191,7 @@ Class saswp_review_output{
162
  $result = $this->saswp_get_review_box_content();
163
 
164
  if(isset($saswp_review_details['saswp-review-location'])){
 
165
  switch ($saswp_review_details['saswp-review-location']) {
166
  case 1:
167
  $content = $content.$result;
@@ -175,7 +205,8 @@ Class saswp_review_output{
175
 
176
  default:
177
  break;
178
- }
 
179
  }
180
 
181
  return $content;
9
  }
10
 
11
  public function saswp_review_display_via_shortcode($attr){
12
+
13
  $review_id = $attr['id'];
14
+
15
  if(isset($review_id)){
16
+
17
  $result = $this->saswp_get_review_box_content();
18
  return $result;
19
+
20
  }
21
 
22
  }
23
 
24
 
25
  public function saswp_get_review_box_content(){
26
+
27
+ $saswp_review_details = array();
28
+ $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
29
+ $saswp_review_item_feature = array();
30
+ $saswp_review_item_star_rating = array();
31
+ $saswp_review_title = '';
32
  $saswp_review_description_title = '';
33
+
34
  $saswp_review_description = get_post_meta( get_the_ID(), 'saswp-review-item-description', true );
35
+ $saswp_review_props = get_post_meta( get_the_ID(), 'saswp-review-item-props', true );
36
+ $saswp_review_cons = get_post_meta( get_the_ID(), 'saswp-review-item-cons', true );
37
+ $saswp_over_all_rating = '';
38
+
39
  if(isset($saswp_review_details['saswp-review-item-feature'])){
40
  $saswp_review_item_feature = $saswp_review_details['saswp-review-item-feature'];
41
  }
52
  if(isset($saswp_review_details['saswp-review-item-over-all'])){
53
  $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
54
  }
55
+
56
  $boxdata ='';
57
+
58
  if($saswp_review_props !='' || $saswp_review_cons != '' ){
59
+
60
  $boxdata .='
61
  <div class="saswp-pc-wrap">
62
  <div class="saswp-lst">
68
  '.wpautop( stripslashes ( $saswp_review_cons ) ).'
69
  </div>
70
  </div>';
71
+
72
  }
73
 
74
  if(!empty($saswp_review_item_feature) || $saswp_review_description !=''){
75
+
76
  $boxdata.='<table class="saswp-rvw">
77
  <tbody>
78
  <div class="saswp-rvw-hd">
79
  <span>'.esc_html__('REVIEW OVERVIEW', 'schema-and-structured-data-for-wp').'</span>
80
+ </div>';
81
+
82
  if(isset($saswp_review_item_feature)){
83
+
84
  for($i=0; $i<count($saswp_review_item_feature); $i++){
85
+
86
  $boxdata.='<tr>
87
  <td>'.esc_attr($saswp_review_item_feature[$i]).'</td>
88
  <td>
89
  <div class="saswp-rvw-str">';
90
+ for($j=0; $j<5; $j++){
91
+
92
  if($saswp_review_item_star_rating[$i] >$j){
93
 
94
+ $explod = explode('.', $saswp_review_item_star_rating[$i]);
95
+
96
+ if(isset($explod[1])){
97
+
98
+ if($j <$explod[0]){
99
+
100
+ $boxdata.='<span class="str-ic"></span>';
101
+
102
+ }else{
103
+
104
+ $boxdata.='<span class="half-str"></span>';
105
+
106
+ }
107
+ }else{
108
+
109
+ $boxdata.='<span class="str-ic"></span>';
110
+
111
+ }
112
 
113
  } else{
114
+ $boxdata.='<span class="df-clr"></span>';
115
  }
116
  }
117
 
132
  <div class="saswp-rvw-fs">'.esc_attr(number_format($saswp_over_all_rating, 2, '.', '')).'</div>';
133
 
134
  if($saswp_over_all_rating !=''){
135
+
136
  $boxdata.='<div class="tvw-fnl-str saswp-rvw-str">';
137
+ $explod = explode('.', $saswp_over_all_rating);
138
+
139
  for($x=0;$x<5;$x++) {
140
 
141
+ if(isset($explod[1])){
142
+
143
+ if($saswp_over_all_rating >$x){
144
+
145
+ if($x <$explod[0]){
146
+ $boxdata.='<span class="str-ic"></span>';
147
+ }else{
148
+ $boxdata.='<span class="half-str"></span>';
149
+ }
150
+
151
+ }else{
152
+ $boxdata.='<span class="df-clr"></span>';
153
+ }
154
+ }else{
155
+ if($saswp_over_all_rating >$x){
156
+ $boxdata.='<span class="str-ic"></span>';
157
+ } else{
158
+ $boxdata.='<span class="df-clr"></span>';
159
+ }
160
+ }
161
  }
162
  $boxdata.='</div><span class="ovs">'.esc_html__('OVERALL SCORE', 'schema-and-structured-data-for-wp').'</span>';
163
  }
172
 
173
  }
174
  public function saswp_display_review_box($content){
175
+
176
  global $sd_data;
177
+ $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
178
  $saswp_review_item_enable = 0;
179
+
180
  if(isset($saswp_review_details['saswp-review-item-enable'])){
181
  $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
182
  }
183
  $review_module = 0;
184
+
185
  if(isset($sd_data['saswp-review-module'])){
186
  $review_module = $sd_data['saswp-review-module'];
187
  }
191
  $result = $this->saswp_get_review_box_content();
192
 
193
  if(isset($saswp_review_details['saswp-review-location'])){
194
+
195
  switch ($saswp_review_details['saswp-review-location']) {
196
  case 1:
197
  $content = $content.$result;
205
 
206
  default:
207
  break;
208
+ }
209
+
210
  }
211
 
212
  return $content;
output/service.php CHANGED
@@ -4,24 +4,28 @@ Class saswp_output_service{
4
 
5
  }
6
  public function saswp_service_hooks(){
 
7
  add_action( 'wp_ajax_saswp_get_custom_meta_fields', array($this, 'saswp_get_custom_meta_fields'));
8
  add_action( 'wp_ajax_saswp_get_schema_type_fields', array($this, 'saswp_get_schema_type_fields'));
 
9
  }
10
-
11
-
12
  public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
13
 
14
  $custom_fields = esc_sql ( get_post_meta($schema_post_id, 'saswp_custom_fields', true) );
15
 
16
  if(!empty($custom_fields)){
 
17
  $schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
18
 
19
  foreach ($custom_fields as $key => $field){
20
 
21
  $custom_fields[$key] = get_post_meta($schema_post_id, $field, true);
22
 
23
- }
 
24
  switch ($schema_type) {
 
25
  case 'local_business':
26
 
27
  if(isset($custom_fields['saswp_business_type'])){
@@ -641,59 +645,106 @@ Class saswp_output_service{
641
  wp_die();
642
  }
643
  public function saswp_woocommerce_product_details($post_id){
644
-
645
-
646
  $product_details = array();
 
647
  if (class_exists('WC_Product')) {
648
- $product = wc_get_product($post_id);
 
 
649
  if(is_object($product)){
 
650
  $gtin = get_post_meta($post_id, $key='hwp_product_gtin', true);
 
651
  if($gtin !=''){
 
652
  $product_details['product_gtin8'] = $gtin;
653
- }
 
 
654
  $brand = get_post_meta($post_id, $key='hwp_product_brand', true);
 
655
  if($brand !=''){
 
656
  $product_details['product_brand'] = $brand;
 
657
  }
658
- $date_on_sale = $product->get_date_on_sale_to();
659
- $product_details['product_name'] = $product->get_title();
 
 
 
 
 
 
 
 
 
660
  $product_details['product_description'] = $product->get_description();
661
- $product_details['product_image'] = $product->get_image();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  $product_details['product_availability'] = $product->get_stock_status();
663
- $product_details['product_price'] = $product->get_price();
664
- $product_details['product_sku'] = $product->get_sku();
 
665
  if(isset($date_on_sale)){
 
666
  $product_details['product_priceValidUntil'] = $date_on_sale->date('Y-m-d G:i:s');
667
- }
 
 
668
  $product_details['product_currency'] = get_option( 'woocommerce_currency' );
669
 
670
  $reviews_arr = array();
671
- $reviews = get_approved_comments( $post_id );
 
672
  if($reviews){
 
673
  foreach($reviews as $review){
 
674
  $reviews_arr[] = array(
675
- 'author' => $review->comment_author,
676
  'datePublished' => $review->comment_date,
677
- 'description' => $review->comment_content,
678
- 'reviewRating' => get_comment_meta( $review->comment_ID, 'rating', true ),
679
  );
 
 
 
680
  }
681
- }
682
  $product_details['product_review_count'] = $product->get_review_count();
683
  $product_details['product_average_rating'] = $product->get_average_rating();
684
  $product_details['product_reviews'] = $reviews_arr;
 
685
  }
 
686
  }
687
  return $product_details;
688
  }
689
 
690
  public function saswp_extra_theme_review_details($post_id){
 
691
  global $sd_data;
692
 
693
- $review_data = array();
694
- $rating_value =0;
695
- $post_review_title ='';
696
- $post_review_desc ='';
697
 
698
  $post_meta = esc_sql ( get_post_meta($post_id, $key='', true) );
699
 
@@ -733,227 +784,234 @@ Class saswp_output_service{
733
  }
734
 
735
  public function saswp_dw_question_answers_details($post_id){
 
736
  global $sd_data;
737
- $dw_qa = array();
738
  $qa_page = array();
739
 
740
  $post_type = get_post_type($post_id);
 
741
  if($post_type =='dwqa-question' && isset($sd_data['saswp-dw-question-answer']) && $sd_data['saswp-dw-question-answer'] ==1 ){
742
 
743
- $post_meta = get_post_meta($post_id, $key='', true);
744
  $best_answer_id = $post_meta['_dwqa_best_answer'][0];
745
 
746
- $userid = get_post_field( 'post_author', $post_id );
747
- $userinfo = get_userdata($userid);
748
 
749
- $dw_qa['@type'] = 'Question';
750
- $dw_qa['name'] = get_the_title();
751
  $dw_qa['upvoteCount'] = get_post_meta( $post_id, '_dwqa_votes', true );
 
752
  $args = array(
753
  'p' => $post_id, // ID of a page, post, or custom type
754
  'post_type' => 'dwqa-question'
755
  );
756
 
757
  $my_posts = new WP_Query($args);
 
758
  if ( $my_posts->have_posts() ) {
 
759
  while ( $my_posts->have_posts() ) : $my_posts->the_post();
760
  $dw_qa['text'] = get_the_content();
761
  endwhile;
 
762
  }
 
763
  $dw_qa['dateCreated'] = get_the_date("Y-m-d\TH:i:s\Z");
764
- $dw_qa['author'] = array('@type' => 'Person','name' =>$userinfo->data->user_nicename);
765
  $dw_qa['answerCount'] = $post_meta['_dwqa_answers_count'][0];
766
 
767
  $args = array(
768
- 'post_type' => 'dwqa-answer',
769
- 'post_parent' => $post_id,
770
  'post_per_page' => '-1',
771
- 'post_status' => array('publish')
772
  );
773
 
774
  $answer_array = get_posts($args);
775
 
776
- $accepted_answer = array();
777
  $suggested_answer = array();
 
778
  foreach($answer_array as $answer){
779
- $authorinfo = get_userdata($answer->post_author);
 
 
780
  if($answer->ID == $best_answer_id){
781
- $accepted_answer['@type'] = 'Answer';
 
782
  $accepted_answer['upvoteCount'] = get_post_meta( $answer->ID, '_dwqa_votes', true );
783
- $accepted_answer['url'] = get_permalink($answer->ID);
784
- $accepted_answer['text'] = $answer->post_content;
785
  $accepted_answer['dateCreated'] = get_the_date("Y-m-d\TH:i:s\Z", $answer);
786
- $accepted_answer['author'] = array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename);
 
787
  }else{
 
788
  $suggested_answer[] = array(
789
- '@type' => 'Answer',
790
  'upvoteCount' => get_post_meta( $answer->ID, '_dwqa_votes', true ),
791
- 'url' => get_permalink($answer->ID),
792
- 'text' => $answer->post_content,
793
  'dateCreated' => get_the_date("Y-m-d\TH:i:s\Z", $answer),
794
- 'author' => array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename),
795
  );
 
796
  }
797
  }
798
- $dw_qa['acceptedAnswer'] = $accepted_answer;
 
799
  $dw_qa['suggestedAnswer'] = $suggested_answer;
800
 
801
- $qa_page['@context'] = 'http://schema.org';
802
- $qa_page['@type'] = 'QAPage';
803
  $qa_page['mainEntity'] = $dw_qa;
804
 
805
- }
 
806
  return $qa_page;
807
  }
808
 
809
  public function saswp_get_all_schema_type_fields($schema_type, $id =null){
 
810
  $meta_field = array();
 
811
  if($schema_type ==''){
 
812
  $schema_type = get_post_meta( $id, 'schema_type', true);
813
- }
 
 
814
  switch ($schema_type) {
815
 
816
  case 'local_business':
817
 
818
  $meta_field = array(
819
- 'saswp_business_type' => 'Business Type',
820
- 'saswp_business_name' => 'Sub Business Type',
821
- 'local_business_name' => 'Business Name',
822
- 'local_business_name_url' => 'URL',
823
  'local_business_description' => 'Description',
824
- 'local_street_address' => 'Street Address',
825
- 'local_city' => 'City',
826
- 'local_state' => 'State',
827
- 'local_postal_code' => 'Postal Code',
828
- 'local_phone' => 'Phone',
829
- 'local_website' => 'Website',
830
- 'local_business_logo' => 'Image',
831
- 'saswp_dayofweek' => 'Operation Days',
832
- 'local_price_range' => 'Price Range',
833
  );
834
  break;
835
 
836
  case 'Blogposting':
837
- $meta_field = array(
838
- 'saswp_blogposting_main_entity_of_page' => 'Main Entity Of Page',
839
- 'saswp_blogposting_headline' => 'Headline',
840
- 'saswp_blogposting_description' => 'Description',
841
-
842
- 'saswp_blogposting_name' => 'Name',
843
- 'saswp_blogposting_url' => 'URL',
844
- 'saswp_blogposting_date_published' => 'Date Published',
845
 
846
- 'saswp_blogposting_date_modified' => 'Date Modified',
847
- 'saswp_blogposting_author_name' => 'Author Name',
848
- 'saswp_blogposting_organization_name' => 'Organization Name',
849
- 'saswp_blogposting_organization_logo' => 'Organization Logo',
 
 
 
 
 
 
850
 
851
  );
852
 
853
  break;
854
 
855
  case 'NewsArticle':
 
856
  $meta_field = array(
857
  'saswp_newsarticle_main_entity_of_page' => 'Main Entity Of Page',
858
- 'saswp_newsarticle_URL' => 'URL',
859
- 'saswp_newsarticle_headline' => 'Headline',
860
-
861
- 'saswp_newsarticle_date_published' => 'Date Published',
862
- 'saswp_newsarticle_date_modified' => 'Date Modified',
863
- 'saswp_newsarticle_headline' => 'Headline',
864
-
865
- 'saswp_newsarticle_description' => 'Description',
866
- 'saswp_newsarticle_section' => 'Article Section',
867
- 'saswp_newsarticle_body' => 'Article Body',
868
-
869
- 'saswp_newsarticle_name' => 'Name',
870
- 'saswp_newsarticle_thumbnailurl' => 'Thumbnail URL',
871
- 'saswp_newsarticle_timerequired' => 'Time Required',
872
-
873
- 'saswp_newsarticle_main_entity_id' => 'Main Entity Id',
874
- 'saswp_newsarticle_author_name' => 'Author Name',
875
- 'saswp_newsarticle_author_image' => 'Author Image',
876
-
877
- 'saswp_newsarticle_organization_name' => 'Organization Name',
878
- 'saswp_newsarticle_organization_logo' => 'Organization Logo',
879
  );
880
 
881
  break;
882
 
883
  case 'WebPage':
 
884
  $meta_field = array(
885
- 'saswp_webpage_name' => 'Name',
886
- 'saswp_webpage_url' => 'URL',
887
- 'saswp_webpage_description' => 'Description',
888
-
889
  'saswp_webpage_main_entity_of_page' => 'Main Entity Of Page',
890
- 'saswp_webpage_image' => 'Image',
891
- 'saswp_webpage_headline' => 'Headline',
892
-
893
- 'saswp_webpage_date_published' => 'Date Published',
894
- 'saswp_webpage_date_modified' => 'Date Modified',
895
- 'saswp_webpage_author_name' => 'Author Name',
896
-
897
- 'saswp_webpage_organization_name' => 'Organization Name',
898
- 'saswp_webpage_organization_logo' => 'Organization Logo',
899
  );
900
 
901
  break;
902
 
903
  case 'Article':
 
904
  $meta_field = array(
905
  'saswp_article_main_entity_of_page' => 'Main Entity Of Page',
906
- 'saswp_article_image' => 'Image',
907
- 'saswp_article_headline' => 'Headline',
908
-
909
- 'saswp_article_description' => 'Description',
910
- 'saswp_article_date_published' => 'Date Published',
911
- 'saswp_article_date_modified' => 'Date Modified',
912
-
913
- 'saswp_article_author_name' => 'Author Name',
914
- 'saswp_article_organization_name' => 'Organization Name',
915
- 'saswp_article_organization_logo' => 'Organization Logo',
916
 
917
  );
918
  break;
919
 
920
  case 'Recipe':
 
921
  $meta_field = array(
922
- 'saswp_recipe_url' => 'URL',
923
- 'saswp_recipe_name' => 'Name',
924
- 'saswp_recipe_date_published' => 'Date Published',
925
-
926
- 'saswp_recipe_date_modified' => 'Date Modified',
927
- 'saswp_recipe_description' => 'Description',
928
- 'saswp_recipe_main_entity' => 'Main Entity Id',
929
-
930
- 'saswp_recipe_author_name' => 'Author Name',
931
- 'saswp_recipe_author_image' => 'Author Image',
932
- 'saswp_recipe_organization_name' => 'Organization Name',
933
-
934
- 'saswp_recipe_organization_logo' => 'Organization Logo',
935
- 'saswp_recipe_preptime' => 'Prepare Time',
936
- 'saswp_recipe_cooktime' => 'Cook Time',
937
-
938
- 'saswp_recipe_totaltime' => 'Total Time',
939
- 'saswp_recipe_keywords' => 'Keywords',
940
- 'saswp_recipe_recipeyield' => 'Recipe Yield',
941
-
942
- 'saswp_recipe_category' => 'Recipe Category',
943
- 'saswp_recipe_cuisine' => 'Recipe Cuisine',
944
- 'saswp_recipe_nutrition' => 'Nutrition',
945
-
946
- 'saswp_recipe_ingredient' => 'Recipe Ingredient',
947
- 'saswp_recipe_instructions' => 'Recipe Instructions',
948
- 'saswp_recipe_video_name' => 'Video Name',
949
-
950
- 'saswp_recipe_video_description' => 'Video Description',
951
- 'saswp_recipe_video_thumbnailurl' => 'Video ThumbnailUrl',
952
- 'saswp_recipe_video_contenturl' => 'Video ContentUrl',
953
-
954
- 'saswp_recipe_video_embedurl' => 'Video EmbedUrl',
955
- 'saswp_recipe_video_upload_date' => 'Video Upload Date',
956
- 'saswp_recipe_video_duration' => 'Video Duration',
957
  );
958
 
959
  break;
@@ -961,41 +1019,43 @@ Class saswp_output_service{
961
  case 'Product':
962
 
963
  $meta_field = array(
964
- 'saswp_product_url' => 'URL',
965
- 'saswp_product_name' => 'Name',
966
  'saswp_product_description' => 'Description',
967
- );
968
- if(is_plugin_active('woocommerce/woocommerce.php')){
969
- $meta_field['saswp_product_image'] = 'Image';
970
- $meta_field['saswp_product_availability'] = 'Availability';
971
- $meta_field['saswp_product_price'] = 'Price';
972
- $meta_field['saswp_product_currency'] = 'Price Currency';
973
-
974
- $meta_field['saswp_product_brand'] = 'Brand';
 
975
  $meta_field['saswp_product_priceValidUntil'] = 'Price Valid Until';
976
- $meta_field['saswp_product_isbn'] = 'ISBN';
977
- $meta_field['saswp_product_mpn'] = 'MPN';
978
- $meta_field['saswp_product_gtin8'] = 'GTIN 8';
979
- }
 
980
  break;
981
 
982
  case 'Service':
983
 
984
  $meta_field = array(
985
- 'saswp_service_schema_name' => 'Name',
986
- 'saswp_service_schema_type' => 'Service Type',
987
- 'saswp_service_schema_provider_name' => 'Provider Name',
988
- 'saswp_service_schema_provider_type' => 'Provider Type',
989
- 'saswp_service_schema_image' => 'Image',
990
- 'saswp_service_schema_locality' => 'Locality',
991
- 'saswp_service_schema_postal_code' => 'Postal Code',
992
- 'saswp_service_schema_telephone' => 'Telephone',
993
- 'saswp_service_schema_price_range' => 'Price Range',
994
- 'saswp_service_schema_description' => 'Description',
995
- 'saswp_service_schema_area_served' => 'Area Served (City)',
996
- 'saswp_service_schema_service_offer' => 'Service Offer',
997
- 'saswp_review_schema_country' => 'Address Country',
998
- 'saswp_review_schema_telephone' => 'Telephone',
999
  );
1000
 
1001
  break;
@@ -1003,19 +1063,19 @@ Class saswp_output_service{
1003
  case 'Review':
1004
  $meta_field = array(
1005
 
1006
- 'saswp_review_schema_item_type' => 'Item Reviewed Type',
1007
- 'saswp_review_schema_name' => 'Name',
1008
- 'saswp_review_schema_description' => 'Description',
1009
- 'saswp_review_schema_date_published' => 'Date Published',
1010
- 'saswp_review_schema_date_modified' => 'Date Modified',
1011
- 'saswp_review_schema_image' => 'Image',
1012
- 'saswp_review_schema_price_range' => 'Price Range',
1013
- 'saswp_review_schema_street_address' => 'Street Address',
1014
- 'saswp_review_schema_locality' => 'Address Locality',
1015
- 'saswp_review_schema_region' => 'Address Region',
1016
- 'saswp_review_schema_postal_code' => 'Postal Code',
1017
- 'saswp_review_schema_country' => 'Address Country',
1018
- 'saswp_review_schema_telephone' => 'Telephone',
1019
  );
1020
  break;
1021
 
@@ -1023,19 +1083,19 @@ Class saswp_output_service{
1023
 
1024
  $meta_field = array(
1025
 
1026
- 'saswp_video_object_url' => 'URL',
1027
- 'saswp_video_object_headline' => 'Headline',
1028
- 'saswp_video_object_date_published' => 'Date Published',
1029
- 'saswp_video_object_date_modified' => 'Date Modified',
1030
- 'saswp_video_object_description' => 'Description',
1031
- 'saswp_video_object_name' => 'Name',
1032
- 'saswp_video_object_upload_date' => 'Upload Date',
1033
- 'saswp_video_object_thumbnail_url' => 'Thumbnail Url',
1034
- 'saswp_video_object_main_entity_id' => 'Main Entity Id',
1035
- 'saswp_video_object_author_name' => 'Author Name',
1036
- 'saswp_video_object_author_image' => 'Author Image',
1037
- 'saswp_video_object_organization_name' => 'Organization Name',
1038
- 'saswp_video_object_organization_logo' => 'Organization Logo',
1039
  );
1040
 
1041
  break;
@@ -1044,14 +1104,14 @@ Class saswp_output_service{
1044
 
1045
  $meta_field = array(
1046
 
1047
- 'saswp_audio_schema_name' => 'Name',
1048
- 'saswp_audio_schema_description' => 'Description',
1049
- 'saswp_audio_schema_contenturl' => 'Content Url',
1050
- 'saswp_audio_schema_duration' => 'Duration',
1051
- 'saswp_audio_schema_encoding_format' => 'Encoding Format',
1052
  'saswp_audio_schema_date_published' => 'Date Published',
1053
- 'saswp_audio_schema_date_modified' => 'Date Modified',
1054
- 'saswp_audio_schema_author_name' => 'Author',
1055
  );
1056
 
1057
  break;
@@ -1059,21 +1119,21 @@ Class saswp_output_service{
1059
  case 'qanda':
1060
  $meta_field = array(
1061
 
1062
- 'saswp_qa_question_title' => 'Question Title',
1063
- 'saswp_qa_question_description' => 'Question Description',
1064
- 'saswp_qa_upvote_count' => 'Question Upvote Count',
1065
- 'saswp_qa_date_created' => 'Question Date Created',
1066
- 'saswp_qa_question_author_name' => 'Author Name',
1067
- 'saswp_qa_accepted_answer_text' => 'Accepted Answer Text',
1068
  'saswp_qa_accepted_answer_date_created' => 'Accepted Answer Date Created',
1069
  'saswp_qa_accepted_answer_upvote_count' => 'Accepted Answer Upvote Count',
1070
- 'saswp_qa_accepted_answer_url' => 'Accepted Answer Url',
1071
- 'saswp_qa_accepted_author_name' => 'Accepted Answer Author Name',
1072
- 'saswp_qa_suggested_answer_text' => 'Suggested Answer Text',
1073
- 'saswp_qa_suggested_answer_date_created' => 'Suggested Answer Date Created',
1074
- 'saswp_qa_suggested_answer_upvote_count' => 'Suggested Answer Upvote Count',
1075
- 'saswp_qa_suggested_answer_url' => 'Suggested Answer Url',
1076
- 'saswp_qa_suggested_author_name' => 'Suggested Answer Author Name',
1077
 
1078
  );
1079
  break;
@@ -1084,6 +1144,232 @@ Class saswp_output_service{
1084
  return $meta_field;
1085
  }
1086
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1087
  }
1088
  if (class_exists('saswp_output_service')) {
1089
  $object = new saswp_output_service();
4
 
5
  }
6
  public function saswp_service_hooks(){
7
+
8
  add_action( 'wp_ajax_saswp_get_custom_meta_fields', array($this, 'saswp_get_custom_meta_fields'));
9
  add_action( 'wp_ajax_saswp_get_schema_type_fields', array($this, 'saswp_get_schema_type_fields'));
10
+
11
  }
12
+
 
13
  public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
14
 
15
  $custom_fields = esc_sql ( get_post_meta($schema_post_id, 'saswp_custom_fields', true) );
16
 
17
  if(!empty($custom_fields)){
18
+
19
  $schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
20
 
21
  foreach ($custom_fields as $key => $field){
22
 
23
  $custom_fields[$key] = get_post_meta($schema_post_id, $field, true);
24
 
25
+ }
26
+
27
  switch ($schema_type) {
28
+
29
  case 'local_business':
30
 
31
  if(isset($custom_fields['saswp_business_type'])){
645
  wp_die();
646
  }
647
  public function saswp_woocommerce_product_details($post_id){
648
+
 
649
  $product_details = array();
650
+
651
  if (class_exists('WC_Product')) {
652
+
653
+ $product = wc_get_product($post_id);
654
+
655
  if(is_object($product)){
656
+
657
  $gtin = get_post_meta($post_id, $key='hwp_product_gtin', true);
658
+
659
  if($gtin !=''){
660
+
661
  $product_details['product_gtin8'] = $gtin;
662
+
663
+ }
664
+
665
  $brand = get_post_meta($post_id, $key='hwp_product_brand', true);
666
+
667
  if($brand !=''){
668
+
669
  $product_details['product_brand'] = $brand;
670
+
671
  }
672
+
673
+ $product_image_id = $product->get_image_id();
674
+
675
+ if($product_image_id){
676
+
677
+ $image_details = wp_get_attachment_image_src($product_image_id, 'full');
678
+
679
+ }
680
+
681
+ $date_on_sale = $product->get_date_on_sale_to();
682
+ $product_details['product_name'] = $product->get_title();
683
  $product_details['product_description'] = $product->get_description();
684
+
685
+ if(!empty($image_details)){
686
+
687
+ $product_details['product_image'] = array(
688
+ '@type' => 'ImageObject',
689
+ 'url' => $image_details[0],
690
+ 'width' => $image_details[1],
691
+ 'height' => $image_details[2]
692
+ );
693
+
694
+ }else{
695
+
696
+ $product_details['product_image'] = '';
697
+
698
+ }
699
+
700
  $product_details['product_availability'] = $product->get_stock_status();
701
+ $product_details['product_price'] = $product->get_price();
702
+ $product_details['product_sku'] = $product->get_sku();
703
+
704
  if(isset($date_on_sale)){
705
+
706
  $product_details['product_priceValidUntil'] = $date_on_sale->date('Y-m-d G:i:s');
707
+
708
+ }
709
+
710
  $product_details['product_currency'] = get_option( 'woocommerce_currency' );
711
 
712
  $reviews_arr = array();
713
+ $reviews = get_approved_comments( $post_id );
714
+
715
  if($reviews){
716
+
717
  foreach($reviews as $review){
718
+
719
  $reviews_arr[] = array(
720
+ 'author' => $review->comment_author,
721
  'datePublished' => $review->comment_date,
722
+ 'description' => $review->comment_content,
723
+ 'reviewRating' => get_comment_meta( $review->comment_ID, 'rating', true ),
724
  );
725
+
726
+ }
727
+
728
  }
729
+
730
  $product_details['product_review_count'] = $product->get_review_count();
731
  $product_details['product_average_rating'] = $product->get_average_rating();
732
  $product_details['product_reviews'] = $reviews_arr;
733
+
734
  }
735
+
736
  }
737
  return $product_details;
738
  }
739
 
740
  public function saswp_extra_theme_review_details($post_id){
741
+
742
  global $sd_data;
743
 
744
+ $review_data = array();
745
+ $rating_value = 0;
746
+ $post_review_title = '';
747
+ $post_review_desc = '';
748
 
749
  $post_meta = esc_sql ( get_post_meta($post_id, $key='', true) );
750
 
784
  }
785
 
786
  public function saswp_dw_question_answers_details($post_id){
787
+
788
  global $sd_data;
789
+ $dw_qa = array();
790
  $qa_page = array();
791
 
792
  $post_type = get_post_type($post_id);
793
+
794
  if($post_type =='dwqa-question' && isset($sd_data['saswp-dw-question-answer']) && $sd_data['saswp-dw-question-answer'] ==1 ){
795
 
796
+ $post_meta = get_post_meta($post_id, $key='', true);
797
  $best_answer_id = $post_meta['_dwqa_best_answer'][0];
798
 
799
+ $userid = get_post_field( 'post_author', $post_id );
800
+ $userinfo = get_userdata($userid);
801
 
802
+ $dw_qa['@type'] = 'Question';
803
+ $dw_qa['name'] = get_the_title();
804
  $dw_qa['upvoteCount'] = get_post_meta( $post_id, '_dwqa_votes', true );
805
+
806
  $args = array(
807
  'p' => $post_id, // ID of a page, post, or custom type
808
  'post_type' => 'dwqa-question'
809
  );
810
 
811
  $my_posts = new WP_Query($args);
812
+
813
  if ( $my_posts->have_posts() ) {
814
+
815
  while ( $my_posts->have_posts() ) : $my_posts->the_post();
816
  $dw_qa['text'] = get_the_content();
817
  endwhile;
818
+
819
  }
820
+
821
  $dw_qa['dateCreated'] = get_the_date("Y-m-d\TH:i:s\Z");
822
+ $dw_qa['author'] = array('@type' => 'Person','name' =>$userinfo->data->user_nicename);
823
  $dw_qa['answerCount'] = $post_meta['_dwqa_answers_count'][0];
824
 
825
  $args = array(
826
+ 'post_type' => 'dwqa-answer',
827
+ 'post_parent' => $post_id,
828
  'post_per_page' => '-1',
829
+ 'post_status' => array('publish')
830
  );
831
 
832
  $answer_array = get_posts($args);
833
 
834
+ $accepted_answer = array();
835
  $suggested_answer = array();
836
+
837
  foreach($answer_array as $answer){
838
+
839
+ $authorinfo = get_userdata($answer->post_author);
840
+
841
  if($answer->ID == $best_answer_id){
842
+
843
+ $accepted_answer['@type'] = 'Answer';
844
  $accepted_answer['upvoteCount'] = get_post_meta( $answer->ID, '_dwqa_votes', true );
845
+ $accepted_answer['url'] = get_permalink($answer->ID);
846
+ $accepted_answer['text'] = $answer->post_content;
847
  $accepted_answer['dateCreated'] = get_the_date("Y-m-d\TH:i:s\Z", $answer);
848
+ $accepted_answer['author'] = array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename);
849
+
850
  }else{
851
+
852
  $suggested_answer[] = array(
853
+ '@type' => 'Answer',
854
  'upvoteCount' => get_post_meta( $answer->ID, '_dwqa_votes', true ),
855
+ 'url' => get_permalink($answer->ID),
856
+ 'text' => $answer->post_content,
857
  'dateCreated' => get_the_date("Y-m-d\TH:i:s\Z", $answer),
858
+ 'author' => array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename),
859
  );
860
+
861
  }
862
  }
863
+
864
+ $dw_qa['acceptedAnswer'] = $accepted_answer;
865
  $dw_qa['suggestedAnswer'] = $suggested_answer;
866
 
867
+ $qa_page['@context'] = 'http://schema.org';
868
+ $qa_page['@type'] = 'QAPage';
869
  $qa_page['mainEntity'] = $dw_qa;
870
 
871
+ }
872
+
873
  return $qa_page;
874
  }
875
 
876
  public function saswp_get_all_schema_type_fields($schema_type, $id =null){
877
+
878
  $meta_field = array();
879
+
880
  if($schema_type ==''){
881
+
882
  $schema_type = get_post_meta( $id, 'schema_type', true);
883
+
884
+ }
885
+
886
  switch ($schema_type) {
887
 
888
  case 'local_business':
889
 
890
  $meta_field = array(
891
+ 'saswp_business_type' => 'Business Type',
892
+ 'saswp_business_name' => 'Sub Business Type',
893
+ 'local_business_name' => 'Business Name',
894
+ 'local_business_name_url' => 'URL',
895
  'local_business_description' => 'Description',
896
+ 'local_street_address' => 'Street Address',
897
+ 'local_city' => 'City',
898
+ 'local_state' => 'State',
899
+ 'local_postal_code' => 'Postal Code',
900
+ 'local_phone' => 'Phone',
901
+ 'local_website' => 'Website',
902
+ 'local_business_logo' => 'Image',
903
+ 'saswp_dayofweek' => 'Operation Days',
904
+ 'local_price_range' => 'Price Range',
905
  );
906
  break;
907
 
908
  case 'Blogposting':
909
+
910
+ $meta_field = array(
 
 
 
 
 
 
911
 
912
+ 'saswp_blogposting_main_entity_of_page' => 'Main Entity Of Page',
913
+ 'saswp_blogposting_headline' => 'Headline',
914
+ 'saswp_blogposting_description' => 'Description',
915
+ 'saswp_blogposting_name' => 'Name',
916
+ 'saswp_blogposting_url' => 'URL',
917
+ 'saswp_blogposting_date_published' => 'Date Published',
918
+ 'saswp_blogposting_date_modified' => 'Date Modified',
919
+ 'saswp_blogposting_author_name' => 'Author Name',
920
+ 'saswp_blogposting_organization_name' => 'Organization Name',
921
+ 'saswp_blogposting_organization_logo' => 'Organization Logo',
922
 
923
  );
924
 
925
  break;
926
 
927
  case 'NewsArticle':
928
+
929
  $meta_field = array(
930
  'saswp_newsarticle_main_entity_of_page' => 'Main Entity Of Page',
931
+ 'saswp_newsarticle_URL' => 'URL',
932
+ 'saswp_newsarticle_headline' => 'Headline',
933
+ 'saswp_newsarticle_date_published' => 'Date Published',
934
+ 'saswp_newsarticle_date_modified' => 'Date Modified',
935
+ 'saswp_newsarticle_headline' => 'Headline',
936
+ 'saswp_newsarticle_description' => 'Description',
937
+ 'saswp_newsarticle_section' => 'Article Section',
938
+ 'saswp_newsarticle_body' => 'Article Body',
939
+ 'saswp_newsarticle_name' => 'Name',
940
+ 'saswp_newsarticle_thumbnailurl' => 'Thumbnail URL',
941
+ 'saswp_newsarticle_timerequired' => 'Time Required',
942
+ 'saswp_newsarticle_main_entity_id' => 'Main Entity Id',
943
+ 'saswp_newsarticle_author_name' => 'Author Name',
944
+ 'saswp_newsarticle_author_image' => 'Author Image',
945
+ 'saswp_newsarticle_organization_name' => 'Organization Name',
946
+ 'saswp_newsarticle_organization_logo' => 'Organization Logo',
 
 
 
 
 
947
  );
948
 
949
  break;
950
 
951
  case 'WebPage':
952
+
953
  $meta_field = array(
954
+ 'saswp_webpage_name' => 'Name',
955
+ 'saswp_webpage_url' => 'URL',
956
+ 'saswp_webpage_description' => 'Description',
 
957
  'saswp_webpage_main_entity_of_page' => 'Main Entity Of Page',
958
+ 'saswp_webpage_image' => 'Image',
959
+ 'saswp_webpage_headline' => 'Headline',
960
+ 'saswp_webpage_date_published' => 'Date Published',
961
+ 'saswp_webpage_date_modified' => 'Date Modified',
962
+ 'saswp_webpage_author_name' => 'Author Name',
963
+ 'saswp_webpage_organization_name' => 'Organization Name',
964
+ 'saswp_webpage_organization_logo' => 'Organization Logo',
 
 
965
  );
966
 
967
  break;
968
 
969
  case 'Article':
970
+
971
  $meta_field = array(
972
  'saswp_article_main_entity_of_page' => 'Main Entity Of Page',
973
+ 'saswp_article_image' => 'Image',
974
+ 'saswp_article_headline' => 'Headline',
975
+ 'saswp_article_description' => 'Description',
976
+ 'saswp_article_date_published' => 'Date Published',
977
+ 'saswp_article_date_modified' => 'Date Modified',
978
+ 'saswp_article_author_name' => 'Author Name',
979
+ 'saswp_article_organization_name' => 'Organization Name',
980
+ 'saswp_article_organization_logo' => 'Organization Logo',
 
 
981
 
982
  );
983
  break;
984
 
985
  case 'Recipe':
986
+
987
  $meta_field = array(
988
+ 'saswp_recipe_url' => 'URL',
989
+ 'saswp_recipe_name' => 'Name',
990
+ 'saswp_recipe_date_published' => 'Date Published',
991
+ 'saswp_recipe_date_modified' => 'Date Modified',
992
+ 'saswp_recipe_description' => 'Description',
993
+ 'saswp_recipe_main_entity' => 'Main Entity Id',
994
+ 'saswp_recipe_author_name' => 'Author Name',
995
+ 'saswp_recipe_author_image' => 'Author Image',
996
+ 'saswp_recipe_organization_name' => 'Organization Name',
997
+ 'saswp_recipe_organization_logo' => 'Organization Logo',
998
+ 'saswp_recipe_preptime' => 'Prepare Time',
999
+ 'saswp_recipe_cooktime' => 'Cook Time',
1000
+ 'saswp_recipe_totaltime' => 'Total Time',
1001
+ 'saswp_recipe_keywords' => 'Keywords',
1002
+ 'saswp_recipe_recipeyield' => 'Recipe Yield',
1003
+ 'saswp_recipe_category' => 'Recipe Category',
1004
+ 'saswp_recipe_cuisine' => 'Recipe Cuisine',
1005
+ 'saswp_recipe_nutrition' => 'Nutrition',
1006
+ 'saswp_recipe_ingredient' => 'Recipe Ingredient',
1007
+ 'saswp_recipe_instructions' => 'Recipe Instructions',
1008
+ 'saswp_recipe_video_name' => 'Video Name',
1009
+ 'saswp_recipe_video_description' => 'Video Description',
1010
+ 'saswp_recipe_video_thumbnailurl' => 'Video ThumbnailUrl',
1011
+ 'saswp_recipe_video_contenturl' => 'Video ContentUrl',
1012
+ 'saswp_recipe_video_embedurl' => 'Video EmbedUrl',
1013
+ 'saswp_recipe_video_upload_date' => 'Video Upload Date',
1014
+ 'saswp_recipe_video_duration' => 'Video Duration',
 
 
 
 
 
 
 
 
1015
  );
1016
 
1017
  break;
1019
  case 'Product':
1020
 
1021
  $meta_field = array(
1022
+ 'saswp_product_url' => 'URL',
1023
+ 'saswp_product_name' => 'Name',
1024
  'saswp_product_description' => 'Description',
1025
+ );
1026
+
1027
+ if(is_plugin_active('woocommerce/woocommerce.php')){
1028
+
1029
+ $meta_field['saswp_product_image'] = 'Image';
1030
+ $meta_field['saswp_product_availability'] = 'Availability';
1031
+ $meta_field['saswp_product_price'] = 'Price';
1032
+ $meta_field['saswp_product_currency'] = 'Price Currency';
1033
+ $meta_field['saswp_product_brand'] = 'Brand';
1034
  $meta_field['saswp_product_priceValidUntil'] = 'Price Valid Until';
1035
+ $meta_field['saswp_product_isbn'] = 'ISBN';
1036
+ $meta_field['saswp_product_mpn'] = 'MPN';
1037
+ $meta_field['saswp_product_gtin8'] = 'GTIN 8';
1038
+ }
1039
+
1040
  break;
1041
 
1042
  case 'Service':
1043
 
1044
  $meta_field = array(
1045
+ 'saswp_service_schema_name' => 'Name',
1046
+ 'saswp_service_schema_type' => 'Service Type',
1047
+ 'saswp_service_schema_provider_name' => 'Provider Name',
1048
+ 'saswp_service_schema_provider_type' => 'Provider Type',
1049
+ 'saswp_service_schema_image' => 'Image',
1050
+ 'saswp_service_schema_locality' => 'Locality',
1051
+ 'saswp_service_schema_postal_code' => 'Postal Code',
1052
+ 'saswp_service_schema_telephone' => 'Telephone',
1053
+ 'saswp_service_schema_price_range' => 'Price Range',
1054
+ 'saswp_service_schema_description' => 'Description',
1055
+ 'saswp_service_schema_area_served' => 'Area Served (City)',
1056
+ 'saswp_service_schema_service_offer' => 'Service Offer',
1057
+ 'saswp_review_schema_country' => 'Address Country',
1058
+ 'saswp_review_schema_telephone' => 'Telephone',
1059
  );
1060
 
1061
  break;
1063
  case 'Review':
1064
  $meta_field = array(
1065
 
1066
+ 'saswp_review_schema_item_type' => 'Item Reviewed Type',
1067
+ 'saswp_review_schema_name' => 'Name',
1068
+ 'saswp_review_schema_description' => 'Description',
1069
+ 'saswp_review_schema_date_published' => 'Date Published',
1070
+ 'saswp_review_schema_date_modified' => 'Date Modified',
1071
+ 'saswp_review_schema_image' => 'Image',
1072
+ 'saswp_review_schema_price_range' => 'Price Range',
1073
+ 'saswp_review_schema_street_address' => 'Street Address',
1074
+ 'saswp_review_schema_locality' => 'Address Locality',
1075
+ 'saswp_review_schema_region' => 'Address Region',
1076
+ 'saswp_review_schema_postal_code' => 'Postal Code',
1077
+ 'saswp_review_schema_country' => 'Address Country',
1078
+ 'saswp_review_schema_telephone' => 'Telephone',
1079
  );
1080
  break;
1081
 
1083
 
1084
  $meta_field = array(
1085
 
1086
+ 'saswp_video_object_url' => 'URL',
1087
+ 'saswp_video_object_headline' => 'Headline',
1088
+ 'saswp_video_object_date_published' => 'Date Published',
1089
+ 'saswp_video_object_date_modified' => 'Date Modified',
1090
+ 'saswp_video_object_description' => 'Description',
1091
+ 'saswp_video_object_name' => 'Name',
1092
+ 'saswp_video_object_upload_date' => 'Upload Date',
1093
+ 'saswp_video_object_thumbnail_url' => 'Thumbnail Url',
1094
+ 'saswp_video_object_main_entity_id' => 'Main Entity Id',
1095
+ 'saswp_video_object_author_name' => 'Author Name',
1096
+ 'saswp_video_object_author_image' => 'Author Image',
1097
+ 'saswp_video_object_organization_name' => 'Organization Name',
1098
+ 'saswp_video_object_organization_logo' => 'Organization Logo',
1099
  );
1100
 
1101
  break;
1104
 
1105
  $meta_field = array(
1106
 
1107
+ 'saswp_audio_schema_name' => 'Name',
1108
+ 'saswp_audio_schema_description' => 'Description',
1109
+ 'saswp_audio_schema_contenturl' => 'Content Url',
1110
+ 'saswp_audio_schema_duration' => 'Duration',
1111
+ 'saswp_audio_schema_encoding_format'=> 'Encoding Format',
1112
  'saswp_audio_schema_date_published' => 'Date Published',
1113
+ 'saswp_audio_schema_date_modified' => 'Date Modified',
1114
+ 'saswp_audio_schema_author_name' => 'Author',
1115
  );
1116
 
1117
  break;
1119
  case 'qanda':
1120
  $meta_field = array(
1121
 
1122
+ 'saswp_qa_question_title' => 'Question Title',
1123
+ 'saswp_qa_question_description' => 'Question Description',
1124
+ 'saswp_qa_upvote_count' => 'Question Upvote Count',
1125
+ 'saswp_qa_date_created' => 'Question Date Created',
1126
+ 'saswp_qa_question_author_name' => 'Author Name',
1127
+ 'saswp_qa_accepted_answer_text' => 'Accepted Answer Text',
1128
  'saswp_qa_accepted_answer_date_created' => 'Accepted Answer Date Created',
1129
  'saswp_qa_accepted_answer_upvote_count' => 'Accepted Answer Upvote Count',
1130
+ 'saswp_qa_accepted_answer_url' => 'Accepted Answer Url',
1131
+ 'saswp_qa_accepted_author_name' => 'Accepted Answer Author Name',
1132
+ 'saswp_qa_suggested_answer_text' => 'Suggested Answer Text',
1133
+ 'saswp_qa_suggested_answer_date_created'=> 'Suggested Answer Date Created',
1134
+ 'saswp_qa_suggested_answer_upvote_count'=> 'Suggested Answer Upvote Count',
1135
+ 'saswp_qa_suggested_answer_url' => 'Suggested Answer Url',
1136
+ 'saswp_qa_suggested_author_name' => 'Suggested Answer Author Name',
1137
 
1138
  );
1139
  break;
1144
  return $meta_field;
1145
  }
1146
 
1147
+
1148
+ public function saswp_schema_markup_generator($schema_type){
1149
+
1150
+ global $sd_data;
1151
+ $logo ='';
1152
+ $height ='';
1153
+ $width ='';
1154
+ $site_name ='';
1155
+
1156
+ $input1 = array();
1157
+
1158
+ $author_id = get_the_author_meta('ID');
1159
+ $image_id = get_post_thumbnail_id();
1160
+ $image_details = wp_get_attachment_image_src($image_id, 'full');
1161
+ $author_details = get_avatar_data($author_id);
1162
+ $date = get_the_date("Y-m-d\TH:i:s\Z");
1163
+ $modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
1164
+ $aurthor_name = get_the_author();
1165
+
1166
+
1167
+ if(isset($sd_data['sd_logo'])){
1168
+
1169
+ $logo = $sd_data['sd_logo']['url'];
1170
+ }
1171
+
1172
+
1173
+ if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
1174
+ $site_name = $sd_data['sd_name'];
1175
+ }else{
1176
+ $site_name = get_bloginfo();
1177
+ }
1178
+
1179
+ if('' != $logo && !empty($logo)){
1180
+
1181
+ $height = $sd_data['sd_logo']['height'];
1182
+ $width = $sd_data['sd_logo']['width'];
1183
+
1184
+ }else{
1185
+ $sizes = array(
1186
+ 'width' => 600,
1187
+ 'height' => 60,
1188
+ 'crop' => false,
1189
+ );
1190
+
1191
+ $custom_logo_id = get_theme_mod( 'custom_logo' );
1192
+ $custom_logo = wp_get_attachment_image_src( $custom_logo_id, $sizes);
1193
+ $logo = $custom_logo[0];
1194
+ $height = $custom_logo[1];
1195
+ $width = $custom_logo[2];
1196
+ }
1197
+
1198
+
1199
+
1200
+ switch ($schema_type) {
1201
+
1202
+ case 'Article':
1203
+ $input1 = array(
1204
+ '@context' => 'http://schema.org',
1205
+ '@type' => 'Article',
1206
+ 'mainEntityOfPage' => get_permalink(),
1207
+ 'headline' => get_the_title(),
1208
+ 'description' => strip_tags(get_the_excerpt()),
1209
+ 'datePublished' => $date,
1210
+ 'dateModified' => $modified_date,
1211
+ 'author' => array(
1212
+ '@type' => 'Person',
1213
+ 'name' => $aurthor_name
1214
+ ),
1215
+ 'Publisher' => array(
1216
+ '@type' => 'Organization',
1217
+ 'logo' => array(
1218
+ '@type' => 'ImageObject',
1219
+ 'url' => $logo,
1220
+ 'width' => $width,
1221
+ 'height' => $height,
1222
+ ),
1223
+ 'name' => $site_name,
1224
+ ),
1225
+
1226
+ );
1227
+
1228
+ break;
1229
+
1230
+ case 'WebPage':
1231
+
1232
+ if(empty($image_details[0]) || $image_details[0] === NULL ){
1233
+ $image_details[0] = $logo;
1234
+ }
1235
+
1236
+ $input1 = array(
1237
+ '@context' => 'http://schema.org',
1238
+ '@type' => $schema_type ,
1239
+ 'name' => get_the_title(),
1240
+ 'url' => get_permalink(),
1241
+ 'description' => strip_tags(get_the_excerpt()),
1242
+ 'mainEntity' => array(
1243
+ '@type' => 'Article',
1244
+ 'mainEntityOfPage' => get_permalink(),
1245
+ 'image' => $image_details[0],
1246
+ 'headline' => get_the_title(),
1247
+ 'description' => strip_tags(get_the_excerpt()),
1248
+ 'datePublished' => $date,
1249
+ 'dateModified' => $modified_date,
1250
+ 'author' => array(
1251
+ '@type' => 'Person',
1252
+ 'name' => $aurthor_name, ),
1253
+ 'Publisher' => array(
1254
+ '@type' => 'Organization',
1255
+ 'logo' => array(
1256
+ '@type' => 'ImageObject',
1257
+ 'url' => $logo,
1258
+ 'width' => $width,
1259
+ 'height' => $height,
1260
+ ),
1261
+ 'name' => $site_name,
1262
+ ),
1263
+
1264
+ ),
1265
+
1266
+
1267
+ );
1268
+
1269
+ break;
1270
+
1271
+ default:
1272
+ break;
1273
+ }
1274
+
1275
+ return $input1;
1276
+
1277
+ }
1278
+
1279
+ public function saswp_get_fetaure_image(){
1280
+
1281
+ global $sd_data;
1282
+ $input2 = array();
1283
+ $image_id = get_post_thumbnail_id();
1284
+ $image_details = wp_get_attachment_image_src($image_id, 'full');
1285
+
1286
+ if( is_array($image_details) ){
1287
+
1288
+ if(isset($image_details[1]) && ($image_details[1] < 1200) && function_exists('ampforwp_aq_resize')){
1289
+
1290
+ $width = 1280;
1291
+ $height = 720;
1292
+ $resize_image = ampforwp_aq_resize( $image_details[0], $width, $height, true, false, true );
1293
+ $image_details[0] = $resize_image[0];
1294
+
1295
+ }else{
1296
+
1297
+ $width = $image_details[1];
1298
+ $height = $image_details[2];
1299
+ }
1300
+
1301
+ $input2['image']['@type'] = 'ImageObject';
1302
+ $input2['image']['url'] = $image_details[0];
1303
+ $input2['image']['width'] = $width;
1304
+ $input2['image']['height'] = $height;
1305
+
1306
+ }else{
1307
+
1308
+ if(isset($sd_data['sd_default_image']['url']) && $sd_data['sd_default_image']['url'] !=''){
1309
+
1310
+ $input2['image']['@type'] = 'ImageObject';
1311
+ $input2['image']['url'] = $sd_data['sd_default_image']['url'];
1312
+ $input2['image']['width'] = $sd_data['sd_default_image_width'];
1313
+ $input2['image']['height'] = $sd_data['sd_default_image_height'];
1314
+
1315
+ }
1316
+
1317
+
1318
+ }
1319
+
1320
+ return $input2;
1321
+ }
1322
+
1323
+ public function saswp_get_publisher($d_logo = null){
1324
+
1325
+ global $sd_data;
1326
+
1327
+ $publisher = array();
1328
+ $default_logo = array();
1329
+
1330
+ $logo = isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['url']:'';
1331
+ $height = isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['height']:'';
1332
+ $width = isset($sd_data['sd_logo']) ? $sd_data['sd_logo']['width']:'';
1333
+ $site_name = isset($sd_data['sd_name']) && $sd_data['sd_name'] !='' ? $sd_data['sd_name']:get_bloginfo();
1334
+
1335
+ if($logo =='' && $height =='' && $width ==''){
1336
+
1337
+ $sizes = array(
1338
+ 'width' => 600,
1339
+ 'height' => 60,
1340
+ 'crop' => false,
1341
+ );
1342
+
1343
+ $custom_logo_id = get_theme_mod( 'custom_logo' );
1344
+ $custom_logo = wp_get_attachment_image_src( $custom_logo_id, $sizes);
1345
+ $logo = $custom_logo[0];
1346
+ $height = $custom_logo[1];
1347
+ $width = $custom_logo[2];
1348
+ }
1349
+
1350
+ if($logo !='' && $height !='' && $width !=''){
1351
+
1352
+ $publisher['Publisher']['@type'] = 'Organization';
1353
+ $publisher['Publisher']['logo']['@type'] = 'ImageObject';
1354
+ $publisher['Publisher']['logo']['url'] = $logo;
1355
+ $publisher['Publisher']['logo']['width'] = $width;
1356
+ $publisher['Publisher']['logo']['height']= $height;
1357
+ $publisher['Publisher']['name'] = $site_name;
1358
+
1359
+ $default_logo['url'] = $logo;
1360
+ $default_logo['height'] = $height;
1361
+ $default_logo['width'] = $width;
1362
+
1363
+ }
1364
+
1365
+ if($d_logo){
1366
+ return $default_logo;
1367
+ }else{
1368
+ return $publisher;
1369
+ }
1370
+
1371
+ }
1372
+
1373
  }
1374
  if (class_exists('saswp_output_service')) {
1375
  $object = new saswp_output_service();
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 5.0.2
6
- Stable tag: 1.0.7.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -65,6 +65,15 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
 
 
68
  = 1.0.7.1 (5 January 2019) =
69
 
70
  * Improvement: AMP tab should always be shown and amp option should be disabled if amp is not activated. #87
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 5.0.2
6
+ Stable tag: 1.0.8
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
65
 
66
  == Changelog ==
67
 
68
+ = 1.0.8 (28 January 2019) =
69
+
70
+ * Added: Yoast plugin compatibility ( If yoast is activated for schema. Organization & website markup should not be duplicate )
71
+ * Improvement: Show the fields of review schema type according to selected Item Reviewed Type
72
+ * Bug Fixed: Product schema is not getting feature image/product image when WooCommerce compatibility is enable #122
73
+ * Bug Fixed: Missing escaping, Warnings and Notices fixed
74
+ * Bug Fixed: Google is requiring 1200 pixel wide feature images #131
75
+
76
+
77
  = 1.0.7.1 (5 January 2019) =
78
 
79
  * Improvement: AMP tab should always be shown and amp option should be disabled if amp is not activated. #87
structured-data-for-wp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Schema & Structured Data for WP
4
  Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5
- Version: 1.0.7.1
6
  Text Domain: schema-and-structured-data-for-wp
7
  Domain Path: /languages
8
  Author: Mohammed Kaludi, Ahmed Kaludi
@@ -13,7 +13,7 @@ License: GPL2
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
- define('SASWP_VERSION', '1.0.7.1');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
@@ -35,15 +35,20 @@ if ( is_plugin_active('flexmls-idx/flexmls_connect.php') && class_exists('flexml
35
  }
36
 
37
  // Non amp checker
38
- if ( ! function_exists('saswp_non_amp') ){
 
39
  function saswp_non_amp(){
 
40
  $non_amp = true;
 
41
  if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
 
42
  $non_amp = false;
43
-
44
  }
45
  return $non_amp;
46
  }
 
47
  }
48
  // Schema App end here
49
  require_once SASWP_DIR_NAME.'/admin_section/structure_admin.php';
@@ -67,68 +72,62 @@ require_once SASWP_DIR_NAME.'/output/service.php';
67
  * set user defined message on plugin activate
68
  */
69
  register_activation_hook( __FILE__, 'saswp_admin_notice_activation_hook' );
 
70
  function saswp_admin_notice_activation_hook() {
 
71
  set_transient( 'saswp_admin_notice_transient', true, 5 );
72
  update_option( "saswp_activation_date", date("Y-m-d"));
 
73
  }
74
  add_action( 'admin_notices', 'saswp_admin_notice' );
75
 
76
  function saswp_admin_notice(){
 
77
  $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
78
- ?>
79
- <div class="updated notice is-dismissible message notice notice-alt saswp-setup-notice saswp_hide">
80
- <p><span class="dashicons dashicons-thumbs-up"></span> <?php echo esc_html__('Thank you for using Schema & Structured Data For WP plugin!', 'schema-and-structured-data-for-wp') ?>
81
- <a href="<?php echo esc_url(admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce); ?>"> <?php echo esc_html__('Start Quick Setup', 'schema-and-structured-data-for-wp') ?></a>
82
- </p>
83
- </div>
84
-
85
- <div class="updated notice is-dismissible message notice notice-alt saswp-feedback-notice saswp_hide">
86
- <p><span class="dashicons dashicons-thumbs-up"></span> <?php echo esc_html__('You have been using the Schema & structured data for wp plugin for some time now, do you like it?, If so,', 'schema-and-structured-data-for-wp') ?>
87
- <a target="_blank" href="https://wordpress.org/plugins/schema-and-structured-data-for-wp/#reviews"> <?php echo esc_html__('please write us a review', 'schema-and-structured-data-for-wp') ?></a>&nbsp;&nbsp;&nbsp;&nbsp;
88
- <a class="saswp-feedback-remindme button button-primary"><?php echo esc_html__('Remind Me Later', 'schema-and-structured-data-for-wp') ?></a>
89
- <a class="saswp-feedback-no-thanks button button-primary"><?php echo esc_html__('No Thanks', 'schema-and-structured-data-for-wp') ?></a>
90
- </p>
91
- </div>
92
- <?php
93
  /* Check transient, if available display notice */
94
  if( get_transient( 'saswp_admin_notice_transient' ) ){
95
- ?>
96
- <script type="text/javascript">
97
- jQuery(document).ready( function($) {
98
- $(".saswp-setup-notice").show();
99
- });
100
- </script>
101
- <?php
102
  /* Delete transient, only display this notice once. */
103
  delete_transient( 'saswp_admin_notice_transient' );
 
104
  }
105
- $current_screen = get_Current_screen();
106
- $post_type = get_post_type();
107
- $sd_data = get_option('sd_data');
 
 
108
  if(($post_type == 'saswp' || $current_screen->id =='saswp_page_structured_data_options') && !isset($sd_data['sd_initial_wizard_status'])){
109
- ?>
110
- <script type="text/javascript">
111
- jQuery(document).ready( function($) {
112
- $(".saswp-setup-notice").show();
113
- $(".saswp-start-quck-setup").hide();
114
- });
115
- </script>
116
- <?php
117
  }
118
  //Feedback notice
119
- $activation_date = get_option("saswp_activation_date");
120
  $activation_never = get_option("saswp_activation_never");
121
- $next_days = strtotime("+7 day", strtotime($activation_date));
122
- $next_days = date('Y-m-d', $next_days);
123
- $current_date = date("Y-m-d");
124
 
125
  if(($next_days < $current_date) && $activation_never !='never' ){
126
  ?>
127
- <script type="text/javascript">
128
- jQuery(document).ready( function($) {
129
- $(".saswp-feedback-notice").show();
130
- });
131
- </script>
 
 
132
  <?php
133
  }
134
  }
@@ -139,9 +138,9 @@ function saswp_add_plugin_meta_links($meta_fields, $file) {
139
  if ( plugin_basename(__FILE__) == $file ) {
140
  $plugin_url = "https://wordpress.org/support/plugin/schema-and-structured-data-for-wp";
141
  $hire_url = "https://ampforwp.com/hire/";
142
- $meta_fields[] = "<a href='" . esc_url($plugin_url) . "' target='_blank'>" . esc_html__('Support Forum', 'ads-for-wp') . "</a>";
143
- $meta_fields[] = "<a href='" . esc_url($hire_url) . "' target='_blank'>" . esc_html__('Hire Us', 'ads-for-wp') . "</a>";
144
- $meta_fields[] = "<a href='" . esc_url($plugin_url) . "/reviews#new-post' target='_blank' title='" . esc_html__('Rate', 'ads-for-wp') . "'>
145
  <i class='saswp-wdi-rate-stars'>"
146
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
147
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
@@ -149,12 +148,6 @@ function saswp_add_plugin_meta_links($meta_fields, $file) {
149
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
150
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
151
  . "</i></a>";
152
- echo "<style>"
153
- . ".saswp-wdi-rate-stars{display:inline-block;color:#ffb900;position:relative;top:3px;}"
154
- . ".saswp-wdi-rate-stars svg{fill:#ffb900;}"
155
- . ".saswp-wdi-rate-stars svg:hover{fill:#ffb900}"
156
- . ".saswp-wdi-rate-stars svg:hover ~ svg{fill:none;}"
157
- . "</style>";
158
  }
159
 
160
  return $meta_fields;
2
  /*
3
  Plugin Name: Schema & Structured Data for WP
4
  Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5
+ Version: 1.0.8
6
  Text Domain: schema-and-structured-data-for-wp
7
  Domain Path: /languages
8
  Author: Mohammed Kaludi, Ahmed Kaludi
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
+ define('SASWP_VERSION', '1.0.8');
17
  define('SASWP_DIR_NAME_FILE', __FILE__ );
18
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
19
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
35
  }
36
 
37
  // Non amp checker
38
+ if ( ! function_exists('saswp_non_amp') ){
39
+
40
  function saswp_non_amp(){
41
+
42
  $non_amp = true;
43
+
44
  if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
45
+
46
  $non_amp = false;
47
+
48
  }
49
  return $non_amp;
50
  }
51
+
52
  }
53
  // Schema App end here
54
  require_once SASWP_DIR_NAME.'/admin_section/structure_admin.php';
72
  * set user defined message on plugin activate
73
  */
74
  register_activation_hook( __FILE__, 'saswp_admin_notice_activation_hook' );
75
+
76
  function saswp_admin_notice_activation_hook() {
77
+
78
  set_transient( 'saswp_admin_notice_transient', true, 5 );
79
  update_option( "saswp_activation_date", date("Y-m-d"));
80
+
81
  }
82
  add_action( 'admin_notices', 'saswp_admin_notice' );
83
 
84
  function saswp_admin_notice(){
85
+
86
  $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
87
+
88
+ $setup_notice = '<div class="updated notice is-dismissible message notice notice-alt saswp-setup-notice">'
89
+ . '<p><span class="dashicons dashicons-thumbs-up"></span>'
90
+ . esc_html__('Thank you for using Schema & Structured Data For WP plugin!', 'schema-and-structured-data-for-wp')
91
+ . ' <a href="'.esc_url(admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce).'">'
92
+ . esc_html__('Start Quick Setup', 'schema-and-structured-data-for-wp')
93
+ . '</a>'
94
+ . '</p>'
95
+ . '</div>';
96
+
 
 
 
 
 
97
  /* Check transient, if available display notice */
98
  if( get_transient( 'saswp_admin_notice_transient' ) ){
99
+
100
+ echo $setup_notice;
 
 
 
 
 
101
  /* Delete transient, only display this notice once. */
102
  delete_transient( 'saswp_admin_notice_transient' );
103
+
104
  }
105
+
106
+ $current_screen = get_Current_screen();
107
+ $post_type = get_post_type();
108
+ $sd_data = get_option('sd_data');
109
+
110
  if(($post_type == 'saswp' || $current_screen->id =='saswp_page_structured_data_options') && !isset($sd_data['sd_initial_wizard_status'])){
111
+
112
+ echo $setup_notice;
113
+
 
 
 
 
 
114
  }
115
  //Feedback notice
116
+ $activation_date = get_option("saswp_activation_date");
117
  $activation_never = get_option("saswp_activation_never");
118
+ $next_days = strtotime("+7 day", strtotime($activation_date));
119
+ $next_days = date('Y-m-d', $next_days);
120
+ $current_date = date("Y-m-d");
121
 
122
  if(($next_days < $current_date) && $activation_never !='never' ){
123
  ?>
124
+ <div class="updated notice is-dismissible message notice notice-alt saswp-feedback-notice">
125
+ <p><span class="dashicons dashicons-thumbs-up"></span> <?php echo esc_html__('You have been using the Schema & structured data for wp plugin for some time now, do you like it?, If so,', 'schema-and-structured-data-for-wp') ?>
126
+ <a target="_blank" href="https://wordpress.org/plugins/schema-and-structured-data-for-wp/#reviews"> <?php echo esc_html__('please write us a review', 'schema-and-structured-data-for-wp') ?></a>&nbsp;&nbsp;&nbsp;&nbsp;
127
+ <a class="saswp-feedback-remindme button button-primary"><?php echo esc_html__('Remind Me Later', 'schema-and-structured-data-for-wp') ?></a>
128
+ <a class="saswp-feedback-no-thanks button button-primary"><?php echo esc_html__('No Thanks', 'schema-and-structured-data-for-wp') ?></a>
129
+ </p>
130
+ </div>
131
  <?php
132
  }
133
  }
138
  if ( plugin_basename(__FILE__) == $file ) {
139
  $plugin_url = "https://wordpress.org/support/plugin/schema-and-structured-data-for-wp";
140
  $hire_url = "https://ampforwp.com/hire/";
141
+ $meta_fields[] = "<a href='" . esc_url($plugin_url) . "' target='_blank'>" . esc_html__('Support Forum', 'schema-and-structured-data-for-wp') . "</a>";
142
+ $meta_fields[] = "<a href='" . esc_url($hire_url) . "' target='_blank'>" . esc_html__('Hire Us', 'schema-and-structured-data-for-wp') . "</a>";
143
+ $meta_fields[] = "<a href='" . esc_url($plugin_url) . "/reviews#new-post' target='_blank' title='" . esc_html__('Rate', 'schema-and-structured-data-for-wp') . "'>
144
  <i class='saswp-wdi-rate-stars'>"
145
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
146
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
148
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
149
  . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
150
  . "</i></a>";
 
 
 
 
 
 
151
  }
152
 
153
  return $meta_fields;
view/paywall.php CHANGED
@@ -3,14 +3,16 @@
3
  add_action( 'save_post', 'saswp_schema_options_add_meta_box_save' ) ;
4
 
5
  function saswp_schema_options_add_meta_box() {
 
6
  add_meta_box(
7
  'schema_options',
8
- esc_html__( 'Advance Schema Options', 'ads-for-wp' ),
9
  'saswp_schema_options_meta_box_callback',
10
  'saswp',
11
  'advanced',
12
  'low'
13
  );
 
14
  }
15
  function saswp_schema_options_get_meta( $value ) {
16
  global $post;
@@ -24,12 +26,13 @@
24
  }
25
  }
26
  function saswp_schema_options_meta_box_callback( $post) {
 
27
  wp_nonce_field( 'saswp_schema_options_nonce', 'saswp_schema_options_nonce' );
28
  $schema_options = esc_sql ( get_post_meta($post->ID, 'schema_options', true) );
29
  $custom_fields = esc_sql ( get_post_meta($post->ID, 'saswp_custom_fields', true) );
30
  ?>
31
  <style type="text/css">
32
- .option-table-class{width:100%;}
33
  .option-table-class tr td {padding: 10px 10px 10px 10px ;}
34
  .option-table-class tr > td{width: 30%;}
35
  .option-table-class tr td:last-child{width: 60%;}
@@ -72,6 +75,7 @@
72
  <table class="option-table-class saswp-custom-fields-table">
73
 
74
  <?php
 
75
  if(!empty($custom_fields)){
76
  $schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
77
  $service = new saswp_output_service();
3
  add_action( 'save_post', 'saswp_schema_options_add_meta_box_save' ) ;
4
 
5
  function saswp_schema_options_add_meta_box() {
6
+
7
  add_meta_box(
8
  'schema_options',
9
+ esc_html__( 'Advance Schema Options', 'schema-and-structured-data-for-wp' ),
10
  'saswp_schema_options_meta_box_callback',
11
  'saswp',
12
  'advanced',
13
  'low'
14
  );
15
+
16
  }
17
  function saswp_schema_options_get_meta( $value ) {
18
  global $post;
26
  }
27
  }
28
  function saswp_schema_options_meta_box_callback( $post) {
29
+
30
  wp_nonce_field( 'saswp_schema_options_nonce', 'saswp_schema_options_nonce' );
31
  $schema_options = esc_sql ( get_post_meta($post->ID, 'schema_options', true) );
32
  $custom_fields = esc_sql ( get_post_meta($post->ID, 'saswp_custom_fields', true) );
33
  ?>
34
  <style type="text/css">
35
+ .option-table-class {width:100%;}
36
  .option-table-class tr td {padding: 10px 10px 10px 10px ;}
37
  .option-table-class tr > td{width: 30%;}
38
  .option-table-class tr td:last-child{width: 60%;}
75
  <table class="option-table-class saswp-custom-fields-table">
76
 
77
  <?php
78
+
79
  if(!empty($custom_fields)){
80
  $schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
81
  $service = new saswp_output_service();
view/post_specific.php CHANGED
@@ -1,15 +1,18 @@
1
  <?php
2
  class saswp_post_specific {
3
- private $screen = array();
4
- private $meta_fields = array(
5
-
6
- );
7
- protected $all_schema = null;
8
- protected $options_response = array();
9
  protected $modify_schema_post_enable = false;
10
- public function __construct() {
 
 
11
  }
 
12
  public function saswp_post_specific_hooks(){
 
13
  $this->saswp_get_all_schema_list();
14
  add_action( 'add_meta_boxes', array( $this, 'saswp_post_specifc_add_meta_boxes' ) );
15
  add_action( 'save_post', array( $this, 'saswp_post_specific_save_fields' ) );
@@ -20,6 +23,7 @@ class saswp_post_specific {
20
  add_action( 'wp_ajax_saswp_restore_schema', array($this,'saswp_restore_schema'));
21
 
22
  add_action( 'wp_ajax_saswp_enable_disable_schema_on_post', array($this,'saswp_enable_disable_schema_on_post'));
 
23
  }
24
  public function saswp_enable_disable_schema_on_post(){
25
 
@@ -29,14 +33,17 @@ class saswp_post_specific {
29
  if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
30
  return;
31
  }
 
32
  $schema_enable = array();
33
- $post_id = sanitize_text_field($_POST['post_id']);
34
- $schema_id = sanitize_text_field($_POST['schema_id']);
35
- $status = sanitize_text_field($_POST['status']);
36
 
37
  $schema_enable = get_post_meta($post_id, 'saswp_enable_disable_schema', true);
 
38
  $schema_enable[$schema_id] = $status;
39
  update_post_meta( $post_id, 'saswp_enable_disable_schema', $schema_enable);
 
40
  echo json_encode(array('status'=>'t'));
41
  wp_die();
42
 
@@ -90,34 +97,45 @@ class saswp_post_specific {
90
  }
91
  }
92
 
93
- public function saswp_post_meta_box_fields($post){
94
- $tabs = '';
95
- $tabs_fields = '';
96
- $schema_ids = array();
 
97
 
98
  $schema_enable = get_post_meta($post->ID, 'saswp_enable_disable_schema', true);
99
 
100
- if(count($this->all_schema)>1){
 
101
  foreach($this->all_schema as $key => $schema){
102
 
103
  $checked = '';
 
104
  if(isset($schema_enable[$schema->ID]) && $schema_enable[$schema->ID] == 1){
 
105
  $checked = 'checked';
 
106
  }
107
  $response = $this->saswp_get_fields_by_schema_type($schema->ID);
108
  $this->meta_fields = $response;
109
- $output = $this->saswp_saswp_post_specific( $post, $schema->ID );
 
110
  $schema_type = esc_sql ( get_post_meta($schema->ID, 'schema_type', true) );
 
111
  if($key==0){
 
112
  $tabs .='<li class="selected"><a saswp-schema-type="'.$schema_type.'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links selected">'.esc_attr($schema->post_title).'</a>'
113
  . '<label class="saswp-switch">'
114
  . '<input type="checkbox" class="saswp-schema-type-toggle" value="1" data-schema-id="'.esc_attr($schema->ID).'" data-post-id="'.esc_attr($post->ID).'" '.$checked.'>'
115
  . '<span class="saswp-slider"></span>'
116
  . '</li>';
 
117
  $tabs_fields .= '<div data-id="'.esc_attr($schema->ID).'" id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-post-specific-wrapper">';
118
  $tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
119
  $tabs_fields .= '</div>';
 
120
  }else{
 
121
  $tabs .='<li>'
122
  . '<a saswp-schema-type="'.$schema_type.'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links">'.esc_attr($schema->post_title).'</a>'
123
  . '<label class="saswp-switch">'
@@ -129,6 +147,7 @@ class saswp_post_specific {
129
  $tabs_fields .= '</div>';
130
 
131
  }
 
132
  $schema_ids[] =$schema->ID;
133
  }
134
 
@@ -148,7 +167,7 @@ class saswp_post_specific {
148
  }else{
149
 
150
  $all_schema = $this->all_schema;
151
- $response = $this->saswp_get_fields_by_schema_type($all_schema[0]->ID);
152
 
153
  $schema_ids[] =$all_schema[0]->ID;
154
  $schema_type = esc_sql ( get_post_meta($all_schema[0]->ID, 'schema_type', true) );
@@ -174,35 +193,50 @@ class saswp_post_specific {
174
  }
175
  }
176
 
177
- public function saswp_post_meta_box_callback() {
 
178
  wp_nonce_field( 'post_specific_data', 'post_specific_nonce' );
179
  global $post;
180
  $option = get_option('modify_schema_post_enable_'.$post->ID);
 
181
  if($option == 'enable'){
182
- $this->saswp_post_meta_box_fields($post);
 
 
183
  }else{
 
184
  echo '<a class="button saswp-modify_schema_post_enable">Modify Schema</a>' ;
 
185
  }
186
 
187
  }
188
 
189
  public function saswp_restore_schema(){
 
190
  if ( ! isset( $_POST['saswp_security_nonce'] ) ){
191
  return;
192
  }
193
  if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
194
  return;
195
  }
196
- $result ='';
197
- $post_id = sanitize_text_field($_POST['post_id']);
198
  $schema_ids = $_POST['schema_ids'];
 
199
  foreach($schema_ids as $id){
 
200
  $meta_field = $this->saswp_get_fields_by_schema_type($id);
 
201
  foreach($meta_field as $field){
202
- $result = delete_post_meta($post_id, $field['id']);
203
- }
204
- }
 
 
 
 
205
  update_option('modify_schema_post_enable_'.$post_id, 'disable');
 
206
  if($result){
207
  echo json_encode(array('status'=> 't', 'msg'=>esc_html__( 'Schema has been restored', 'schema-and-structured-data-for-wp' )));
208
  }else{
@@ -212,35 +246,45 @@ class saswp_post_specific {
212
  }
213
 
214
  public function saswp_modify_schema_post_enable(){
 
215
  if ( ! isset( $_GET['saswp_security_nonce'] ) ){
216
- return;
217
  }
218
  if ( !wp_verify_nonce( $_GET['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
219
  return;
220
  }
221
 
222
  $post_id = sanitize_text_field($_GET['post_id']);
223
- update_option('modify_schema_post_enable_'.$post_id, 'enable');
 
224
  $args = array(
225
  'p' => $post_id, // ID of a page, post, or custom type
226
  'post_type' => 'any'
227
  );
 
228
  $my_posts = new WP_Query($args);
 
229
  if ( $my_posts->have_posts() ) {
230
- while ( $my_posts->have_posts() ) : $my_posts->the_post();
231
- echo $this->saswp_post_meta_box_callback();
 
 
 
232
  endwhile;
 
233
  }
234
 
235
  wp_die();
 
236
  }
237
 
238
  public function saswp_saswp_post_specific( $post, $schema_id ) {
239
 
240
  global $post;
241
  global $sd_data;
242
- $image_id = get_post_thumbnail_id();
243
  $image_details = wp_get_attachment_image_src($image_id, 'full');
 
244
  if(empty($image_details[0]) || $image_details[0] === NULL ){
245
 
246
  if(isset($sd_data['sd_logo'])){
@@ -248,17 +292,22 @@ class saswp_post_specific {
248
  }
249
 
250
  }
251
- $current_user = wp_get_current_user();
 
252
  $author_details = get_avatar_data($current_user->ID);
253
- $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
254
  $output = '';
 
255
  $this->meta_fields = array_filter($this->meta_fields);
 
256
  foreach ( $this->meta_fields as $meta_field ) {
257
- $input ='';
 
258
  $attributes ='';
259
 
260
- $label = '<label for="' . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
261
  $meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
 
262
  if ( empty( $meta_value ) && isset($meta_field['default'])) {
263
 
264
  $meta_value = $meta_field['default'];
@@ -272,7 +321,7 @@ class saswp_post_specific {
272
  switch ( $meta_field['type'] ) {
273
  case 'media':
274
  $media_value = array();
275
- $media_key = $meta_field['id'].'detail';
276
  $media_value_meta = get_post_meta( $post->ID, $media_key, true );
277
  if(!empty($media_value_meta)){
278
  $media_value =$media_value_meta;
@@ -380,9 +429,12 @@ class saswp_post_specific {
380
  if (strpos($meta_field['id'], 'business_name') !== false){
381
  $class='saswp-local-business-name-select';
382
  }
 
 
 
383
 
384
  $input = sprintf(
385
- '<select class="%s" id="%s" name="%s">',
386
  $class,
387
  $meta_field['id'],
388
  $meta_field['id']
@@ -502,6 +554,10 @@ class saswp_post_specific {
502
  )
503
  {
504
  $output .= '<tr class="saswp-rating-review-'.strtolower($schema_type).'"><th>'.$label.'</th><td>'.$input.'</td></tr>';
 
 
 
 
505
  }else{
506
  $output .= '<tr><th>'.$label.'</th><td>'.$input.'</td></tr>';
507
  }
@@ -510,6 +566,7 @@ class saswp_post_specific {
510
  return $output;
511
  }
512
  public function saswp_post_specific_save_fields( $post_id ) {
 
513
  if ( ! isset( $_POST['post_specific_nonce'] ) )
514
  return $post_id;
515
  $nonce = $_POST['post_specific_nonce'];
@@ -519,30 +576,36 @@ class saswp_post_specific {
519
  return $post_id;
520
 
521
  $option = get_option('modify_schema_post_enable_'.$post_id);
 
522
  if($option != 'enable'){
523
  return;
524
- }
 
 
 
525
  if(count($this->all_schema)>0){
526
-
527
  foreach($this->all_schema as $schema){
528
- $response = $this->saswp_get_fields_by_schema_type($schema->ID);
529
- $this->meta_fields = $response;
 
 
530
  foreach ( $this->meta_fields as $meta_field ) {
 
531
  if ( isset( $_POST[ $meta_field['id'] ] ) ) {
 
532
  switch ( $meta_field['type'] ) {
 
533
  case 'media':
534
- $media_key = $meta_field['id'].'_detail';
535
- //$media_id = sanitize_text_field( $_POST[ $meta_field['id'].'_id' ] );
536
- $media_height = sanitize_text_field( $_POST[ $meta_field['id'].'_height' ] );
537
- $media_width = sanitize_text_field( $_POST[ $meta_field['id'].'_width' ] );
538
  $media_thumbnail = sanitize_text_field( $_POST[ $meta_field['id'].'_thumbnail' ] );
539
- $media_detail = array(
540
- //'id' =>$media_id,
541
  'height' =>$media_height,
542
  'width' =>$media_width,
543
  'thumbnail' =>$media_thumbnail,
544
- );
545
-
546
  update_post_meta( $post_id, $media_key, $media_detail);
547
  break;
548
  case 'email':
@@ -551,6 +614,7 @@ class saswp_post_specific {
551
  case 'text':
552
  $_POST[ $meta_field['id'] ] = sanitize_text_field( $_POST[ $meta_field['id'] ] );
553
  break;
 
554
  }
555
  update_post_meta( $post_id, $meta_field['id'], $_POST[ $meta_field['id'] ] );
556
  } else if ( $meta_field['type'] === 'checkbox' ) {
@@ -581,144 +645,146 @@ class saswp_post_specific {
581
  wp_die();
582
  }
583
  public function saswp_get_sub_business_array($business_type){
 
584
  $sub_business_options = array();
 
585
  switch ($business_type) {
586
  case 'automotivebusiness':
587
  $sub_business_options = array(
588
- 'autobodyshop' => 'Auto Body Shop',
589
- 'autodealer' => 'Auto Dealer',
590
- 'autopartsstore' => 'Auto Parts Store',
591
- 'autorental' => 'Auto Rental',
592
- 'autorepair' => 'Auto Repair',
593
- 'autowash' => 'Auto Wash',
594
- 'gasstation' => 'Gas Station',
595
- 'motorcycledealer' => 'Motorcycle Dealer',
596
- 'motorcyclerepair' => 'Motorcycle Repair'
597
  );
598
  break;
599
  case 'emergencyservice':
600
  $sub_business_options = array(
601
- 'firestation' => 'Fire Station',
602
- 'hospital' => 'Hospital',
603
- 'policestation' => 'Police Station',
604
  );
605
  break;
606
  case 'entertainmentbusiness':
607
  $sub_business_options = array(
608
  'adultentertainment' => 'Adult Entertainment',
609
- 'amusementpark' => 'Amusement Park',
610
- 'artgallery' => 'Art Gallery',
611
- 'casino' => 'Casino',
612
- 'comedyclub' => 'Comedy Club',
613
- 'movietheater' => 'Movie Theater',
614
- 'nightclub' => 'Night Club',
615
 
616
  );
617
  break;
618
  case 'financialservice':
619
  $sub_business_options = array(
620
- 'accountingservice' => 'Accounting Service',
621
- 'automatedteller' => 'Automated Teller',
622
- 'bankorcredit_union' => 'Bank Or Credit Union',
623
- 'insuranceagency' => 'Insurance Agency',
624
 
625
  );
626
  break;
627
  case 'foodestablishment':
628
  $sub_business_options = array(
629
- 'bakery' => 'Bakery',
630
- 'barorpub' => 'Bar Or Pub',
631
- 'brewery' => 'Brewery',
632
- 'cafeorcoffee_shop' => 'Cafe Or Coffee Shop',
633
  'fastfoodrestaurant' => 'Fast Food Restaurant',
634
- 'icecreamshop' => 'Ice Cream Shop',
635
- 'restaurant' => 'Restaurant',
636
- 'winery' => 'Winery',
637
 
638
  );
639
  break;
640
  case 'healthandbeautybusiness':
641
  $sub_business_options = array(
642
- 'beautysalon' => 'Beauty Salon',
643
- 'dayspa' => 'DaySpa',
644
- 'hairsalon' => 'Hair Salon',
645
- 'healthclub' => 'Health Club',
646
- 'nailsalon' => 'Nail Salon',
647
  'tattooparlor' => 'Tattoo Parlor',
648
  );
649
  break;
650
  case 'homeandconstructionbusiness':
651
  $sub_business_options = array(
652
- 'electrician' => 'Electrician',
653
  'generalcontractor' => 'General Contractor',
654
- 'hvacbusiness' => 'HVAC Business',
655
- 'locksmith' => 'Locksmith',
656
- 'movingcompany' => 'Moving Company',
657
- 'plumber' => 'Plumber',
658
  'roofingcontractor' => 'Roofing Contractor',
659
  );
660
  break;
661
  case 'legalservice':
662
  $sub_business_options = array(
663
  'attorney' => 'Attorney',
664
- 'notary' => 'Notary',
665
  );
666
  break;
667
  case 'lodgingbusiness':
668
  $sub_business_options = array(
669
  'bedandbreakfast' => 'Bed And Breakfast',
670
- 'campground' => 'Campground',
671
- 'hostel' => 'Hostel',
672
- 'hotel' => 'Hotel',
673
- 'motel' => 'Motel',
674
- 'resort' => 'Resort',
675
  );
676
  break;
677
  case 'sportsactivitylocation':
678
  $sub_business_options = array(
679
- 'bowlingalley' => 'Bowling Alley',
680
- 'exercisegym' => 'Exercise Gym',
681
- 'golfcourse' => 'Golf Course',
682
- 'healthclub' => 'Health Club',
683
  'publicswimming_pool' => 'Public Swimming Pool',
684
- 'skiresort' => 'Ski Resort',
685
- 'sportsclub' => 'Sports Club',
686
- 'stadiumorarena' => 'Stadium Or Arena',
687
- 'tenniscomplex' => 'Tennis Complex'
688
  );
689
  break;
690
  case 'store':
691
  $sub_business_options = array(
692
- 'autopartsstore'=>'Auto Parts Store',
693
- 'bikestore'=>'Bike Store',
694
- 'bookstore'=>'Book Store',
695
- 'clothingstore'=>'Clothing Store',
696
- 'computerstore'=>'Computer Store',
697
- 'conveniencestore'=>'Convenience Store',
698
- 'departmentstore'=>'Department Store',
699
- 'electronicsstore'=>'Electronics Store',
700
- 'florist'=>'Florist',
701
- 'furniturestore'=>'Furniture Store',
702
- 'gardenstore'=>'Garden Store',
703
- 'grocerystore'=>'Grocery Store',
704
- 'hardwarestore'=>'Hardware Store',
705
- 'hobbyshop'=>'Hobby Shop',
706
- 'homegoodsstore'=>'HomeGoods Store',
707
- 'jewelrystore'=>'Jewelry Store',
708
- 'liquorstore'=>'Liquor Store',
709
- 'mensclothingstore'=>'Mens Clothing Store',
710
- 'mobilephonestore'=>'Mobile Phone Store',
711
- 'movierentalstore'=>'Movie Rental Store',
712
- 'musicstore'=>'Music Store',
713
- 'officeequipmentstore'=>'Office Equipment Store',
714
- 'outletstore'=>'Outlet Store',
715
- 'pawnshop'=>'Pawn Shop',
716
- 'petstore'=>'Pet Store',
717
- 'shoestore'=>'Shoe Store',
718
- 'sportinggoodsstore'=>'Sporting Goods Store',
719
- 'tireshop'=>'Tire Shop',
720
- 'toystore'=>'Toy Store',
721
- 'wholesalestore'=>'Wholesale Store'
722
  );
723
  break;
724
  default:
@@ -728,27 +794,33 @@ class saswp_post_specific {
728
  }
729
 
730
  public function saswp_get_fields_by_schema_type( $schema_id ) {
 
731
  global $post;
732
- global $sd_data;
733
- $image_id = get_post_thumbnail_id();
 
734
  $image_details = wp_get_attachment_image_src($image_id, 'full');
 
735
  if(empty($image_details[0]) || $image_details[0] === NULL ){
736
 
737
  if(isset($sd_data['sd_logo'])){
738
  $image_details[0] = $sd_data['sd_logo']['url'];
739
- }
 
740
  }
741
- $current_user = wp_get_current_user();
742
  $author_details = get_avatar_data($current_user->ID);
743
- $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
744
 
745
  $business_type = esc_sql ( get_post_meta($schema_id, 'saswp_business_type', true) );
746
  $business_name = esc_sql ( get_post_meta($schema_id, 'saswp_business_name', true) );
747
  $business_details = esc_sql ( get_post_meta($schema_id, 'saswp_local_business_details', true) );
748
- $dayoftheweek = get_post_meta ($schema_id, 'saswp_dayofweek', true);
749
- $saswp_business_type_key = 'saswp_business_type_'.$schema_id;
750
- $saved_business_type = get_post_meta( $post->ID, $saswp_business_type_key, true );
751
- $saved_saswp_business_name = get_post_meta( $post->ID, 'saswp_business_name_'.$schema_id, true );
 
 
752
  if($saved_business_type){
753
  $business_type = $saved_business_type;
754
  }
@@ -800,57 +872,59 @@ class saswp_post_specific {
800
  }
801
 
802
  if(!empty($this->options_response)){
 
803
  $sub_business_options = array(
804
- 'label' => 'Sub Business Type',
805
- 'id' => 'saswp_business_name_'.$schema_id,
806
- 'type' => 'select',
807
- 'options' => $this->options_response,
808
- 'default' => $business_name
809
  );
 
810
  }
811
 
812
  $meta_field = array(
813
  array(
814
- 'label' => 'Business Type',
815
- 'id' => 'saswp_business_type_'.$schema_id,
816
- 'type' => 'select',
817
  'default' => $business_type,
818
  'options' => array(
819
- 'animalshelter' => 'Animal Shelter',
820
- 'automotivebusiness' => 'Automotive Business',
821
- 'childcare' => 'ChildCare',
822
- 'dentist' => 'Dentist',
823
- 'drycleaningorlaundry' => 'Dry Cleaning Or Laundry',
824
- 'emergencyservice' => 'Emergency Service',
825
- 'employmentagency' => 'Employment Agency',
826
- 'entertainmentbusiness' => 'Entertainment Business',
827
- 'financialservice' => 'Financial Service',
828
- 'foodestablishment' => 'Food Establishment',
829
- 'governmentoffice' => 'Government Office',
830
- 'healthandbeautybusiness' => 'Health And Beauty Business',
831
- 'homeandconstructionbusiness' => 'Home And Construction Business',
832
- 'internetcafe' => 'Internet Cafe',
833
- 'legalservice' => 'Legal Service',
834
- 'library' => 'Library',
835
- 'lodgingbusiness' => 'Lodging Business',
836
- 'professionalservice' => 'Professional Service',
837
- 'radiostation' => 'Radio Station',
838
- 'realestateagent' => 'Real Estate Agent',
839
- 'recyclingcenter' => 'Recycling Center',
840
- 'selfstorage' => 'Self Storage',
841
- 'shoppingcenter' => 'Shopping Center',
842
- 'sportsactivitylocation' => 'Sports Activity Location',
843
- 'store' => 'Store',
844
- 'televisionstation' => 'Television Station',
845
- 'touristinformationcenter' => 'Tourist Information Center',
846
- 'travelagency' => 'Travel Agency',
847
  )
848
  ),
849
  $sub_business_options,
850
  array(
851
- 'label' => 'Business Name',
852
- 'id' => 'local_business_name_'.$schema_id,
853
- 'type' => 'text',
854
  'default' => $business_details['local_business_name']
855
  ),
856
 
@@ -1011,8 +1085,11 @@ class saswp_post_specific {
1011
 
1012
  $category_detail=get_the_category(get_the_ID());//$post->ID
1013
  $article_section = '';
 
1014
  foreach($category_detail as $cd){
 
1015
  $article_section = $cd->cat_name;
 
1016
  }
1017
  $word_count = saswp_reading_time_and_word_count();
1018
 
@@ -1687,15 +1764,36 @@ class saswp_post_specific {
1687
  'id' => 'saswp_service_schema_review_count_'.$schema_id,
1688
  'type' => 'text',
1689
  'default' => saswp_remove_warnings($service_schema_details, 'saswp_service_schema_review_count', 'saswp_string')
1690
- ),
1691
-
1692
-
1693
 
1694
  );
1695
  break;
1696
 
1697
  case 'Review':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1698
  $service_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_review_schema_details', true) );
 
 
 
 
 
 
1699
  $meta_field = array(
1700
  array(
1701
  'label' => 'Item Reviewed Type',
@@ -1703,10 +1801,10 @@ class saswp_post_specific {
1703
  'type' => 'select',
1704
  'options' => array(
1705
  'Article' => 'Article',
1706
- 'adultentertainment' => 'Adult Entertainment',
1707
  'Blog' => 'Blog',
1708
  'Book' => 'Book',
1709
- 'casino' => 'Casino',
1710
  'Diet' => 'Diet',
1711
  'Episode' => 'Episode',
1712
  'ExercisePlan' => 'Exercise Plan',
@@ -1715,96 +1813,16 @@ class saswp_post_specific {
1715
  'MusicPlaylist' => 'Music Playlist',
1716
  'MusicRecording' => 'MusicRecording',
1717
  'Photograph' => 'Photograph',
1718
- 'Recipe' => 'Recipe',
1719
  'Restaurant' => 'Restaurant',
1720
  'Series' => 'Series',
1721
- 'SoftwareApplication' => 'Software Application',
1722
  'VisualArtwork' => 'Visual Artwork',
1723
  'Webpage' => 'Webpage',
1724
  'WebSite' => 'WebSite',
1725
  ),
1726
  'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_item_type', 'saswp_string')
1727
- ),
1728
- array(
1729
- 'label' => 'Name',
1730
- 'id' => 'saswp_review_schema_name_'.$schema_id,
1731
- 'type' => 'text',
1732
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_name', 'saswp_string')
1733
- ),
1734
- array(
1735
- 'label' => 'Review Body',
1736
- 'id' => 'saswp_review_schema_description_'.$schema_id,
1737
- 'type' => 'textarea',
1738
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_description', 'saswp_string')
1739
- ),
1740
- array(
1741
- 'label' => 'Date Published',
1742
- 'id' => 'saswp_review_schema_date_published_'.$schema_id,
1743
- 'type' => 'text',
1744
- 'default' => get_the_date("Y-m-d")
1745
- ),
1746
- array(
1747
- 'label' => 'Date Modified',
1748
- 'id' => 'saswp_review_schema_date_modified_'.$schema_id,
1749
- 'type' => 'text',
1750
- 'default' => get_the_modified_date("Y-m-d")
1751
- ),
1752
- array(
1753
- 'label' => 'Image',
1754
- 'id' => 'saswp_review_schema_image_'.$schema_id,
1755
- 'type' => 'media',
1756
- 'default' => $service_schema_details['saswp_review_schema_image']['url']
1757
- ),
1758
- array(
1759
- 'label' => 'Author',
1760
- 'id' => 'saswp_review_schema_author_'.$schema_id,
1761
- 'type' => 'text',
1762
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_author', 'saswp_string')
1763
- ),
1764
- array(
1765
- 'label' => 'Price Range',
1766
- 'id' => 'saswp_review_schema_price_range_'.$schema_id,
1767
- 'type' => 'text',
1768
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_price_range', 'saswp_string')
1769
- ),
1770
- array(
1771
- 'label' => 'Street Address',
1772
- 'id' => 'saswp_review_schema_street_address_'.$schema_id,
1773
- 'type' => 'text',
1774
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_street_address', 'saswp_string')
1775
- ),
1776
- array(
1777
- 'label' => 'Address Locality',
1778
- 'id' => 'saswp_review_schema_locality_'.$schema_id,
1779
- 'type' => 'text',
1780
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_locality', 'saswp_string')
1781
- ),
1782
- array(
1783
- 'label' => 'Address Region',
1784
- 'id' => 'saswp_review_schema_region_'.$schema_id,
1785
- 'type' => 'text',
1786
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_region', 'saswp_string')
1787
- ),
1788
- array(
1789
- 'label' => 'Postal Code',
1790
- 'id' => 'saswp_review_schema_postal_code_'.$schema_id,
1791
- 'type' => 'text',
1792
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_postal_code', 'saswp_string')
1793
- ),
1794
- array(
1795
- 'label' => 'Address Country',
1796
- 'id' => 'saswp_review_schema_country_'.$schema_id,
1797
- 'type' => 'text',
1798
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_country', 'saswp_string'),
1799
- ),
1800
- array(
1801
- 'label' => 'Telephone',
1802
- 'id' => 'saswp_review_schema_telephone_'.$schema_id,
1803
- 'type' => 'text',
1804
- 'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_telephone', 'saswp_string'),
1805
-
1806
- ),
1807
-
1808
  array(
1809
  'label' => 'Review Rating',
1810
  'id' => 'saswp_review_schema_enable_rating_'.$schema_id,
@@ -1826,9 +1844,11 @@ class saswp_post_specific {
1826
 
1827
 
1828
  );
 
1829
  break;
1830
 
1831
  case 'AudioObject':
 
1832
  $service_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_audio_schema_details', true) );
1833
  $meta_field = array(
1834
 
@@ -1968,6 +1988,7 @@ class saswp_post_specific {
1968
  break;
1969
 
1970
  case 'qanda':
 
1971
  $meta_field = array(
1972
  array(
1973
  'label' => 'Question Title',
1
  <?php
2
  class saswp_post_specific {
3
+
4
+ private $screen = array();
5
+ private $meta_fields = array();
6
+ protected $all_schema = null;
7
+ protected $options_response = array();
 
8
  protected $modify_schema_post_enable = false;
9
+
10
+ public function __construct() {
11
+
12
  }
13
+
14
  public function saswp_post_specific_hooks(){
15
+
16
  $this->saswp_get_all_schema_list();
17
  add_action( 'add_meta_boxes', array( $this, 'saswp_post_specifc_add_meta_boxes' ) );
18
  add_action( 'save_post', array( $this, 'saswp_post_specific_save_fields' ) );
23
  add_action( 'wp_ajax_saswp_restore_schema', array($this,'saswp_restore_schema'));
24
 
25
  add_action( 'wp_ajax_saswp_enable_disable_schema_on_post', array($this,'saswp_enable_disable_schema_on_post'));
26
+
27
  }
28
  public function saswp_enable_disable_schema_on_post(){
29
 
33
  if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
34
  return;
35
  }
36
+
37
  $schema_enable = array();
38
+ $post_id = sanitize_text_field($_POST['post_id']);
39
+ $schema_id = sanitize_text_field($_POST['schema_id']);
40
+ $status = sanitize_text_field($_POST['status']);
41
 
42
  $schema_enable = get_post_meta($post_id, 'saswp_enable_disable_schema', true);
43
+
44
  $schema_enable[$schema_id] = $status;
45
  update_post_meta( $post_id, 'saswp_enable_disable_schema', $schema_enable);
46
+
47
  echo json_encode(array('status'=>'t'));
48
  wp_die();
49
 
97
  }
98
  }
99
 
100
+ public function saswp_post_meta_box_fields($post){
101
+
102
+ $tabs = '';
103
+ $tabs_fields = '';
104
+ $schema_ids = array();
105
 
106
  $schema_enable = get_post_meta($post->ID, 'saswp_enable_disable_schema', true);
107
 
108
+ if(count($this->all_schema)>1){
109
+
110
  foreach($this->all_schema as $key => $schema){
111
 
112
  $checked = '';
113
+
114
  if(isset($schema_enable[$schema->ID]) && $schema_enable[$schema->ID] == 1){
115
+
116
  $checked = 'checked';
117
+
118
  }
119
  $response = $this->saswp_get_fields_by_schema_type($schema->ID);
120
  $this->meta_fields = $response;
121
+
122
+ $output = $this->saswp_saswp_post_specific( $post, $schema->ID );
123
  $schema_type = esc_sql ( get_post_meta($schema->ID, 'schema_type', true) );
124
+
125
  if($key==0){
126
+
127
  $tabs .='<li class="selected"><a saswp-schema-type="'.$schema_type.'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links selected">'.esc_attr($schema->post_title).'</a>'
128
  . '<label class="saswp-switch">'
129
  . '<input type="checkbox" class="saswp-schema-type-toggle" value="1" data-schema-id="'.esc_attr($schema->ID).'" data-post-id="'.esc_attr($post->ID).'" '.$checked.'>'
130
  . '<span class="saswp-slider"></span>'
131
  . '</li>';
132
+
133
  $tabs_fields .= '<div data-id="'.esc_attr($schema->ID).'" id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-post-specific-wrapper">';
134
  $tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
135
  $tabs_fields .= '</div>';
136
+
137
  }else{
138
+
139
  $tabs .='<li>'
140
  . '<a saswp-schema-type="'.$schema_type.'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links">'.esc_attr($schema->post_title).'</a>'
141
  . '<label class="saswp-switch">'
147
  $tabs_fields .= '</div>';
148
 
149
  }
150
+
151
  $schema_ids[] =$schema->ID;
152
  }
153
 
167
  }else{
168
 
169
  $all_schema = $this->all_schema;
170
+ $response = $this->saswp_get_fields_by_schema_type($all_schema[0]->ID);
171
 
172
  $schema_ids[] =$all_schema[0]->ID;
173
  $schema_type = esc_sql ( get_post_meta($all_schema[0]->ID, 'schema_type', true) );
193
  }
194
  }
195
 
196
+ public function saswp_post_meta_box_callback() {
197
+
198
  wp_nonce_field( 'post_specific_data', 'post_specific_nonce' );
199
  global $post;
200
  $option = get_option('modify_schema_post_enable_'.$post->ID);
201
+
202
  if($option == 'enable'){
203
+
204
+ $this->saswp_post_meta_box_fields($post);
205
+
206
  }else{
207
+
208
  echo '<a class="button saswp-modify_schema_post_enable">Modify Schema</a>' ;
209
+
210
  }
211
 
212
  }
213
 
214
  public function saswp_restore_schema(){
215
+
216
  if ( ! isset( $_POST['saswp_security_nonce'] ) ){
217
  return;
218
  }
219
  if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
220
  return;
221
  }
222
+ $result = '';
223
+ $post_id = sanitize_text_field($_POST['post_id']);
224
  $schema_ids = $_POST['schema_ids'];
225
+
226
  foreach($schema_ids as $id){
227
+
228
  $meta_field = $this->saswp_get_fields_by_schema_type($id);
229
+
230
  foreach($meta_field as $field){
231
+
232
+ $result = delete_post_meta($post_id, $field['id']);
233
+
234
+ }
235
+
236
+ }
237
+
238
  update_option('modify_schema_post_enable_'.$post_id, 'disable');
239
+
240
  if($result){
241
  echo json_encode(array('status'=> 't', 'msg'=>esc_html__( 'Schema has been restored', 'schema-and-structured-data-for-wp' )));
242
  }else{
246
  }
247
 
248
  public function saswp_modify_schema_post_enable(){
249
+
250
  if ( ! isset( $_GET['saswp_security_nonce'] ) ){
251
+ return;
252
  }
253
  if ( !wp_verify_nonce( $_GET['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
254
  return;
255
  }
256
 
257
  $post_id = sanitize_text_field($_GET['post_id']);
258
+ update_option('modify_schema_post_enable_'.$post_id, 'enable');
259
+
260
  $args = array(
261
  'p' => $post_id, // ID of a page, post, or custom type
262
  'post_type' => 'any'
263
  );
264
+
265
  $my_posts = new WP_Query($args);
266
+
267
  if ( $my_posts->have_posts() ) {
268
+
269
+ while ( $my_posts->have_posts() ) : $my_posts->the_post();
270
+
271
+ echo $this->saswp_post_meta_box_callback();
272
+
273
  endwhile;
274
+
275
  }
276
 
277
  wp_die();
278
+
279
  }
280
 
281
  public function saswp_saswp_post_specific( $post, $schema_id ) {
282
 
283
  global $post;
284
  global $sd_data;
285
+ $image_id = get_post_thumbnail_id();
286
  $image_details = wp_get_attachment_image_src($image_id, 'full');
287
+
288
  if(empty($image_details[0]) || $image_details[0] === NULL ){
289
 
290
  if(isset($sd_data['sd_logo'])){
292
  }
293
 
294
  }
295
+
296
+ $current_user = wp_get_current_user();
297
  $author_details = get_avatar_data($current_user->ID);
298
+ $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
299
  $output = '';
300
+
301
  $this->meta_fields = array_filter($this->meta_fields);
302
+
303
  foreach ( $this->meta_fields as $meta_field ) {
304
+
305
+ $input ='';
306
  $attributes ='';
307
 
308
+ $label = '<label for="' . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
309
  $meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
310
+
311
  if ( empty( $meta_value ) && isset($meta_field['default'])) {
312
 
313
  $meta_value = $meta_field['default'];
321
  switch ( $meta_field['type'] ) {
322
  case 'media':
323
  $media_value = array();
324
+ $media_key = $meta_field['id'].'_detail';
325
  $media_value_meta = get_post_meta( $post->ID, $media_key, true );
326
  if(!empty($media_value_meta)){
327
  $media_value =$media_value_meta;
429
  if (strpos($meta_field['id'], 'business_name') !== false){
430
  $class='saswp-local-business-name-select';
431
  }
432
+ if (strpos($meta_field['id'], 'saswp_review_schema_item_type') !== false){
433
+ $class='saswp-item-reviewed';
434
+ }
435
 
436
  $input = sprintf(
437
+ '<select post-specific="1" data-id="'.$schema_id.'" class="%s" id="%s" name="%s">',
438
  $class,
439
  $meta_field['id'],
440
  $meta_field['id']
554
  )
555
  {
556
  $output .= '<tr class="saswp-rating-review-'.strtolower($schema_type).'"><th>'.$label.'</th><td>'.$input.'</td></tr>';
557
+ }else if($schema_type == 'Review' && $meta_field['id'] != 'saswp_review_schema_enable_rating_'.$schema_id) {
558
+
559
+ $output .= '<tr class="saswp-review-tr"><th>'.$label.'</th><td>'.$input.'</td></tr>';
560
+
561
  }else{
562
  $output .= '<tr><th>'.$label.'</th><td>'.$input.'</td></tr>';
563
  }
566
  return $output;
567
  }
568
  public function saswp_post_specific_save_fields( $post_id ) {
569
+
570
  if ( ! isset( $_POST['post_specific_nonce'] ) )
571
  return $post_id;
572
  $nonce = $_POST['post_specific_nonce'];
576
  return $post_id;
577
 
578
  $option = get_option('modify_schema_post_enable_'.$post_id);
579
+
580
  if($option != 'enable'){
581
  return;
582
+ }
583
+
584
+
585
+
586
  if(count($this->all_schema)>0){
587
+
588
  foreach($this->all_schema as $schema){
589
+
590
+ $response = $this->saswp_get_fields_by_schema_type($schema->ID);
591
+ $this->meta_fields = $response;
592
+
593
  foreach ( $this->meta_fields as $meta_field ) {
594
+
595
  if ( isset( $_POST[ $meta_field['id'] ] ) ) {
596
+
597
  switch ( $meta_field['type'] ) {
598
+
599
  case 'media':
600
+ $media_key = $meta_field['id'].'_detail';
601
+ $media_height = sanitize_text_field( $_POST[ $meta_field['id'].'_height' ] );
602
+ $media_width = sanitize_text_field( $_POST[ $meta_field['id'].'_width' ] );
 
603
  $media_thumbnail = sanitize_text_field( $_POST[ $meta_field['id'].'_thumbnail' ] );
604
+ $media_detail = array(
 
605
  'height' =>$media_height,
606
  'width' =>$media_width,
607
  'thumbnail' =>$media_thumbnail,
608
+ );
 
609
  update_post_meta( $post_id, $media_key, $media_detail);
610
  break;
611
  case 'email':
614
  case 'text':
615
  $_POST[ $meta_field['id'] ] = sanitize_text_field( $_POST[ $meta_field['id'] ] );
616
  break;
617
+
618
  }
619
  update_post_meta( $post_id, $meta_field['id'], $_POST[ $meta_field['id'] ] );
620
  } else if ( $meta_field['type'] === 'checkbox' ) {
645
  wp_die();
646
  }
647
  public function saswp_get_sub_business_array($business_type){
648
+
649
  $sub_business_options = array();
650
+
651
  switch ($business_type) {
652
  case 'automotivebusiness':
653
  $sub_business_options = array(
654
+ 'autobodyshop' => 'Auto Body Shop',
655
+ 'autodealer' => 'Auto Dealer',
656
+ 'autopartsstore' => 'Auto Parts Store',
657
+ 'autorental' => 'Auto Rental',
658
+ 'autorepair' => 'Auto Repair',
659
+ 'autowash' => 'Auto Wash',
660
+ 'gasstation' => 'Gas Station',
661
+ 'motorcycledealer' => 'Motorcycle Dealer',
662
+ 'motorcyclerepair' => 'Motorcycle Repair'
663
  );
664
  break;
665
  case 'emergencyservice':
666
  $sub_business_options = array(
667
+ 'firestation' => 'Fire Station',
668
+ 'hospital' => 'Hospital',
669
+ 'policestation' => 'Police Station',
670
  );
671
  break;
672
  case 'entertainmentbusiness':
673
  $sub_business_options = array(
674
  'adultentertainment' => 'Adult Entertainment',
675
+ 'amusementpark' => 'Amusement Park',
676
+ 'artgallery' => 'Art Gallery',
677
+ 'casino' => 'Casino',
678
+ 'comedyclub' => 'Comedy Club',
679
+ 'movietheater' => 'Movie Theater',
680
+ 'nightclub' => 'Night Club',
681
 
682
  );
683
  break;
684
  case 'financialservice':
685
  $sub_business_options = array(
686
+ 'accountingservice' => 'Accounting Service',
687
+ 'automatedteller' => 'Automated Teller',
688
+ 'bankorcredit_union' => 'Bank Or Credit Union',
689
+ 'insuranceagency' => 'Insurance Agency',
690
 
691
  );
692
  break;
693
  case 'foodestablishment':
694
  $sub_business_options = array(
695
+ 'bakery' => 'Bakery',
696
+ 'barorpub' => 'Bar Or Pub',
697
+ 'brewery' => 'Brewery',
698
+ 'cafeorcoffee_shop' => 'Cafe Or Coffee Shop',
699
  'fastfoodrestaurant' => 'Fast Food Restaurant',
700
+ 'icecreamshop' => 'Ice Cream Shop',
701
+ 'restaurant' => 'Restaurant',
702
+ 'winery' => 'Winery',
703
 
704
  );
705
  break;
706
  case 'healthandbeautybusiness':
707
  $sub_business_options = array(
708
+ 'beautysalon' => 'Beauty Salon',
709
+ 'dayspa' => 'DaySpa',
710
+ 'hairsalon' => 'Hair Salon',
711
+ 'healthclub' => 'Health Club',
712
+ 'nailsalon' => 'Nail Salon',
713
  'tattooparlor' => 'Tattoo Parlor',
714
  );
715
  break;
716
  case 'homeandconstructionbusiness':
717
  $sub_business_options = array(
718
+ 'electrician' => 'Electrician',
719
  'generalcontractor' => 'General Contractor',
720
+ 'hvacbusiness' => 'HVAC Business',
721
+ 'locksmith' => 'Locksmith',
722
+ 'movingcompany' => 'Moving Company',
723
+ 'plumber' => 'Plumber',
724
  'roofingcontractor' => 'Roofing Contractor',
725
  );
726
  break;
727
  case 'legalservice':
728
  $sub_business_options = array(
729
  'attorney' => 'Attorney',
730
+ 'notary' => 'Notary',
731
  );
732
  break;
733
  case 'lodgingbusiness':
734
  $sub_business_options = array(
735
  'bedandbreakfast' => 'Bed And Breakfast',
736
+ 'campground' => 'Campground',
737
+ 'hostel' => 'Hostel',
738
+ 'hotel' => 'Hotel',
739
+ 'motel' => 'Motel',
740
+ 'resort' => 'Resort',
741
  );
742
  break;
743
  case 'sportsactivitylocation':
744
  $sub_business_options = array(
745
+ 'bowlingalley' => 'Bowling Alley',
746
+ 'exercisegym' => 'Exercise Gym',
747
+ 'golfcourse' => 'Golf Course',
748
+ 'healthclub' => 'Health Club',
749
  'publicswimming_pool' => 'Public Swimming Pool',
750
+ 'skiresort' => 'Ski Resort',
751
+ 'sportsclub' => 'Sports Club',
752
+ 'stadiumorarena' => 'Stadium Or Arena',
753
+ 'tenniscomplex' => 'Tennis Complex'
754
  );
755
  break;
756
  case 'store':
757
  $sub_business_options = array(
758
+ 'autopartsstore' => 'Auto Parts Store',
759
+ 'bikestore' => 'Bike Store',
760
+ 'bookstore' => 'Book Store',
761
+ 'clothingstore' => 'Clothing Store',
762
+ 'computerstore' => 'Computer Store',
763
+ 'conveniencestore' => 'Convenience Store',
764
+ 'departmentstore' => 'Department Store',
765
+ 'electronicsstore' => 'Electronics Store',
766
+ 'florist' => 'Florist',
767
+ 'furniturestore' => 'Furniture Store',
768
+ 'gardenstore' => 'Garden Store',
769
+ 'grocerystore' => 'Grocery Store',
770
+ 'hardwarestore' => 'Hardware Store',
771
+ 'hobbyshop' => 'Hobby Shop',
772
+ 'homegoodsstore' => 'HomeGoods Store',
773
+ 'jewelrystore' => 'Jewelry Store',
774
+ 'liquorstore' => 'Liquor Store',
775
+ 'mensclothingstore' => 'Mens Clothing Store',
776
+ 'mobilephonestore' => 'Mobile Phone Store',
777
+ 'movierentalstore' => 'Movie Rental Store',
778
+ 'musicstore' => 'Music Store',
779
+ 'officeequipmentstore' => 'Office Equipment Store',
780
+ 'outletstore' => 'Outlet Store',
781
+ 'pawnshop' => 'Pawn Shop',
782
+ 'petstore' => 'Pet Store',
783
+ 'shoestore' => 'Shoe Store',
784
+ 'sportinggoodsstore' => 'Sporting Goods Store',
785
+ 'tireshop' => 'Tire Shop',
786
+ 'toystore' => 'Toy Store',
787
+ 'wholesalestore' => 'Wholesale Store'
788
  );
789
  break;
790
  default:
794
  }
795
 
796
  public function saswp_get_fields_by_schema_type( $schema_id ) {
797
+
798
  global $post;
799
+ global $sd_data;
800
+
801
+ $image_id = get_post_thumbnail_id();
802
  $image_details = wp_get_attachment_image_src($image_id, 'full');
803
+
804
  if(empty($image_details[0]) || $image_details[0] === NULL ){
805
 
806
  if(isset($sd_data['sd_logo'])){
807
  $image_details[0] = $sd_data['sd_logo']['url'];
808
+ }
809
+
810
  }
811
+ $current_user = wp_get_current_user();
812
  $author_details = get_avatar_data($current_user->ID);
813
+ $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
814
 
815
  $business_type = esc_sql ( get_post_meta($schema_id, 'saswp_business_type', true) );
816
  $business_name = esc_sql ( get_post_meta($schema_id, 'saswp_business_name', true) );
817
  $business_details = esc_sql ( get_post_meta($schema_id, 'saswp_local_business_details', true) );
818
+ $dayoftheweek = get_post_meta ($schema_id, 'saswp_dayofweek', true);
819
+
820
+ $saswp_business_type_key = 'saswp_business_type_'.$schema_id;
821
+ $saved_business_type = get_post_meta( $post->ID, $saswp_business_type_key, true );
822
+ $saved_saswp_business_name = get_post_meta( $post->ID, 'saswp_business_name_'.$schema_id, true );
823
+
824
  if($saved_business_type){
825
  $business_type = $saved_business_type;
826
  }
872
  }
873
 
874
  if(!empty($this->options_response)){
875
+
876
  $sub_business_options = array(
877
+ 'label' => 'Sub Business Type',
878
+ 'id' => 'saswp_business_name_'.$schema_id,
879
+ 'type' => 'select',
880
+ 'options' => $this->options_response,
881
+ 'default' => $business_name
882
  );
883
+
884
  }
885
 
886
  $meta_field = array(
887
  array(
888
+ 'label' => 'Business Type',
889
+ 'id' => 'saswp_business_type_'.$schema_id,
890
+ 'type' => 'select',
891
  'default' => $business_type,
892
  'options' => array(
893
+ 'animalshelter' => 'Animal Shelter',
894
+ 'automotivebusiness' => 'Automotive Business',
895
+ 'childcare' => 'ChildCare',
896
+ 'dentist' => 'Dentist',
897
+ 'drycleaningorlaundry' => 'Dry Cleaning Or Laundry',
898
+ 'emergencyservice' => 'Emergency Service',
899
+ 'employmentagency' => 'Employment Agency',
900
+ 'entertainmentbusiness' => 'Entertainment Business',
901
+ 'financialservice' => 'Financial Service',
902
+ 'foodestablishment' => 'Food Establishment',
903
+ 'governmentoffice' => 'Government Office',
904
+ 'healthandbeautybusiness' => 'Health And Beauty Business',
905
+ 'homeandconstructionbusiness' => 'Home And Construction Business',
906
+ 'internetcafe' => 'Internet Cafe',
907
+ 'legalservice' => 'Legal Service',
908
+ 'library' => 'Library',
909
+ 'lodgingbusiness' => 'Lodging Business',
910
+ 'professionalservice' => 'Professional Service',
911
+ 'radiostation' => 'Radio Station',
912
+ 'realestateagent' => 'Real Estate Agent',
913
+ 'recyclingcenter' => 'Recycling Center',
914
+ 'selfstorage' => 'Self Storage',
915
+ 'shoppingcenter' => 'Shopping Center',
916
+ 'sportsactivitylocation' => 'Sports Activity Location',
917
+ 'store' => 'Store',
918
+ 'televisionstation' => 'Television Station',
919
+ 'touristinformationcenter' => 'Tourist Information Center',
920
+ 'travelagency' => 'Travel Agency',
921
  )
922
  ),
923
  $sub_business_options,
924
  array(
925
+ 'label' => 'Business Name',
926
+ 'id' => 'local_business_name_'.$schema_id,
927
+ 'type' => 'text',
928
  'default' => $business_details['local_business_name']
929
  ),
930
 
1085
 
1086
  $category_detail=get_the_category(get_the_ID());//$post->ID
1087
  $article_section = '';
1088
+
1089
  foreach($category_detail as $cd){
1090
+
1091
  $article_section = $cd->cat_name;
1092
+
1093
  }
1094
  $word_count = saswp_reading_time_and_word_count();
1095
 
1764
  'id' => 'saswp_service_schema_review_count_'.$schema_id,
1765
  'type' => 'text',
1766
  'default' => saswp_remove_warnings($service_schema_details, 'saswp_service_schema_review_count', 'saswp_string')
1767
+ ),
 
 
1768
 
1769
  );
1770
  break;
1771
 
1772
  case 'Review':
1773
+
1774
+
1775
+ if(isset($_POST['saswp_review_schema_item_type_'.$schema_id])){
1776
+
1777
+ $reviewed_field = item_reviewed_fields(sanitize_text_field($_POST['saswp_review_schema_item_type_'.$schema_id]), $post_specific=1, $schema_id);
1778
+
1779
+
1780
+ }else{
1781
+
1782
+ $item_type_by_post = esc_sql ( get_post_meta($post->ID, 'saswp_review_schema_item_type_'.$schema_id, true) );
1783
+
1784
+ if($item_type_by_post){
1785
+
1786
+ $reviewed_field = item_reviewed_fields($item_type_by_post, $post_specific=1, $schema_id);
1787
+
1788
+ }else{
1789
+
1790
  $service_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_review_schema_details', true) );
1791
+ $reviewed_field = item_reviewed_fields($service_schema_details['saswp_review_schema_item_type'], $post_specific=1, $schema_id);
1792
+
1793
+ }
1794
+
1795
+ }
1796
+
1797
  $meta_field = array(
1798
  array(
1799
  'label' => 'Item Reviewed Type',
1801
  'type' => 'select',
1802
  'options' => array(
1803
  'Article' => 'Article',
1804
+ 'Adultentertainment' => 'Adult Entertainment',
1805
  'Blog' => 'Blog',
1806
  'Book' => 'Book',
1807
+ 'Casino' => 'Casino',
1808
  'Diet' => 'Diet',
1809
  'Episode' => 'Episode',
1810
  'ExercisePlan' => 'Exercise Plan',
1813
  'MusicPlaylist' => 'Music Playlist',
1814
  'MusicRecording' => 'MusicRecording',
1815
  'Photograph' => 'Photograph',
1816
+ //'Recipe' => 'Recipe',
1817
  'Restaurant' => 'Restaurant',
1818
  'Series' => 'Series',
1819
+ // 'SoftwareApplication' => 'Software Application',
1820
  'VisualArtwork' => 'Visual Artwork',
1821
  'Webpage' => 'Webpage',
1822
  'WebSite' => 'WebSite',
1823
  ),
1824
  'default' => saswp_remove_warnings($service_schema_details, 'saswp_review_schema_item_type', 'saswp_string')
1825
+ ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1826
  array(
1827
  'label' => 'Review Rating',
1828
  'id' => 'saswp_review_schema_enable_rating_'.$schema_id,
1844
 
1845
 
1846
  );
1847
+ $meta_field = array_merge($meta_field, $reviewed_field);
1848
  break;
1849
 
1850
  case 'AudioObject':
1851
+
1852
  $service_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_audio_schema_details', true) );
1853
  $meta_field = array(
1854
 
1988
  break;
1989
 
1990
  case 'qanda':
1991
+
1992
  $meta_field = array(
1993
  array(
1994
  'label' => 'Question Title',
view/review.php CHANGED
@@ -7,11 +7,15 @@ class saswp_metaboxes_review {
7
  add_action( 'save_post', array( $this, 'saswp_review_save' ) );
8
  }
9
  function saswp_review_add_meta_box($post) {
10
- global $sd_data;
 
11
 
12
  $review_post_id = '';
 
13
  if(is_object($post)){
 
14
  $review_post_id = $post->ID;
 
15
  }
16
 
17
  if(get_post_status($review_post_id)=='publish' && saswp_remove_warnings($sd_data, 'saswp-review-module', 'saswp_string')==1){
@@ -23,12 +27,12 @@ class saswp_metaboxes_review {
23
  foreach ( $this->screen as $single_screen ) {
24
 
25
  add_meta_box(
26
- 'sasw-review',
27
- esc_html__( 'Review', 'schema-and-structured-data-for-wp' ),
28
- array( $this, 'saswp_meta_box_callback' ),
29
- $single_screen,
30
- 'advanced',
31
- 'default'
32
  );
33
 
34
  }
@@ -36,6 +40,7 @@ class saswp_metaboxes_review {
36
  }
37
  }
38
  function saswp_review_get_meta( $value ) {
 
39
  global $post;
40
 
41
  $field = get_post_meta( $post->ID, $value, true );
@@ -166,6 +171,7 @@ class saswp_metaboxes_review {
166
  }
167
 
168
  function saswp_review_save( $post_id ) {
 
169
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
170
  if ( ! isset( $_POST['saswp_review_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_review_nonce'], 'saswp_review_nonce' ) ) return;
171
  if ( ! current_user_can( 'edit_post', $post_id ) ) return;
7
  add_action( 'save_post', array( $this, 'saswp_review_save' ) );
8
  }
9
  function saswp_review_add_meta_box($post) {
10
+
11
+ global $sd_data;
12
 
13
  $review_post_id = '';
14
+
15
  if(is_object($post)){
16
+
17
  $review_post_id = $post->ID;
18
+
19
  }
20
 
21
  if(get_post_status($review_post_id)=='publish' && saswp_remove_warnings($sd_data, 'saswp-review-module', 'saswp_string')==1){
27
  foreach ( $this->screen as $single_screen ) {
28
 
29
  add_meta_box(
30
+ 'sasw-review',
31
+ esc_html__( 'Review', 'schema-and-structured-data-for-wp' ),
32
+ array( $this, 'saswp_meta_box_callback' ),
33
+ $single_screen,
34
+ 'advanced',
35
+ 'default'
36
  );
37
 
38
  }
40
  }
41
  }
42
  function saswp_review_get_meta( $value ) {
43
+
44
  global $post;
45
 
46
  $field = get_post_meta( $post->ID, $value, true );
171
  }
172
 
173
  function saswp_review_save( $post_id ) {
174
+
175
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
176
  if ( ! isset( $_POST['saswp_review_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_review_nonce'], 'saswp_review_nonce' ) ) return;
177
  if ( ! current_user_can( 'edit_post', $post_id ) ) return;
view/schema_type.php CHANGED
@@ -1,18 +1,504 @@
1
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  add_action( 'add_meta_boxes', 'saswp_schema_type_add_meta_box' ) ;
3
  add_action( 'save_post', 'saswp_schema_type_add_meta_box_save' ) ;
4
 
5
  function saswp_schema_type_add_meta_box() {
 
6
  add_meta_box(
7
  'schema_type',
8
- esc_html__( 'Schema Type', 'ads-for-wp' ),
9
  'saswp_schema_type_meta_box_callback',
10
  'saswp',
11
  'advanced',
12
  'high'
13
  );
 
14
  }
15
  function saswp_schema_type_get_meta( $value ) {
 
16
  global $post;
17
 
18
  $field = get_post_meta( $post->ID, $value, true );
@@ -24,38 +510,79 @@
24
  }
25
  }
26
  function saswp_schema_type_meta_box_callback( $post) {
 
27
  wp_nonce_field( 'saswp_schema_type_nonce', 'saswp_schema_type_nonce' );
28
- $style_business_type ='';
29
- $style_business_name ='';
30
- $style_service_name ='';
31
- $style_review_name ='';
32
- $business_name ='';
33
- $schema_type ='';
34
- $business_type ='';
35
- $business_details ='';
36
- $custom_logo_id ='';
37
- $logo = array();
38
- $service_details = array();
39
- $review_details = array();
40
- $product_details = array();
 
 
41
  if($post){
42
- $schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
43
- $business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
44
- $business_name = esc_sql ( get_post_meta($post->ID, 'saswp_business_name', true) );
45
- $business_details = esc_sql ( get_post_meta($post->ID, 'saswp_local_business_details', true) );
46
- $service_details = esc_sql ( get_post_meta($post->ID, 'saswp_service_schema_details', true) );
47
- $review_details = esc_sql ( get_post_meta($post->ID, 'saswp_review_schema_details', true) );
48
- $product_details = esc_sql ( get_post_meta($post->ID, 'saswp_product_schema_details', true) );
49
- $audio_details = esc_sql ( get_post_meta($post->ID, 'saswp_audio_schema_details', true) );
50
- $dayoftheweek = get_post_meta($post->ID, 'saswp_dayofweek', true);
51
- $custom_logo_id = get_theme_mod( 'custom_logo' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  if($custom_logo_id){
53
- $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
 
 
54
  }
55
 
56
  if($schema_type != 'local_business'){
57
- $style_business_type = 'style="display:none"';
58
- $style_business_name = 'style="display:none"';
 
 
59
  }
60
  }
61
 
@@ -87,10 +614,10 @@
87
 
88
  $item_reviewed = array(
89
  'Article' => 'Article',
90
- 'adultentertainment' => 'Adult Entertainment',
91
  'Blog' => 'Blog',
92
  'Book' => 'Book',
93
- 'casino' => 'Casino',
94
  'Diet' => 'Diet',
95
  'Episode' => 'Episode',
96
  'ExercisePlan' => 'Exercise Plan',
@@ -99,181 +626,181 @@
99
  'MusicPlaylist' => 'Music Playlist',
100
  'MusicRecording' => 'MusicRecording',
101
  'Photograph' => 'Photograph',
102
- 'Recipe' => 'Recipe',
103
  'Restaurant' => 'Restaurant',
104
  'Series' => 'Series',
105
- 'SoftwareApplication' => 'Software Application',
106
  'VisualArtwork' => 'Visual Artwork',
107
- 'Webpage' => 'Webpage',
108
  'WebSite' => 'WebSite',
109
  );
110
 
111
  $all_schema_array = array(
112
- 'Article' => 'Article',
113
- 'AudioObject' => 'AudioObject',
114
- 'Blogposting' => 'Blogposting',
115
- 'local_business' => 'Local Business',
116
- 'NewsArticle' => 'NewsArticle',
117
- 'Product' => 'Product',
118
- 'qanda' => 'Q&A',
119
- 'Review' => 'Review',
120
- 'Recipe' => 'Recipe',
121
- 'Service' => 'Service',
122
- 'VideoObject' => 'VideoObject',
123
- 'WebPage' => 'WebPage'
124
  );
125
  $all_business_type = array(
126
- 'animalshelter' => 'Animal Shelter',
127
- 'automotivebusiness' => 'Automotive Business',
128
- 'childcare' => 'ChildCare',
129
- 'dentist' => 'Dentist',
130
- 'drycleaningorlaundry' => 'Dry Cleaning Or Laundry',
131
- 'emergencyservice' => 'Emergency Service',
132
- 'employmentagency' => 'Employment Agency',
133
- 'entertainmentbusiness' => 'Entertainment Business',
134
- 'financialservice' => 'Financial Service',
135
- 'foodestablishment' => 'Food Establishment',
136
- 'governmentoffice' => 'Government Office',
137
- 'healthandbeautybusiness' => 'Health And Beauty Business',
138
- 'homeandconstructionbusiness' => 'Home And Construction Business',
139
- 'internetcafe' => 'Internet Cafe',
140
- 'legalservice' => 'Legal Service',
141
- 'library' => 'Library',
142
- 'lodgingbusiness' => 'Lodging Business',
143
- 'professionalservice' => 'Professional Service',
144
- 'radiostation' => 'Radio Station',
145
- 'realestateagent' => 'Real Estate Agent',
146
- 'recyclingcenter' => 'Recycling Center',
147
- 'selfstorage' => 'Self Storage',
148
- 'shoppingcenter' => 'Shopping Center',
149
- 'sportsactivitylocation' => 'Sports Activity Location',
150
- 'store' => 'Store',
151
- 'televisionstation' => 'Television Station',
152
- 'touristinformationcenter' => 'Tourist Information Center',
153
- 'travelagency' => 'Travel Agency',
154
  );
155
 
156
  $all_automotive_array = array(
157
- 'autobodyshop' => 'Auto Body Shop',
158
- 'autodealer' => 'Auto Dealer',
159
- 'autopartsstore' => 'Auto Parts Store',
160
- 'autorental' => 'Auto Rental',
161
- 'autorepair' => 'Auto Repair',
162
- 'autowash' => 'Auto Wash',
163
- 'gasstation' => 'Gas Station',
164
  'motorcycledealer' => 'Motorcycle Dealer',
165
  'motorcyclerepair' => 'Motorcycle Repair'
166
  );
167
 
168
  $all_emergency_array = array(
169
- 'firestation' => 'Fire Station',
170
- 'hospital' => 'Hospital',
171
- 'policestation' => 'Police Station',
172
  );
173
  $all_entertainment_array = array(
174
  'adultentertainment' => 'Adult Entertainment',
175
- 'amusementpark' => 'Amusement Park',
176
- 'artgallery' => 'Art Gallery',
177
- 'casino' => 'Casino',
178
- 'comedyclub' => 'Comedy Club',
179
- 'movietheater' => 'Movie Theater',
180
- 'nightclub' => 'Night Club',
181
 
182
  );
183
  $all_financial_array = array(
184
- 'accountingservice' => 'Accounting Service',
185
- 'automatedteller' => 'Automated Teller',
186
- 'bankorcredit_union' => 'Bank Or Credit Union',
187
- 'insuranceagency' => 'Insurance Agency',
188
 
189
  );
190
 
191
  $all_food_establishment_array = array(
192
- 'bakery' => 'Bakery',
193
- 'barorpub' => 'Bar Or Pub',
194
- 'brewery' => 'Brewery',
195
- 'cafeorcoffee_shop' => 'Cafe Or Coffee Shop',
196
  'fastfoodrestaurant' => 'Fast Food Restaurant',
197
- 'icecreamshop' => 'Ice Cream Shop',
198
- 'restaurant' => 'Restaurant',
199
- 'winery' => 'Winery',
200
 
201
  );
202
  $all_health_and_beauty_array = array(
203
- 'beautysalon' => 'Beauty Salon',
204
- 'dayspa' => 'DaySpa',
205
- 'hairsalon' => 'Hair Salon',
206
  'healthclub' => 'Health Club',
207
- 'nailsalon' => 'Nail Salon',
208
- 'tattooparlor' => 'Tattoo Parlor',
209
  );
210
 
211
  $all_home_and_construction_array = array(
212
- 'electrician' => 'Electrician',
213
  'generalcontractor' => 'General Contractor',
214
- 'hvacbusiness' => 'HVAC Business',
215
- 'locksmith' => 'Locksmith',
216
- 'movingcompany' => 'Moving Company',
217
- 'plumber' => 'Plumber',
218
  'roofingcontractor' => 'Roofing Contractor',
219
  );
220
 
221
  $all_legal_service_array = array(
222
  'attorney' => 'Attorney',
223
- 'notary' => 'Notary',
224
  );
225
 
226
  $all_lodging_array = array(
227
  'bedandbreakfast' => 'Bed And Breakfast',
228
- 'campground' => 'Campground',
229
- 'hostel' => 'Hostel',
230
- 'hotel' => 'Hotel',
231
- 'motel' => 'Motel',
232
- 'resort' => 'Resort',
233
  );
234
 
235
  $all_sports_activity_location = array(
236
- 'bowlingalley' => 'Bowling Alley',
237
- 'exercisegym' => 'Exercise Gym',
238
- 'golfcourse' => 'Golf Course',
239
- 'healthclub' => 'Health Club',
240
  'publicswimming_pool' => 'Public Swimming Pool',
241
- 'skiresort' => 'Ski Resort',
242
- 'sportsclub' => 'Sports Club',
243
- 'stadiumorarena' => 'Stadium Or Arena',
244
- 'tenniscomplex' => 'Tennis Complex'
245
  );
246
  $all_store = array(
247
- 'autopartsstore'=>'Auto Parts Store',
248
- 'bikestore'=>'Bike Store',
249
- 'bookstore'=>'Book Store',
250
- 'clothingstore'=>'Clothing Store',
251
- 'computerstore'=>'Computer Store',
252
- 'conveniencestore'=>'Convenience Store',
253
- 'departmentstore'=>'Department Store',
254
- 'electronicsstore'=>'Electronics Store',
255
- 'florist'=>'Florist',
256
- 'furniturestore'=>'Furniture Store',
257
- 'gardenstore'=>'Garden Store',
258
- 'grocerystore'=>'Grocery Store',
259
- 'hardwarestore'=>'Hardware Store',
260
- 'hobbyshop'=>'Hobby Shop',
261
- 'homegoodsstore'=>'HomeGoods Store',
262
- 'jewelrystore'=>'Jewelry Store',
263
- 'liquorstore'=>'Liquor Store',
264
- 'mensclothingstore'=>'Mens Clothing Store',
265
- 'mobilephonestore'=>'Mobile Phone Store',
266
- 'movierentalstore'=>'Movie Rental Store',
267
- 'musicstore'=>'Music Store',
268
- 'officeequipmentstore'=>'Office Equipment Store',
269
- 'outletstore'=>'Outlet Store',
270
- 'pawnshop'=>'Pawn Shop',
271
- 'petstore'=>'Pet Store',
272
- 'shoestore'=>'Shoe Store',
273
- 'sportinggoodsstore'=>'Sporting Goods Store',
274
- 'tireshop'=>'Tire Shop',
275
- 'toystore'=>'Toy Store',
276
- 'wholesalestore'=>'Wholesale Store'
277
  );
278
  ?>
279
  <div class="misc-pub-section">
@@ -543,7 +1070,7 @@
543
  <tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
544
  <td><?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?></td>
545
  <td style="display: flex; width: 97%">
546
- <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_url($business_details['local_business_logo']['url']);} else { echo esc_url(saswp_remove_warnings($logo, 0, 'saswp_string')); } ?>" id="local_business_logo" type="text" name="local_business_logo[url]" placeholder="<?php echo esc_html__('Logo', 'schema-and-structured-data-for-wp' ); ?>" readonly="readonly" style="background: #FFF;">
547
  <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_attr($business_details['local_business_logo']['id']);} else { echo esc_attr($custom_logo_id); }?>" data-id="local_business_logo_id" type="hidden" name="local_business_logo[id]">
548
  <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_attr($business_details['local_business_logo']['width']);} else { echo esc_attr(saswp_remove_warnings($logo, 1, 'saswp_string')); } ?>" data-id="local_business_logo_width" type="hidden" name="local_business_logo[width]">
549
  <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_attr($business_details['local_business_logo']['height']);} else { echo esc_attr(saswp_remove_warnings($logo, 2, 'saswp_string')); } ?>" data-id="local_business_logo_height" type="hidden" name="local_business_logo[height]">
@@ -677,7 +1204,7 @@
677
  <td><?php echo esc_html__('Item Reviewed Type', 'schema-and-structured-data-for-wp' ); ?></td>
678
  <td>
679
 
680
- <select name="saswp_review_schema_item_type">
681
  <?php
682
  foreach ($item_reviewed as $key => $value) {
683
  $sel = '';
@@ -689,58 +1216,7 @@
689
  ?>
690
  </select>
691
  </td>
692
- </tr>
693
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
694
- <td><?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?></td>
695
- <td><input value="<?php if(isset($review_details['saswp_review_schema_name'])){echo esc_attr($review_details['saswp_review_schema_name']); } ?>" type="text" name="saswp_review_schema_name" placeholder="<?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?>" ></td>
696
- </tr>
697
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
698
- <td><?php echo esc_html__('Review Body', 'schema-and-structured-data-for-wp' ); ?></td>
699
- <td><textarea placeholder="Review Body" rows="3" cols="70" name="saswp_review_schema_description"><?php if(isset($review_details['saswp_review_schema_description'])){echo esc_attr($review_details['saswp_review_schema_description']); } ?></textarea></td>
700
- </tr>
701
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
702
- <td><?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?></td>
703
- <td style="display: flex; width: 97%">
704
- <input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_url($review_details['saswp_review_schema_image']['url']);} else { echo esc_url(saswp_remove_warnings($logo, 0, 'saswp_string')); } ?>" id="saswp_review_schema_image" type="text" name="saswp_review_schema_image[url]" placeholder="<?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?>" readonly="readonly" style="background: #FFF;">
705
- <input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_attr($review_details['saswp_review_schema_image']['id']);} else { echo esc_attr($custom_logo_id); }?>" data-id="saswp_review_schema_image_id" type="hidden" name="saswp_review_schema_image[id]">
706
- <input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_attr($review_details['saswp_review_schema_image']['width']);} else { echo esc_attr(saswp_remove_warnings($logo, 1, 'saswp_string')); } ?>" data-id="saswp_review_schema_image_width" type="hidden" name="saswp_review_schema_image[width]">
707
- <input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_attr($review_details['saswp_review_schema_image']['height']);} else { echo esc_attr(saswp_remove_warnings($logo, 2, 'saswp_string')); } ?>" data-id="saswp_review_schema_image_height" type="hidden" name="saswp_review_schema_image[height]">
708
- <input data-id="media" class="button" id="saswp_review_schema_image_button" type="button" value="Upload"></td>
709
- </tr>
710
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
711
- <td><?php echo esc_html__('Author', 'schema-and-structured-data-for-wp' ); ?></td>
712
- <td><input value="<?php if(isset($review_details['saswp_review_schema_author'])){echo esc_attr($review_details['saswp_review_schema_author']); } ?>" type="text" name="saswp_review_schema_author" placeholder="<?php echo esc_html__('Author', 'schema-and-structured-data-for-wp' ); ?>" ></td>
713
- </tr>
714
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
715
- <td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
716
- <td><input value="<?php if(isset($review_details['saswp_review_schema_price_range'])){echo esc_attr($review_details['saswp_review_schema_price_range']); } ?>" type="text" name="saswp_review_schema_price_range" placeholder="<?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?>" ></td>
717
- </tr>
718
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
719
- <td><?php echo esc_html__('Street Address', 'schema-and-structured-data-for-wp' ); ?></td>
720
- <td><input value="<?php if(isset($review_details['saswp_review_schema_street_address'])){echo esc_attr($review_details['saswp_review_schema_street_address']); } ?>" type="text" name="saswp_review_schema_street_address" placeholder="<?php echo esc_html__('Street Address', 'schema-and-structured-data-for-wp' ); ?>" ></td>
721
- </tr>
722
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
723
- <td><?php echo esc_html__('Address Locality', 'schema-and-structured-data-for-wp' ); ?></td>
724
- <td><input value="<?php if(isset($review_details['saswp_review_schema_locality'])){echo esc_attr($review_details['saswp_review_schema_locality']); } ?>" type="text" name="saswp_review_schema_locality" placeholder="<?php echo esc_html__('Address Locality', 'schema-and-structured-data-for-wp' ); ?>" ></td>
725
- </tr>
726
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
727
- <td><?php echo esc_html__('Address Region', 'schema-and-structured-data-for-wp' ); ?></td>
728
- <td><input value="<?php if(isset($review_details['saswp_review_schema_region'])){echo esc_attr($review_details['saswp_review_schema_region']); } ?>" type="text" name="saswp_review_schema_region" placeholder="<?php echo esc_html__('Address Region', 'schema-and-structured-data-for-wp' ); ?>" ></td>
729
- </tr>
730
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
731
- <td><?php echo esc_html__('Postal Code', 'schema-and-structured-data-for-wp' ); ?></td>
732
- <td><input value="<?php if(isset($review_details['saswp_review_schema_postal_code'])){echo esc_attr($review_details['saswp_review_schema_postal_code']); } ?>" type="text" name="saswp_review_schema_postal_code" placeholder="<?php echo esc_html__('Postal Code', 'schema-and-structured-data-for-wp' ); ?>" ></td>
733
- </tr>
734
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
735
- <td><?php echo esc_html__('Address Country', 'schema-and-structured-data-for-wp' ); ?></td>
736
- <td><input value="<?php if(isset($review_details['saswp_review_schema_country'])){echo esc_attr($review_details['saswp_review_schema_country']); } ?>" type="text" name="saswp_review_schema_country" placeholder="<?php echo esc_html__('Address Country', 'schema-and-structured-data-for-wp' ); ?>" ></td>
737
- </tr>
738
- <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
739
- <td><?php echo esc_html__('Telephone', 'schema-and-structured-data-for-wp' ); ?></td>
740
- <td><input value="<?php if(isset($review_details['saswp_review_schema_telephone'])){echo esc_attr($review_details['saswp_review_schema_telephone']); } ?>" type="text" name="saswp_review_schema_telephone" placeholder="<?php echo esc_html__('Telephone', 'schema-and-structured-data-for-wp' ); ?>" ></td>
741
- </tr>
742
-
743
-
744
 
745
  <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
746
  <td><?php echo esc_html__('Review Rating', 'schema-and-structured-data-for-wp' ); ?></td>
@@ -991,7 +1467,7 @@
991
 
992
  update_post_meta( $post_id, 'saswp_local_business_details', $local_business_details );
993
 
994
- //Service schema details starts here
995
  $service_schema_details = array();
996
  $review_schema_details = array();
997
  $product_schema_details = array();
@@ -1053,47 +1529,52 @@
1053
 
1054
 
1055
  if($schema_type =='Review'){
1056
- if ( isset( $_POST['saswp_review_schema_item_type'] ) ){
1057
- $review_schema_details['saswp_review_schema_item_type'] = sanitize_text_field($_POST['saswp_review_schema_item_type']);
1058
- }
1059
- if ( isset( $_POST['saswp_review_schema_name'] ) ){
1060
- $review_schema_details['saswp_review_schema_name'] = sanitize_text_field($_POST['saswp_review_schema_name']);
1061
- }
1062
- if ( isset( $_POST['saswp_review_schema_description'] ) ){
1063
- $review_schema_details['saswp_review_schema_description'] = sanitize_textarea_field($_POST['saswp_review_schema_description']);
1064
- }
1065
- if ( isset( $_POST['saswp_review_schema_image'] ) ){
1066
- $review_schema_details['saswp_review_schema_image']['id'] = sanitize_text_field($_POST['saswp_review_schema_image']['id']);
1067
- $review_schema_details['saswp_review_schema_image']['url'] = esc_url_raw($_POST['saswp_review_schema_image']['url']);
1068
- $review_schema_details['saswp_review_schema_image']['width'] = sanitize_text_field($_POST['saswp_review_schema_image']['width']);
1069
- $review_schema_details['saswp_review_schema_image']['height'] = sanitize_text_field($_POST['saswp_review_schema_image']['height']);
1070
- }
1071
- if ( isset( $_POST['saswp_review_schema_author'] ) ){
1072
- $review_schema_details['saswp_review_schema_author'] = sanitize_text_field($_POST['saswp_review_schema_author']);
1073
- }
1074
- if ( isset( $_POST['saswp_review_schema_price_range'] ) ){
1075
- $review_schema_details['saswp_review_schema_price_range'] = sanitize_text_field($_POST['saswp_review_schema_price_range']);
1076
- }
1077
- if ( isset( $_POST['saswp_review_schema_street_address'] ) ){
1078
- $review_schema_details['saswp_review_schema_street_address'] = sanitize_text_field($_POST['saswp_review_schema_street_address']);
1079
- }
1080
- if ( isset( $_POST['saswp_review_schema_locality'] ) ){
1081
- $review_schema_details['saswp_review_schema_locality'] = sanitize_text_field($_POST['saswp_review_schema_locality']);
1082
- }
1083
- if ( isset( $_POST['saswp_review_schema_region'] ) ){
1084
- $review_schema_details['saswp_review_schema_region'] = sanitize_text_field($_POST['saswp_review_schema_region']);
1085
- }
1086
- if ( isset( $_POST['saswp_review_schema_postal_code'] ) ){
1087
- $review_schema_details['saswp_review_schema_postal_code'] = sanitize_text_field($_POST['saswp_review_schema_postal_code']);
1088
- }
1089
- if ( isset( $_POST['saswp_review_schema_country'] ) ){
1090
- $review_schema_details['saswp_review_schema_country'] = sanitize_text_field($_POST['saswp_review_schema_country']);
1091
  }
1092
- if ( isset( $_POST['saswp_review_schema_telephone'] ) ){
1093
- $review_schema_details['saswp_review_schema_telephone'] = sanitize_text_field($_POST['saswp_review_schema_telephone']);
1094
- }
1095
-
1096
- if ( isset( $_POST['saswp_review_schema_enable_rating'] ) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1097
  $review_schema_details['saswp_review_schema_enable_rating'] = sanitize_text_field($_POST['saswp_review_schema_enable_rating']);
1098
  }
1099
  if ( isset( $_POST['saswp_review_schema_rating'] ) ){
@@ -1102,8 +1583,12 @@
1102
  if ( isset( $_POST['saswp_review_schema_review_count'] ) ){
1103
  $review_schema_details['saswp_review_schema_review_count'] = sanitize_text_field($_POST['saswp_review_schema_review_count']);
1104
  }
1105
-
1106
- update_post_meta( $post_id, 'saswp_review_schema_details', $review_schema_details );
 
 
 
 
1107
  }
1108
 
1109
  if($schema_type =='Product'){
@@ -1165,6 +1650,7 @@
1165
  }
1166
 
1167
  update_post_meta( $post_id, 'saswp_product_schema_details', $product_schema_details );
 
1168
  }
1169
 
1170
  if($schema_type =='AudioObject'){
1
+ <?php
2
+ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
3
+
4
+ $post_fix = '';
5
+
6
+ if($post_specific == 1 && isset($schema_id)){
7
+
8
+ $post_fix = '_'.$schema_id;
9
+
10
+ }
11
+
12
+ $reviewed_field = array(
13
+ array(
14
+ 'label' => 'Name',
15
+ 'id' => 'saswp_review_schema_name'.$post_fix,
16
+ 'type' => 'text',
17
+ 'default' => '',
18
+ 'attributes' => array(
19
+ 'placeholder' => 'Name'
20
+ )
21
+
22
+ ),
23
+ array(
24
+ 'label' => 'Review Body',
25
+ 'id' => 'saswp_review_schema_description'.$post_fix,
26
+ 'type' => 'textarea',
27
+ 'default' => '',
28
+ 'attributes' => array(
29
+ 'placeholder' => 'Review Body'
30
+ )
31
+ ),
32
+ array(
33
+ 'label' => 'Image',
34
+ 'id' => 'saswp_review_schema_image'.$post_fix,
35
+ 'type' => 'media',
36
+ 'default' => '',
37
+ 'attributes' => array(
38
+ 'placeholder' => 'Image'
39
+ )
40
+ ),
41
+ array(
42
+ 'label' => 'Author',
43
+ 'id' => 'saswp_review_schema_author'.$post_fix,
44
+ 'type' => 'text',
45
+ 'default' => '',
46
+ 'attributes' => array(
47
+ 'placeholder' => 'Author'
48
+ )
49
+ ),
50
+ array(
51
+ 'label' => 'Price Range',
52
+ 'id' => 'saswp_review_schema_price_range'.$post_fix,
53
+ 'type' => 'text',
54
+ 'default' => '',
55
+ 'attributes' => array(
56
+ 'placeholder' => '$$$ or 55$-100$'
57
+ )
58
+ ),
59
+ array(
60
+ 'label' => 'Street Address',
61
+ 'id' => 'saswp_review_schema_street_address'.$post_fix,
62
+ 'type' => 'text',
63
+ 'default' => '',
64
+ 'attributes' => array(
65
+ 'placeholder' => 'Street Address'
66
+ )
67
+ ),
68
+ array(
69
+ 'label' => 'Address Locality',
70
+ 'id' => 'saswp_review_schema_locality'.$post_fix,
71
+ 'type' => 'text',
72
+ 'default' => '',
73
+ 'attributes' => array(
74
+ 'placeholder' => 'Address Locality'
75
+ )
76
+ ),
77
+ array(
78
+ 'label' => 'Address Region',
79
+ 'id' => 'saswp_review_schema_region'.$post_fix,
80
+ 'type' => 'text',
81
+ 'default' => '',
82
+ 'attributes' => array(
83
+ 'placeholder' => 'Address Region'
84
+ )
85
+ ),
86
+ array(
87
+ 'label' => 'Postal Code',
88
+ 'id' => 'saswp_review_schema_postal_code'.$post_fix,
89
+ 'type' => 'text',
90
+ 'default' => '',
91
+ 'attributes' => array(
92
+ 'placeholder' => 'Postal Code'
93
+ )
94
+ ),
95
+ array(
96
+ 'label' => 'Address Country',
97
+ 'id' => 'saswp_review_schema_country'.$post_fix,
98
+ 'type' => 'text',
99
+ 'default' => '',
100
+ 'attributes' => array(
101
+ 'placeholder' => 'Country'
102
+ )
103
+ ),
104
+ array(
105
+ 'label' => 'Telephone',
106
+ 'id' => 'saswp_review_schema_telephone'.$post_fix,
107
+ 'type' => 'text',
108
+ 'default' => '',
109
+ 'attributes' => array(
110
+ 'placeholder' => '123456789'
111
+ )
112
+ ),
113
+
114
+ );
115
+
116
+ switch ($item) {
117
+
118
+ case 'Article':
119
+
120
+ $reviewed_field = array();
121
+
122
+ break;
123
+ case 'Adultentertainment':
124
+
125
+ $reviewed_field;
126
+
127
+ break;
128
+ case 'Blog':
129
+
130
+ $reviewed_field = array(
131
+ array(
132
+ 'label' => 'Name',
133
+ 'id' => 'saswp_review_schema_name'.$post_fix,
134
+ 'type' => 'text',
135
+ 'default' => $site_name = get_bloginfo()
136
+ ),
137
+ array(
138
+ 'label' => 'Url',
139
+ 'id' => 'saswp_review_schema_url'.$post_fix,
140
+ 'type' => 'text',
141
+ 'default' => get_site_url()
142
+ )
143
+ );
144
+
145
+ break;
146
+ case 'Book':
147
+
148
+ $reviewed_field = array(
149
+ array(
150
+ 'label' => 'Name',
151
+ 'id' => 'saswp_review_schema_name'.$post_fix,
152
+ 'type' => 'text',
153
+ 'default' => '',
154
+ 'attributes' => array(
155
+ 'placeholder' => 'Name'
156
+ )
157
+ ),
158
+ array(
159
+ 'label' => 'Author',
160
+ 'id' => 'saswp_review_schema_author'.$post_fix,
161
+ 'type' => 'text',
162
+ 'default' => '',
163
+ 'attributes' => array(
164
+ 'placeholder' => 'Author'
165
+ )
166
+ ),
167
+ array(
168
+ 'label' => 'ISBN',
169
+ 'id' => 'saswp_review_schema_isbn'.$post_fix,
170
+ 'type' => 'text',
171
+ 'default' => '',
172
+ 'attributes' => array(
173
+ 'placeholder' => 'ISBN'
174
+ )
175
+ ),
176
+ array(
177
+ 'label' => 'URL',
178
+ 'id' => 'saswp_review_schema_author_sameas'.$post_fix,
179
+ 'type' => 'text',
180
+ 'default' => '',
181
+ 'attributes' => array(
182
+ 'placeholder' => 'URL'
183
+ )
184
+ ),
185
+ array(
186
+ 'label' => 'Review Body',
187
+ 'id' => 'saswp_review_schema_description'.$post_fix,
188
+ 'type' => 'textarea',
189
+ 'default' => '',
190
+ 'attributes' => array(
191
+ 'placeholder' => 'Review Body'
192
+ )
193
+ )
194
+
195
+ );
196
+
197
+ break;
198
+ case 'casino':
199
+
200
+ $reviewed_field = $reviewed_field;
201
+
202
+ break;
203
+ case 'Diet':
204
+
205
+ $reviewed_field = array();
206
+
207
+ break;
208
+ case 'Episode':
209
+
210
+ $reviewed_field = array();
211
+
212
+ break;
213
+ case 'ExercisePlan':
214
+ $reviewed_field = array();
215
+ break;
216
+ case 'Game':
217
+ $reviewed_field = array();
218
+ break;
219
+ case 'Movie':
220
+ $reviewed_field = array(
221
+ array(
222
+ 'label' => 'Name',
223
+ 'id' => 'saswp_review_schema_name'.$post_fix,
224
+ 'type' => 'text',
225
+ 'default' => '',
226
+ 'attributes' => array(
227
+ 'placeholder' => 'Name'
228
+ )
229
+ ),
230
+ array(
231
+ 'label' => 'Date Created',
232
+ 'id' => 'saswp_review_schema_date_created'.$post_fix,
233
+ 'type' => 'text',
234
+ 'default' => '',
235
+ 'attributes' => array(
236
+ 'placeholder' => '2017-05-17'
237
+ )
238
+ ),
239
+ array(
240
+ 'label' => 'Image',
241
+ 'id' => 'saswp_review_schema_image'.$post_fix,
242
+ 'type' => 'media',
243
+ 'default' => '',
244
+ 'attributes' => array(
245
+ 'placeholder' => 'Image'
246
+ )
247
+ ),
248
+ array(
249
+ 'label' => 'Director',
250
+ 'id' => 'saswp_review_schema_director'.$post_fix,
251
+ 'type' => 'text',
252
+ 'default' => '',
253
+ 'attributes' => array(
254
+ 'placeholder' => 'Director'
255
+ )
256
+ ),
257
+ array(
258
+ 'label' => 'URL',
259
+ 'id' => 'saswp_review_schema_itemreviewed_sameas'.$post_fix,
260
+ 'type' => 'text',
261
+ 'default' => '',
262
+ 'attributes' => array(
263
+ 'placeholder' => 'URL'
264
+ )
265
+ ),
266
+ array(
267
+ 'label' => 'Review Body',
268
+ 'id' => 'saswp_review_schema_description'.$post_fix,
269
+ 'type' => 'textarea',
270
+ 'default' => '',
271
+ 'attributes' => array(
272
+ 'placeholder' => 'Review Body'
273
+ )
274
+ )
275
+
276
+ );
277
+ break;
278
+ case 'MusicPlaylist':
279
+ $reviewed_field = array();
280
+ break;
281
+ case 'MusicRecording':
282
+ $reviewed_field = array();
283
+ break;
284
+ case 'Photograph':
285
+ $reviewed_field = array();
286
+ break;
287
+ case 'Recipe':
288
+ $reviewed_field = array();
289
+ break;
290
+ case 'Restaurant':
291
+ $reviewed_field[] = array(
292
+ 'label' => 'Serves Cuisine',
293
+ 'id' => 'saswp_review_schema_servescuisine'.$post_fix,
294
+ 'type' => 'text',
295
+ 'default' => '',
296
+ 'attributes' => array(
297
+ 'placeholder' => 'Serves Cuisine'
298
+ )
299
+ );
300
+ break;
301
+ case 'Series':
302
+ $reviewed_field = array();
303
+ break;
304
+ case 'SoftwareApplication':
305
+ $reviewed_field = array();
306
+ break;
307
+ case 'VisualArtwork':
308
+ $reviewed_field = array();
309
+ break;
310
+ case 'WebPage':
311
+ $reviewed_field = array();
312
+ break;
313
+ case 'WebSite':
314
+ $reviewed_field = array(
315
+ array(
316
+ 'label' => 'Name',
317
+ 'id' => 'saswp_review_schema_name'.$post_fix,
318
+ 'type' => 'text',
319
+ 'default' => $site_name = get_bloginfo()
320
+ ),
321
+ array(
322
+ 'label' => 'Url',
323
+ 'id' => 'saswp_review_schema_url'.$post_fix,
324
+ 'type' => 'text',
325
+ 'default' => get_site_url()
326
+ )
327
+ );
328
+ break;
329
+
330
+ default:
331
+ break;
332
+ }
333
+
334
+ return $reviewed_field;
335
+
336
+ }
337
+
338
+ function saswp_get_item_reviewed_fields(){
339
+
340
+ if ( ! isset( $_GET['saswp_security_nonce'] ) ){
341
+ return;
342
+ }
343
+ if ( !wp_verify_nonce( $_GET['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
344
+ return;
345
+ }
346
+
347
+ $post_specific = '';
348
+ $output ='';
349
+ $item = sanitize_text_field($_GET['item']);
350
+ $schema_id = sanitize_text_field($_GET['schema_id']);
351
+ $post_id = sanitize_text_field($_GET['post_id']);
352
+ $post_specific = sanitize_text_field($_GET['post_specific']);
353
+
354
+
355
+ $meta_fields = item_reviewed_fields($item, $post_specific, $schema_id);
356
+
357
+
358
+ foreach ($meta_fields as $meta_field){
359
+
360
+
361
+ $attributes ='';
362
+
363
+ if(isset($meta_field['attributes'])){
364
+ foreach ($meta_field['attributes'] as $key => $attr ){
365
+ $attributes .=''.$key.'="'.$attr.'"';
366
+ }
367
+ }
368
+
369
+
370
+ if($post_specific == 1){
371
+
372
+ $meta_value = get_post_meta( $post_id, $meta_field['id'], true );
373
+
374
+
375
+ if(!$meta_value){
376
+
377
+ $schema_data = get_post_meta( $schema_id, 'saswp_review_schema_details', true );
378
+
379
+ $meta_value = $schema_data[chop($meta_field['id'], '_'.$schema_id)];
380
+ }
381
+
382
+ }else{
383
+
384
+ $schema_data = get_post_meta( $schema_id, 'saswp_review_schema_details', true );
385
+ $meta_value = $schema_data[$meta_field['id']];
386
+
387
+ }
388
+
389
+
390
+
391
+
392
+ if ( empty( $meta_value ) ) {
393
+
394
+ $meta_value = $meta_field['default'];
395
+
396
+ }
397
+
398
+ switch ($meta_field['type']) {
399
+
400
+ case 'media':
401
+
402
+ $media_value = array();
403
+ $media_key = $meta_field['id'].'_detail';
404
+
405
+ if($post_specific == 1){
406
+
407
+ $media_value_meta = get_post_meta( $post_id, $media_key, true );
408
+
409
+ if(empty($media_value_meta)){
410
+
411
+ $media_key = chop($meta_field['id'], '_'.$schema_id).'_detail';
412
+ $media_value_meta = $schema_data[$media_key];
413
+
414
+ }
415
+
416
+ }else{
417
+
418
+ $media_value_meta = $schema_data[$media_key];
419
+
420
+ }
421
+
422
+
423
+ if(!empty($media_value_meta)){
424
+
425
+ $media_value = $media_value_meta;
426
+
427
+ }
428
+
429
+ $input = sprintf(
430
+ ' <input style="width: 80%%" id="%s" name="%s" type="text" value="%s" readonly>'
431
+ . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_height" class="upload-height" name="'.esc_attr($meta_field['id']).'_height" id="'.esc_attr($meta_field['id']).'_height" value="'.$media_value['height'].'">'
432
+ . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_width" class="upload-width" name="'.esc_attr($meta_field['id']).'_width" id="'.esc_attr($meta_field['id']).'_width" value="'.$media_value['width'].'">'
433
+ . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_thumbnail" class="upload-thumbnail" name="'.esc_attr($meta_field['id']).'_thumbnail" id="'.esc_attr($meta_field['id']).'_thumbnail" value="'.$media_value['thumbnail'].'">'
434
+ . '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />',
435
+ $meta_field['id'],
436
+ $meta_field['id'],
437
+ $meta_value,
438
+ $meta_field['id'],
439
+ $meta_field['id']
440
+ );
441
+
442
+
443
+ break;
444
+
445
+ case 'textarea':
446
+ $input = sprintf(
447
+ '<textarea %s style="width: 100%%" id="%s" name="%s" rows="5">%s</textarea>',
448
+ $attributes,
449
+ $meta_field['id'],
450
+ $meta_field['id'],
451
+ $meta_value
452
+ );
453
+ break;
454
+
455
+ default:
456
+
457
+ $input = sprintf(
458
+ '<input %s %s id="%s" name="%s" type="%s" value="%s">',
459
+ $attributes,
460
+ $meta_field['type'] !== 'color' ? 'style="width: 100%"' : '',
461
+ esc_attr(saswp_remove_warnings($meta_field, 'id', 'saswp_string')),
462
+ esc_attr(saswp_remove_warnings($meta_field, 'id', 'saswp_string')),
463
+ esc_attr(saswp_remove_warnings($meta_field, 'type', 'saswp_string')),
464
+ $meta_value
465
+ );
466
+
467
+ break;
468
+
469
+ }
470
+
471
+ $output .= '<tr class="saswp-review-tr">'
472
+ . '<td>'.esc_html__($meta_field['label'], 'schema-and-structured-data-for-wp' ).'</td>'
473
+ . '<td>'.$input.'</td>'
474
+ . '</tr>';
475
+
476
+ }
477
+
478
+ echo $output;
479
+
480
+ wp_die();
481
+ }
482
+
483
+ add_action( 'wp_ajax_saswp_get_item_reviewed_fields', 'saswp_get_item_reviewed_fields' ) ;
484
+
485
  add_action( 'add_meta_boxes', 'saswp_schema_type_add_meta_box' ) ;
486
  add_action( 'save_post', 'saswp_schema_type_add_meta_box_save' ) ;
487
 
488
  function saswp_schema_type_add_meta_box() {
489
+
490
  add_meta_box(
491
  'schema_type',
492
+ esc_html__( 'Schema Type', 'schema-and-structured-data-for-wp' ),
493
  'saswp_schema_type_meta_box_callback',
494
  'saswp',
495
  'advanced',
496
  'high'
497
  );
498
+
499
  }
500
  function saswp_schema_type_get_meta( $value ) {
501
+
502
  global $post;
503
 
504
  $field = get_post_meta( $post->ID, $value, true );
510
  }
511
  }
512
  function saswp_schema_type_meta_box_callback( $post) {
513
+
514
  wp_nonce_field( 'saswp_schema_type_nonce', 'saswp_schema_type_nonce' );
515
+
516
+ $style_business_type = '';
517
+ $style_business_name = '';
518
+ $style_service_name = '';
519
+ $style_review_name = '';
520
+ $business_name = '';
521
+ $schema_type = '';
522
+ $business_type = '';
523
+ $custom_logo_id = '';
524
+ $business_details = array();
525
+ $logo = array();
526
+ $service_details = array();
527
+ $review_details = array();
528
+ $product_details = array();
529
+
530
  if($post){
531
+
532
+ $schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
533
+
534
+ switch ($schema_type) {
535
+
536
+ case 'AudioObject':
537
+
538
+ $audio_details = esc_sql ( get_post_meta($post->ID, 'saswp_audio_schema_details', true) );
539
+
540
+ break;
541
+
542
+ case 'local_business':
543
+
544
+ $business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
545
+ $business_name = esc_sql ( get_post_meta($post->ID, 'saswp_business_name', true) );
546
+ $business_details = esc_sql ( get_post_meta($post->ID, 'saswp_local_business_details', true) );
547
+ $dayoftheweek = get_post_meta($post->ID, 'saswp_dayofweek', true);
548
+
549
+ break;
550
+
551
+ case 'Product':
552
+
553
+ $product_details = esc_sql ( get_post_meta($post->ID, 'saswp_product_schema_details', true) );
554
+
555
+ break;
556
+
557
+ case 'Service':
558
+
559
+ $service_details = esc_sql ( get_post_meta($post->ID, 'saswp_service_schema_details', true) );
560
+
561
+ break;
562
+
563
+ case 'Review':
564
+
565
+ $review_details = esc_sql ( get_post_meta($post->ID, 'saswp_review_schema_details', true) );
566
+
567
+ break;
568
+
569
+ default:
570
+ break;
571
+ }
572
+
573
+ $custom_logo_id = get_theme_mod( 'custom_logo' );
574
+
575
  if($custom_logo_id){
576
+
577
+ $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
578
+
579
  }
580
 
581
  if($schema_type != 'local_business'){
582
+
583
+ $style_business_type = 'style="display:none"';
584
+ $style_business_name = 'style="display:none"';
585
+
586
  }
587
  }
588
 
614
 
615
  $item_reviewed = array(
616
  'Article' => 'Article',
617
+ 'Adultentertainment' => 'Adult Entertainment',
618
  'Blog' => 'Blog',
619
  'Book' => 'Book',
620
+ 'Casino' => 'Casino',
621
  'Diet' => 'Diet',
622
  'Episode' => 'Episode',
623
  'ExercisePlan' => 'Exercise Plan',
626
  'MusicPlaylist' => 'Music Playlist',
627
  'MusicRecording' => 'MusicRecording',
628
  'Photograph' => 'Photograph',
629
+ //'Recipe' => 'Recipe',
630
  'Restaurant' => 'Restaurant',
631
  'Series' => 'Series',
632
+ //'SoftwareApplication' => 'Software Application',
633
  'VisualArtwork' => 'Visual Artwork',
634
+ 'WebPage' => 'WebPage',
635
  'WebSite' => 'WebSite',
636
  );
637
 
638
  $all_schema_array = array(
639
+ 'Article' => 'Article',
640
+ 'AudioObject' => 'AudioObject',
641
+ 'Blogposting' => 'Blogposting',
642
+ 'local_business' => 'Local Business',
643
+ 'NewsArticle' => 'NewsArticle',
644
+ 'Product' => 'Product',
645
+ 'qanda' => 'Q&A',
646
+ 'Review' => 'Review',
647
+ 'Recipe' => 'Recipe',
648
+ 'Service' => 'Service',
649
+ 'VideoObject' => 'VideoObject',
650
+ 'WebPage' => 'WebPage'
651
  );
652
  $all_business_type = array(
653
+ 'animalshelter' => 'Animal Shelter',
654
+ 'automotivebusiness' => 'Automotive Business',
655
+ 'childcare' => 'ChildCare',
656
+ 'dentist' => 'Dentist',
657
+ 'drycleaningorlaundry' => 'Dry Cleaning Or Laundry',
658
+ 'emergencyservice' => 'Emergency Service',
659
+ 'employmentagency' => 'Employment Agency',
660
+ 'entertainmentbusiness' => 'Entertainment Business',
661
+ 'financialservice' => 'Financial Service',
662
+ 'foodestablishment' => 'Food Establishment',
663
+ 'governmentoffice' => 'Government Office',
664
+ 'healthandbeautybusiness' => 'Health And Beauty Business',
665
+ 'homeandconstructionbusiness' => 'Home And Construction Business',
666
+ 'internetcafe' => 'Internet Cafe',
667
+ 'legalservice' => 'Legal Service',
668
+ 'library' => 'Library',
669
+ 'lodgingbusiness' => 'Lodging Business',
670
+ 'professionalservice' => 'Professional Service',
671
+ 'radiostation' => 'Radio Station',
672
+ 'realestateagent' => 'Real Estate Agent',
673
+ 'recyclingcenter' => 'Recycling Center',
674
+ 'selfstorage' => 'Self Storage',
675
+ 'shoppingcenter' => 'Shopping Center',
676
+ 'sportsactivitylocation' => 'Sports Activity Location',
677
+ 'store' => 'Store',
678
+ 'televisionstation' => 'Television Station',
679
+ 'touristinformationcenter' => 'Tourist Information Center',
680
+ 'travelagency' => 'Travel Agency',
681
  );
682
 
683
  $all_automotive_array = array(
684
+ 'autobodyshop' => 'Auto Body Shop',
685
+ 'autodealer' => 'Auto Dealer',
686
+ 'autopartsstore' => 'Auto Parts Store',
687
+ 'autorental' => 'Auto Rental',
688
+ 'autorepair' => 'Auto Repair',
689
+ 'autowash' => 'Auto Wash',
690
+ 'gasstation' => 'Gas Station',
691
  'motorcycledealer' => 'Motorcycle Dealer',
692
  'motorcyclerepair' => 'Motorcycle Repair'
693
  );
694
 
695
  $all_emergency_array = array(
696
+ 'firestation' => 'Fire Station',
697
+ 'hospital' => 'Hospital',
698
+ 'policestation' => 'Police Station',
699
  );
700
  $all_entertainment_array = array(
701
  'adultentertainment' => 'Adult Entertainment',
702
+ 'amusementpark' => 'Amusement Park',
703
+ 'artgallery' => 'Art Gallery',
704
+ 'casino' => 'Casino',
705
+ 'comedyclub' => 'Comedy Club',
706
+ 'movietheater' => 'Movie Theater',
707
+ 'nightclub' => 'Night Club',
708
 
709
  );
710
  $all_financial_array = array(
711
+ 'accountingservice' => 'Accounting Service',
712
+ 'automatedteller' => 'Automated Teller',
713
+ 'bankorcredit_union' => 'Bank Or Credit Union',
714
+ 'insuranceagency' => 'Insurance Agency',
715
 
716
  );
717
 
718
  $all_food_establishment_array = array(
719
+ 'bakery' => 'Bakery',
720
+ 'barorpub' => 'Bar Or Pub',
721
+ 'brewery' => 'Brewery',
722
+ 'cafeorcoffee_shop' => 'Cafe Or Coffee Shop',
723
  'fastfoodrestaurant' => 'Fast Food Restaurant',
724
+ 'icecreamshop' => 'Ice Cream Shop',
725
+ 'restaurant' => 'Restaurant',
726
+ 'winery' => 'Winery',
727
 
728
  );
729
  $all_health_and_beauty_array = array(
730
+ 'beautysalon' => 'Beauty Salon',
731
+ 'dayspa' => 'DaySpa',
732
+ 'hairsalon' => 'Hair Salon',
733
  'healthclub' => 'Health Club',
734
+ 'nailsalon' => 'Nail Salon',
735
+ 'tattooparlor' => 'Tattoo Parlor',
736
  );
737
 
738
  $all_home_and_construction_array = array(
739
+ 'electrician' => 'Electrician',
740
  'generalcontractor' => 'General Contractor',
741
+ 'hvacbusiness' => 'HVAC Business',
742
+ 'locksmith' => 'Locksmith',
743
+ 'movingcompany' => 'Moving Company',
744
+ 'plumber' => 'Plumber',
745
  'roofingcontractor' => 'Roofing Contractor',
746
  );
747
 
748
  $all_legal_service_array = array(
749
  'attorney' => 'Attorney',
750
+ 'notary' => 'Notary',
751
  );
752
 
753
  $all_lodging_array = array(
754
  'bedandbreakfast' => 'Bed And Breakfast',
755
+ 'campground' => 'Campground',
756
+ 'hostel' => 'Hostel',
757
+ 'hotel' => 'Hotel',
758
+ 'motel' => 'Motel',
759
+ 'resort' => 'Resort',
760
  );
761
 
762
  $all_sports_activity_location = array(
763
+ 'bowlingalley' => 'Bowling Alley',
764
+ 'exercisegym' => 'Exercise Gym',
765
+ 'golfcourse' => 'Golf Course',
766
+ 'healthclub' => 'Health Club',
767
  'publicswimming_pool' => 'Public Swimming Pool',
768
+ 'skiresort' => 'Ski Resort',
769
+ 'sportsclub' => 'Sports Club',
770
+ 'stadiumorarena' => 'Stadium Or Arena',
771
+ 'tenniscomplex' => 'Tennis Complex'
772
  );
773
  $all_store = array(
774
+ 'autopartsstore' => 'Auto Parts Store',
775
+ 'bikestore' => 'Bike Store',
776
+ 'bookstore' => 'Book Store',
777
+ 'clothingstore' => 'Clothing Store',
778
+ 'computerstore' => 'Computer Store',
779
+ 'conveniencestore' => 'Convenience Store',
780
+ 'departmentstore' => 'Department Store',
781
+ 'electronicsstore' => 'Electronics Store',
782
+ 'florist' => 'Florist',
783
+ 'furniturestore' => 'Furniture Store',
784
+ 'gardenstore' => 'Garden Store',
785
+ 'grocerystore' => 'Grocery Store',
786
+ 'hardwarestore' => 'Hardware Store',
787
+ 'hobbyshop' => 'Hobby Shop',
788
+ 'homegoodsstore' => 'HomeGoods Store',
789
+ 'jewelrystore' => 'Jewelry Store',
790
+ 'liquorstore' => 'Liquor Store',
791
+ 'mensclothingstore' => 'Mens Clothing Store',
792
+ 'mobilephonestore' => 'Mobile Phone Store',
793
+ 'movierentalstore' => 'Movie Rental Store',
794
+ 'musicstore' => 'Music Store',
795
+ 'officeequipmentstore' => 'Office Equipment Store',
796
+ 'outletstore' => 'Outlet Store',
797
+ 'pawnshop' => 'Pawn Shop',
798
+ 'petstore' => 'Pet Store',
799
+ 'shoestore' => 'Shoe Store',
800
+ 'sportinggoodsstore' => 'Sporting Goods Store',
801
+ 'tireshop' => 'Tire Shop',
802
+ 'toystore' => 'Toy Store',
803
+ 'wholesalestore' => 'Wholesale Store'
804
  );
805
  ?>
806
  <div class="misc-pub-section">
1070
  <tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
1071
  <td><?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?></td>
1072
  <td style="display: flex; width: 97%">
1073
+ <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_url($business_details['local_business_logo']['url']);} else { echo esc_url(saswp_remove_warnings($logo, 0, 'saswp_string')); } ?>" id="local_business_logo" type="text" name="local_business_logo[url]" placeholder="<?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?>" readonly="readonly" style="background: #FFF;">
1074
  <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_attr($business_details['local_business_logo']['id']);} else { echo esc_attr($custom_logo_id); }?>" data-id="local_business_logo_id" type="hidden" name="local_business_logo[id]">
1075
  <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_attr($business_details['local_business_logo']['width']);} else { echo esc_attr(saswp_remove_warnings($logo, 1, 'saswp_string')); } ?>" data-id="local_business_logo_width" type="hidden" name="local_business_logo[width]">
1076
  <input value="<?php if(isset($business_details['local_business_logo'])) { echo esc_attr($business_details['local_business_logo']['height']);} else { echo esc_attr(saswp_remove_warnings($logo, 2, 'saswp_string')); } ?>" data-id="local_business_logo_height" type="hidden" name="local_business_logo[height]">
1204
  <td><?php echo esc_html__('Item Reviewed Type', 'schema-and-structured-data-for-wp' ); ?></td>
1205
  <td>
1206
 
1207
+ <select data-id="<?php echo esc_attr($post->ID); ?>" name="saswp_review_schema_item_type" class="saswp-item-reviewed">
1208
  <?php
1209
  foreach ($item_reviewed as $key => $value) {
1210
  $sel = '';
1216
  ?>
1217
  </select>
1218
  </td>
1219
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1220
 
1221
  <tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
1222
  <td><?php echo esc_html__('Review Rating', 'schema-and-structured-data-for-wp' ); ?></td>
1467
 
1468
  update_post_meta( $post_id, 'saswp_local_business_details', $local_business_details );
1469
 
1470
+
1471
  $service_schema_details = array();
1472
  $review_schema_details = array();
1473
  $product_schema_details = array();
1529
 
1530
 
1531
  if($schema_type =='Review'){
1532
+
1533
+ if ( !isset( $_POST['saswp_review_schema_item_type'] ) ){
1534
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1535
  }
1536
+
1537
+ $item = sanitize_text_field($_POST['saswp_review_schema_item_type']);
1538
+ $meta_fields = item_reviewed_fields($item);
1539
+
1540
+ foreach ( $meta_fields as $meta_field ) {
1541
+
1542
+ if ( isset( $_POST[ $meta_field['id'] ] ) ) {
1543
+ switch ( $meta_field['type'] ) {
1544
+
1545
+ case 'media':
1546
+
1547
+ $media_key = $meta_field['id'].'_detail';
1548
+ $media_height = sanitize_text_field( $_POST[ $meta_field['id'].'_height' ] );
1549
+ $media_width = sanitize_text_field( $_POST[ $meta_field['id'].'_width' ] );
1550
+ $media_thumbnail = sanitize_text_field( $_POST[ $meta_field['id'].'_thumbnail' ] );
1551
+ $media_detail = array(
1552
+ 'height' => $media_height,
1553
+ 'width' => $media_width,
1554
+ 'thumbnail' => $media_thumbnail,
1555
+ );
1556
+
1557
+ $review_schema_details[$media_key] = $media_detail;
1558
+ break;
1559
+
1560
+
1561
+ case 'email':
1562
+ $_POST[ $meta_field['id'] ] = sanitize_email( $_POST[ $meta_field['id'] ] );
1563
+ break;
1564
+ case 'text':
1565
+ $_POST[ $meta_field['id'] ] = sanitize_text_field( $_POST[ $meta_field['id'] ] );
1566
+ break;
1567
+ }
1568
+ $review_schema_details[$meta_field['id']] = $_POST[ $meta_field['id'] ];
1569
+
1570
+
1571
+ } else if ( $meta_field['type'] === 'checkbox' ) {
1572
+ $review_schema_details[$meta_field['id']] = '0';
1573
+ }
1574
+ }
1575
+
1576
+
1577
+ if ( isset( $_POST['saswp_review_schema_enable_rating'] ) ){
1578
  $review_schema_details['saswp_review_schema_enable_rating'] = sanitize_text_field($_POST['saswp_review_schema_enable_rating']);
1579
  }
1580
  if ( isset( $_POST['saswp_review_schema_rating'] ) ){
1583
  if ( isset( $_POST['saswp_review_schema_review_count'] ) ){
1584
  $review_schema_details['saswp_review_schema_review_count'] = sanitize_text_field($_POST['saswp_review_schema_review_count']);
1585
  }
1586
+
1587
+ $review_schema_details['saswp_review_schema_item_type'] = sanitize_text_field($_POST['saswp_review_schema_item_type']);
1588
+
1589
+ update_post_meta( $post_id, 'saswp_review_schema_details', $review_schema_details);
1590
+
1591
+
1592
  }
1593
 
1594
  if($schema_type =='Product'){
1650
  }
1651
 
1652
  update_post_meta( $post_id, 'saswp_product_schema_details', $product_schema_details );
1653
+
1654
  }
1655
 
1656
  if($schema_type =='AudioObject'){