Schema & Structured Data for WP & AMP - Version 1.0.4

Version Description

(16 November 2018) = * Major Feature: Post Specific Meta boxes to override the schemas on posts * Major Feature: Rich Snippets for Reviews and Ratings * Security and other bug fixed

Download this release

Release Info

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

Code changes from version 1.0.3 to 1.0.4

admin_section/add-schema/add_new.php CHANGED
@@ -43,13 +43,16 @@ $saswp_add_data_type_config = array(
43
  // Exit if the user does not have proper permissions
44
  if(! current_user_can( 'manage_options' ) ) {
45
  return ;
46
- }
47
- saswp_add_new_steps_call();
 
 
 
48
  }
49
 
50
  function saswp_add_new_steps_call(){
51
  global $saswp_add_data_type_config;
52
- if ( empty( $_GET['page'] ) || $saswp_add_data_type_config['installerpage'] !== $_GET['page'] ) {
53
  return;
54
  }
55
  if ( ob_get_length() ) {
43
  // Exit if the user does not have proper permissions
44
  if(! current_user_can( 'manage_options' ) ) {
45
  return ;
46
+ }
47
+ if( wp_verify_nonce($_GET['_wpnonce'], '_wpnonce')){
48
+ saswp_add_new_steps_call();
49
+ }
50
+
51
  }
52
 
53
  function saswp_add_new_steps_call(){
54
  global $saswp_add_data_type_config;
55
+ if ( !wp_verify_nonce($_GET['_wpnonce'], '_wpnonce') ||empty( $_GET['page'] ) || $saswp_add_data_type_config['installerpage'] !== $_GET['page'] ) {
56
  return;
57
  }
58
  if ( ob_get_length() ) {
admin_section/common-function.php CHANGED
@@ -878,3 +878,151 @@ function saswp_defaultSettings(){
878
  $sd_data = $settings = get_option( 'sd_data', $defaults);
879
  return $settings;
880
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
878
  $sd_data = $settings = get_option( 'sd_data', $defaults);
879
  return $settings;
880
  }
881
+ function saswp_frontend_enqueue(){
882
+ wp_enqueue_style( 'saswp-style', SASWP_PLUGIN_URL . 'admin_section/css/saswp-style.css', false , SASWP_VERSION );
883
+
884
+ }
885
+ add_action( 'wp_enqueue_scripts', 'saswp_frontend_enqueue' );
886
+
887
+ function saswp_enque_amp_script(){ ?>
888
+ .saswp-pc-wrap{
889
+ background-color: #004f74;
890
+ padding: 15px;
891
+ color: #fff;
892
+ display: flex;
893
+ width:auto;
894
+ flex-wrap: wrap;
895
+ margin-bottom: 20px;
896
+ }
897
+ .saswp-pc-wrap .saswp-lst span{
898
+ font-size: 18px;
899
+ font-weight: 500;
900
+ margin-bottom: 10px;
901
+ display: inline-block;
902
+ line-height: 1.3;
903
+ }
904
+ .saswp-pc-wrap .saswp-lst{
905
+ flex:1 0 42%;
906
+ }
907
+ .saswp-pc-wrap .saswp-lst ul{
908
+ margin:0;
909
+ }
910
+ .saswp-pc-wrap .saswp-lst p{
911
+ list-style-type: none;
912
+ font-size: 15px;
913
+ font-weight: lighter;
914
+ line-height: 1.2;
915
+ margin-bottom: 10px;
916
+ position: relative;
917
+ padding-left: 20px;
918
+ color:#eee;
919
+ }
920
+ .saswp-pc-wrap .saswp-lst p:before{
921
+ content: '';
922
+ position: absolute;
923
+ width: 8px;
924
+ height: 8px;
925
+ background-color: #ccc;
926
+ left: 0px;
927
+ top: 6px;
928
+ border-radius: 10px;
929
+ }
930
+ .sgl .saswp-rvw {
931
+ width: 100%;
932
+ margin-bottom: 34px;
933
+ font-size: 13px;
934
+ border-bottom: 1px solid #ededed;
935
+ }
936
+ .saswp-rvw-hd span {
937
+ background-color: #222;
938
+ color: #fff;
939
+ display: inline-block;
940
+ font-size: 15px;
941
+ line-height: 1.4;
942
+ padding: 8px 12px 6px;
943
+ margin: 26px 0px;
944
+ }
945
+ .saswp-rvw tbody{
946
+ width:100%;
947
+ display:inline-block;
948
+ }
949
+ .saswp-rvw td {
950
+ padding: 7px 14px;
951
+ }
952
+ .sgl table td, .saswp-rvw td {
953
+ border: 1px solid #ededed;
954
+ }
955
+ .saswp-rvw-sm span{
956
+ background-color: #222;
957
+ color: #fff;
958
+ display: inline-block;
959
+ padding: 8px 12px 6px;
960
+ margin-bottom: 13px;
961
+ position: relative;
962
+ font-size: 15px;
963
+ line-height: 1.2;
964
+ }
965
+ .saswp-rvw-fs {
966
+ line-height: 1.5;
967
+ font-size: 48px;
968
+ font-weight: 600;
969
+ margin-bottom: 5px;
970
+ }
971
+ .saswp-rvw-ov .ovs {
972
+ font-size: 11px;
973
+ font-weight:600;
974
+ }
975
+ .sgl .saswp-rvw tr td{
976
+ background:#fff;
977
+ width:100%;
978
+ }
979
+ .sgl .saswp-rvw tr:hover td {
980
+ background-color: #fcfcfc;
981
+ }
982
+ .saswp-rvw .saswp-rvw-sm {
983
+ padding: 21px 14px;
984
+ }
985
+ .str-ic{
986
+ font-size: 18px;
987
+ line-height: 1.2;
988
+ }
989
+ .saswp-rvw-str{
990
+ display: inline-flex;
991
+ width: 100%;
992
+ }
993
+ .saswp-rvw-ov{
994
+ text-align:center;
995
+ }
996
+ .saswp-rvw-str .half-str{
997
+ display:inline-block;
998
+ width: 20px;
999
+ height: 16px;
1000
+ background-repeat: no-repeat;
1001
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0ODIuMjA3IDQ4Mi4yMDciIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ4Mi4yMDcgNDgyLjIwNzsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8cGF0aCBkPSJNNDgyLjIwNywxODYuOTczbC0xNTkuNjk5LTMzLjcwNUwyNDEuMTA0LDExLjgwM2wtODEuNDA0LDE0MS40NjVMMCwxODYuOTczbDEwOS4zODgsMTIxLjEzNEw5Mi4wOTQsNDcwLjQwNGwxNDkuMDEtNjYuNiAgbDE0OS4wMSw2Ni42bC0xNy4yOTQtMTYyLjI5Nkw0ODIuMjA3LDE4Ni45NzN6IE0yNDEuMTA0LDM3MC45NDNWNzEuOTUzbDYyLjA5LDEwNy45TDQyNSwyMDUuNTYxbC04My40MzMsOTIuMzkzbDEzLjE5MSwxMjMuNzg4ICBMMjQxLjEwNCwzNzAuOTQzeiIgZmlsbD0iI2ZmZDcwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);
1002
+ }
1003
+ .saswp-rvw-str .str-ic{
1004
+ display:inline-block;
1005
+ width: 20px;
1006
+ height: 16px;
1007
+ background-repeat: no-repeat;
1008
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0ODIuMjA3IDQ4Mi4yMDciIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ4Mi4yMDcgNDgyLjIwNzsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8cG9seWdvbiBwb2ludHM9IjQ4Mi4yMDcsMTg2Ljk3MyAzMjIuNTA4LDE1My4yNjkgMjQxLjEwNCwxMS44MDMgMTU5LjY5OSwxNTMuMjY5IDAsMTg2Ljk3MyAxMDkuMzg4LDMwOC4xMDggOTIuMDk0LDQ3MC40MDQgICAyNDEuMTA0LDQwMy44MDMgMzkwLjExMyw0NzAuNDA0IDM3Mi44MTgsMzA4LjEwOCAiIGZpbGw9IiNmZmQ3MDAiLz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==);
1009
+ }
1010
+ .saswp-rvw-str .df-clr{
1011
+ display:inline-block;
1012
+ width: 20px;
1013
+ height: 16px;
1014
+ background-repeat: no-repeat;
1015
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0ODIuMjA3IDQ4Mi4yMDciIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ4Mi4yMDcgNDgyLjIwNzsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8cG9seWdvbiBwb2ludHM9IjQ4Mi4yMDcsMTg2Ljk3MyAzMjIuNTA4LDE1My4yNjkgMjQxLjEwNCwxMS44MDMgMTU5LjY5OSwxNTMuMjY5IDAsMTg2Ljk3MyAxMDkuMzg4LDMwOC4xMDggOTIuMDk0LDQ3MC40MDQgICAyNDEuMTA0LDQwMy44MDMgMzkwLjExMyw0NzAuNDA0IDM3Mi44MTgsMzA4LjEwOCAiIGZpbGw9IiM2MzVlNjMiLz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==);
1016
+ }
1017
+ @media(max-width:500px){
1018
+ .saswp-pc-wrap{
1019
+ display:block;
1020
+ }
1021
+ .saswp-pc-wrap .saswp-lst{
1022
+ margin-bottom:20px;
1023
+ }
1024
+ }
1025
+ <?php
1026
+
1027
+ }
1028
+ add_action('amp_post_template_css','saswp_enque_amp_script');
admin_section/css/main-style.css CHANGED
@@ -59,6 +59,10 @@ and open the template in the editor.
59
  width: auto;
60
  padding: 0px;
61
  }
 
 
 
 
62
  .saswp-help table{
63
  margin-top: 0px;
64
  }
@@ -309,6 +313,17 @@ padding-bottom: 10px;
309
  float:left;
310
  clear: both;
311
  }
 
 
 
 
 
 
 
 
 
 
 
312
  .saswp-compativility-div .saswp-knowledge-field{
313
  float: right;
314
  width: 75%;
@@ -328,6 +343,96 @@ clear: both;
328
  }
329
  .saswp-seller-div .saswp-knowledge-field{
330
  float: left;
331
- width: 70%;
332
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  width: auto;
60
  padding: 0px;
61
  }
62
+ .saswp-review table th{
63
+ width: auto;
64
+ padding: 0px;
65
+ }
66
  .saswp-help table{
67
  margin-top: 0px;
68
  }
313
  float:left;
314
  clear: both;
315
  }
316
+
317
+ .saswp-review .saswp-knowledge-field{
318
+ float: right;
319
+ width: 75%;
320
+ padding-bottom: 10px;
321
+ }
322
+ .saswp-review .saswp-knowledge-label{
323
+ float:left;
324
+ clear: both;
325
+ }
326
+
327
  .saswp-compativility-div .saswp-knowledge-field{
328
  float: right;
329
  width: 75%;
343
  }
344
  .saswp-seller-div .saswp-knowledge-field{
345
  float: left;
346
+ width: 70%;
347
+ }
348
+ .saswp-post-specific-tab-wrapper{
349
+ display: inline-block;
350
+ width: 25%;
351
+ vertical-align: top;
352
+
353
+ }
354
+ .saswp-post-specific-container{
355
+ display: inline-block;
356
+ width: calc(75% - 1px );
357
+ border-left: 1px solid #eee;
358
+ }
359
+ .saswp-post-specific-wrapper{
360
+ padding: 10px;
361
+ }
362
+ .saswp-tab a.selected {
363
+ background-color: #ccc;
364
+ }
365
+ .saswp-tab-links{
366
+ display: block;
367
+ background-color: inherit;
368
+ color: black;
369
+ padding: 10px 16px;
370
+ outline: none;
371
+ text-align: left;
372
+ cursor: pointer;
373
+ transition: 0.3s;
374
+ font-size: 17px;
375
+ }
376
+ .saswp-star-rating{
377
+ cursor: pointer;
378
+ }
379
+ .saswp-post-specific-wrapper select{
380
+ width: 100%;
381
+ }
382
+ .saswp-review-tables{
383
+ width: 100%;
384
+ }
385
+ .saswp-over-all-raring{
386
+ float: right;
387
+ }
388
+
389
+ .saswp-review-pros-and-cons{
390
+ position: relative;
391
+ clear:both;
392
+ }
393
+ .saswp-review-pros-and-cons > div:first{
394
+ padding-left: 10px;
395
+ }
396
+ .saswp-review-pros-and-cons > div{
397
+ width: 49%;
398
+ display: inline-block;
399
+ }
400
+ .saswp-review-pros-and-cons > div:nth-child(2){
401
+ padding-left: 12px;
402
  }
403
+ .saswp-wp-ediot-desc{
404
+ margin-bottom: -23px;
405
+ display: block;
406
+ }
407
+ .saswp-review-description{
408
+ margin-top: 40px;
409
+ padding-top: 10px;
410
+ border-top: 1px solid #eee;
411
+ }
412
+ .saswp-review-pros-and-cons{
413
+ margin-top: 40px;
414
+ padding-top: 10px;
415
+ border-top: 1px solid #eee;
416
+ }
417
+ .saspw-review-item-list{
418
+ margin-top: 20px;
419
+ border-top: 1px solid #eee;
420
+ }
421
+ .saswp-review-item-list-table{
422
+ padding-bottom: 10px;
423
+ }
424
+ #sasw-review input[type=text] {
425
+ width: 180px;
426
+ }
427
+ #sasw-review input[type=number] {
428
+ width: 180px;
429
+ }
430
+ #saswp-review-item-enable{
431
+ width: 10px;
432
+ }
433
+ .saswp-enable-review-on-post{
434
+ padding-bottom: 10px;
435
+ }
436
+ .saswp-enable-review-on-post label{
437
+ font-weight: 500;
438
+ }
admin_section/css/saswp-style.css ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .saswp-pc-wrap{
2
+ background-color: #004f74;
3
+ padding: 15px;
4
+ padding-left: 30px;
5
+ color: #fff;
6
+ display: inline-flex;
7
+ width: 100%;
8
+ flex-wrap: wrap;
9
+ margin-bottom: 20px;
10
+ }
11
+ .saswp-pc-wrap .saswp-lst span{
12
+ font-size: 18px;
13
+ font-weight: 500;
14
+ margin-bottom: 10px;
15
+ display: inline-block;
16
+ line-height: 1.3;
17
+ }
18
+ .saswp-pc-wrap .saswp-lst{
19
+ flex:1 0 42%;
20
+ }
21
+ .saswp-pc-wrap .saswp-lst ul{
22
+ margin:0;
23
+ }
24
+ .saswp-pc-wrap .saswp-lst p{
25
+ list-style-type: none;
26
+ font-size: 15px;
27
+ font-weight: lighter;
28
+ line-height: 1.2;
29
+ margin-bottom: 10px;
30
+ position: relative;
31
+ padding-left: 20px;
32
+ color:#eee;
33
+ }
34
+ .saswp-pc-wrap .saswp-lst p:before{
35
+ content: '';
36
+ position: absolute;
37
+ width: 8px;
38
+ height: 8px;
39
+ background-color: #ccc;
40
+ left: 0px;
41
+ top: 6px;
42
+ border-radius: 10px;
43
+ }
44
+ .sgl .saswp-rvw {
45
+ width: 100%;
46
+ margin-bottom: 34px;
47
+ font-size: 13px;
48
+ border-bottom: 1px solid #ededed;
49
+ }
50
+ .saswp-rvw-hd span {
51
+ background-color: #222;
52
+ color: #fff;
53
+ display: inline-block;
54
+ font-size: 15px;
55
+ line-height: 1.4;
56
+ padding: 8px 12px 6px;
57
+ margin: 26px 0px;
58
+ }
59
+ .saswp-rvw td {
60
+ padding: 7px 14px;
61
+ }
62
+ .sgl table td, .saswp-rvw td {
63
+ border: 1px solid #ededed;
64
+ }
65
+ .saswp-rvw tbody{
66
+ width:100%;
67
+ }
68
+ .saswp-rvw-sm span{
69
+ background-color: #222;
70
+ color: #fff;
71
+ display: inline-block;
72
+ padding: 8px 12px 6px;
73
+ margin-bottom: 13px;
74
+ position: relative;
75
+ font-size: 15px;
76
+ line-height: 1.2;
77
+ }
78
+ .saswp-rvw-fs {
79
+ line-height: 1.5;
80
+ font-size: 48px;
81
+ font-weight: 600;
82
+ margin-bottom: 5px;
83
+ }
84
+ .saswp-rvw-ov .ovs {
85
+ font-size: 11px;
86
+ font-weight:600;
87
+ }
88
+ .sgl .saswp-rvw tr td{
89
+ background:#fff;
90
+ width:100%;
91
+ }
92
+ .sgl .saswp-rvw tr:hover td {
93
+ background-color: #fcfcfc;
94
+ }
95
+ .saswp-rvw .saswp-rvw-sm {
96
+ padding: 21px 14px;
97
+ }
98
+ .str-ic{
99
+ font-size: 18px;
100
+ line-height: 1.2;
101
+ }
102
+ .saswp-rvw-str{
103
+ display: inline-flex;
104
+ width: 100%;
105
+ }
106
+ .saswp-rvw-ov{
107
+ text-align:center;
108
+ }
109
+ .saswp-rvw-str .half-str{
110
+ display:inline-block;
111
+ width: 20px;
112
+ height: 16px;
113
+ background-repeat: no-repeat;
114
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0ODIuMjA3IDQ4Mi4yMDciIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ4Mi4yMDcgNDgyLjIwNzsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8cGF0aCBkPSJNNDgyLjIwNywxODYuOTczbC0xNTkuNjk5LTMzLjcwNUwyNDEuMTA0LDExLjgwM2wtODEuNDA0LDE0MS40NjVMMCwxODYuOTczbDEwOS4zODgsMTIxLjEzNEw5Mi4wOTQsNDcwLjQwNGwxNDkuMDEtNjYuNiAgbDE0OS4wMSw2Ni42bC0xNy4yOTQtMTYyLjI5Nkw0ODIuMjA3LDE4Ni45NzN6IE0yNDEuMTA0LDM3MC45NDNWNzEuOTUzbDYyLjA5LDEwNy45TDQyNSwyMDUuNTYxbC04My40MzMsOTIuMzkzbDEzLjE5MSwxMjMuNzg4ICBMMjQxLjEwNCwzNzAuOTQzeiIgZmlsbD0iI2ZmZDcwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);
115
+ }
116
+ .saswp-rvw-str .str-ic{
117
+ display:inline-block;
118
+ width: 20px;
119
+ height: 16px;
120
+ background-repeat: no-repeat;
121
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0ODIuMjA3IDQ4Mi4yMDciIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ4Mi4yMDcgNDgyLjIwNzsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8cG9seWdvbiBwb2ludHM9IjQ4Mi4yMDcsMTg2Ljk3MyAzMjIuNTA4LDE1My4yNjkgMjQxLjEwNCwxMS44MDMgMTU5LjY5OSwxNTMuMjY5IDAsMTg2Ljk3MyAxMDkuMzg4LDMwOC4xMDggOTIuMDk0LDQ3MC40MDQgICAyNDEuMTA0LDQwMy44MDMgMzkwLjExMyw0NzAuNDA0IDM3Mi44MTgsMzA4LjEwOCAiIGZpbGw9IiNmZmQ3MDAiLz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==);
122
+ }
123
+ .saswp-rvw-str .df-clr{
124
+ display:inline-block;
125
+ width: 20px;
126
+ height: 16px;
127
+ background-repeat: no-repeat;
128
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0ODIuMjA3IDQ4Mi4yMDciIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ4Mi4yMDcgNDgyLjIwNzsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8cG9seWdvbiBwb2ludHM9IjQ4Mi4yMDcsMTg2Ljk3MyAzMjIuNTA4LDE1My4yNjkgMjQxLjEwNCwxMS44MDMgMTU5LjY5OSwxNTMuMjY5IDAsMTg2Ljk3MyAxMDkuMzg4LDMwOC4xMDggOTIuMDk0LDQ3MC40MDQgICAyNDEuMTA0LDQwMy44MDMgMzkwLjExMyw0NzAuNDA0IDM3Mi44MTgsMzA4LjEwOCAiIGZpbGw9IiM2MzVlNjMiLz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==);
129
+ }
admin_section/fields-generator.php CHANGED
@@ -49,7 +49,8 @@ class saswp_fields_generator {
49
  case 'media':
50
  $mediavalue = $settings[$meta_field['id']];
51
  $input = sprintf(
52
- '<fieldset><input class="%s" style="width: 80%%" id="%s" name="%s" type="text" value="%s"> <input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
 
53
  . '<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($mediavalue['id']).'">'
54
  . '<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($mediavalue['height']).'">'
55
  . '<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($mediavalue['width']).'">'
49
  case 'media':
50
  $mediavalue = $settings[$meta_field['id']];
51
  $input = sprintf(
52
+ '<fieldset><input class="%s" style="width: 80%%" id="%s" name="%s" type="text" value="%s">'
53
+ . '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
54
  . '<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($mediavalue['id']).'">'
55
  . '<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($mediavalue['height']).'">'
56
  . '<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($mediavalue['width']).'">'
admin_section/js/main-script.js CHANGED
@@ -218,6 +218,16 @@ jQuery(document).ready(function($){
218
  $("#saswp_compativility").val(0);
219
  }
220
  break;
 
 
 
 
 
 
 
 
 
 
221
  default:
222
  break;
223
  }
@@ -245,7 +255,7 @@ jQuery(document).ready(function($){
245
 
246
  }
247
  }).change();
248
- $("input[data-id=media]").click(function(e) { // Application Icon upload
249
  e.preventDefault();
250
  var button = $(this);
251
  var id = button.attr('id').replace('_button', '');
@@ -329,6 +339,130 @@ jQuery(document).ready(function($){
329
  },'json');
330
  });
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  //Importer from schema plugin ends here
333
 
334
  });
218
  $("#saswp_compativility").val(0);
219
  }
220
  break;
221
+
222
+ case 'saswp-review-module-checkbox':
223
+
224
+ if ($(this).is(':checked')) {
225
+ $("#saswp-review-module").val(1);
226
+ }else{
227
+ $("#saswp-review-module").val(0);
228
+ }
229
+ break;
230
+
231
  default:
232
  break;
233
  }
255
 
256
  }
257
  }).change();
258
+ $(document).on("click", "input[data-id=media]" ,function(e) { // Application Icon upload
259
  e.preventDefault();
260
  var button = $(this);
261
  var id = button.attr('id').replace('_button', '');
339
  },'json');
340
  });
341
 
342
+ $(document).on("change",'.saswp-local-business-type-select', function(e){
343
+ e.preventDefault();
344
+ var current = $(this);
345
+ var business_type = $(this).val();
346
+ $.get(ajaxurl,
347
+ { action:"saswp_get_sub_business_ajax", business_type:business_type, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
348
+ function(response){
349
+
350
+ if(response['status'] =='t'){
351
+ $(".saswp-local-business-name-select").parents('tr').remove();
352
+ var schema_id = current.parents('.saswp-post-specific-wrapper').attr('data-id');
353
+ var html ='<tr><th><label for="saswp_business_name_'+schema_id+'">Sub Business Type</label></th>';
354
+ html +='<td><select class="saswp-local-business-name-select" id="saswp_business_name_'+schema_id+'" name="saswp_business_name_'+schema_id+'">';
355
+ $.each(response['result'], function(index, element){
356
+ html +='<option value="'+index+'">'+element+'</option>';
357
+ });
358
+ html +='</select></td>';
359
+ html +='</tr>';
360
+ current.parents('.form-table tr:first').after(html);
361
+ }else{
362
+ $(".saswp-local-business-name-select").parents('tr').remove();
363
+ }
364
+ },'json');
365
+ });
366
+ function saswpAddTimepicker(){
367
+ $('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
368
+ }
369
+ $('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
370
+ $(".saswp-modify_schema_post_enable").on("click", function(e){
371
+ $(this).remove();
372
+ e.preventDefault();
373
+ $.get(ajaxurl,
374
+ { action:"saswp_modify_schema_post_enable", post_id: saswp_localize_data.post_id,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
375
+ function(response){
376
+ $("#post_specific .inside").append(response);
377
+ saswpAddTimepicker();
378
+ });
379
+ });
380
+
381
+ $('.saswp-local-schema-datepicker-picker').datepicker({
382
+ dateFormat: "yy-mm-dd",
383
+ minDate: 0
384
+
385
+ });
386
+
387
+ //Review js starts here
388
+
389
+ $(document).on("click", ".saswp-add-more-item",function(e){
390
+ e.preventDefault();
391
+ var rows = $('.saswp-review-item-list-table tr').length;
392
+ console.log(rows);
393
+ var html = '<tr class="saswp-review-item-tr">';
394
+ html += '<td>Review Item Feature</td>';
395
+ html += '<td><input type="text" name="saswp-review-item-feature[]"></td>';
396
+ html += '<td>Rating</td>';
397
+ html += '<td><input step="0.1" min="0" max="5" type="number" name="saswp-review-item-star-rating[]"></td>';
398
+ html += '<td><a type="button" class="saswp-remove-review-item button">x</a></td>';
399
+ html += '</tr>';
400
+ $(".saswp-review-item-list-table").append(html);
401
+
402
+ });
403
+
404
+ $(document).on("click", ".saswp-remove-review-item", function(e){
405
+ e.preventDefault();
406
+ $(this).parent().parent('tr').remove();
407
+ });
408
+
409
+ $(document).on("focusout", ".saswp-review-item-tr input[type=number]", function(e){
410
+ e.preventDefault();
411
+ var total_rating = 0;
412
+ var element_count = $(".saswp-review-item-tr input[type=number]").length;
413
+ $(".saswp-review-item-tr input[type=number]").each(function(index, element){
414
+ if($(element).val() ==''){
415
+ total_rating += parseFloat(0);
416
+ }else{
417
+ total_rating += parseFloat($(element).val());
418
+ }
419
+
420
+ });
421
+ var over_all_rating = total_rating / element_count;
422
+ $("#saswp-review-item-over-all").val(over_all_rating);
423
+ });
424
+
425
+ $("#saswp-review-location").change(function(){
426
+ var location = $(this).val();
427
+ $(".saswp-review-shortcode").addClass('saswp_hide');
428
+ if(location == 3){
429
+ $(".saswp-review-shortcode").removeClass('saswp_hide');
430
+ }
431
+ }).change();
432
+
433
+ $("#saswp-review-item-enable").change(function(){
434
+ if ($(this).is(':checked')) {
435
+ $(".saswp-review-fields").show();
436
+ }else{
437
+ $(".saswp-review-fields").hide();
438
+ }
439
+ }).change();
440
+
441
+ $(".saswp-restore-post-schema").on("click", function(e){
442
+ e.preventDefault();
443
+ var schema_ids = JSON.parse($(".saswp-post-specific-schema-ids").val());
444
+ $.post(ajaxurl,
445
+ { action:"saswp_restore_schema", schema_ids:schema_ids,post_id: saswp_localize_data.post_id, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
446
+ function(response){
447
+ if(response['status'] =='t'){
448
+ setTimeout(function(){ location.reload(); }, 1000);
449
+ }else{
450
+ alert(response['msg']);
451
+ }
452
+ },'json');
453
+ });
454
+
455
+ //Review js ends here
456
+
457
+ $(document).on("click","div.saswp-tab ul.saswp-tab-nav a", function(e){
458
+ e.preventDefault();
459
+ var attr = $(this).attr('data-id');
460
+ $(".saswp-post-specific-wrapper").hide();
461
+ $("#"+attr).show();
462
+ $('div.saswp-tab ul.saswp-tab-nav a').removeClass('selected');
463
+ $(this).addClass('selected');
464
+ });
465
+
466
  //Importer from schema plugin ends here
467
 
468
  });
admin_section/js/structure_admin.js CHANGED
@@ -27,15 +27,12 @@ var clone = function(){
27
  });
28
  }
29
  jQuery(document).ready(function($){
30
- if(saswp_app_object.post_type ==='saswp' && saswp_app_object.post_found_status ==='not_found'){
31
- var html = '<div>';
32
- html += '<p><span class="dashicons dashicons-thumbs-up"></span>'+saswp_app_object.thankyou+' <a href="'+saswp_app_object.wizard_url+'">'+saswp_app_object.quicksetup+'</a></p>';
33
- html += '</div>';
34
- $(".wp-list-table .colspanchange").html(html);
35
- }
36
  $('#saswp-dayofweek-opens-time').timepicker({ 'timeFormat': 'H:i:s'});
37
  $('#saswp-dayofweek-closes-time').timepicker({ 'timeFormat': 'H:i:s'});
38
 
 
 
39
  $(".saswp-placement-or-group").on("click", function(e){
40
  e.preventDefault();
41
  var group_index ='';
27
  });
28
  }
29
  jQuery(document).ready(function($){
30
+
 
 
 
 
 
31
  $('#saswp-dayofweek-opens-time').timepicker({ 'timeFormat': 'H:i:s'});
32
  $('#saswp-dayofweek-closes-time').timepicker({ 'timeFormat': 'H:i:s'});
33
 
34
+
35
+
36
  $(".saswp-placement-or-group").on("click", function(e){
37
  e.preventDefault();
38
  var group_index ='';
admin_section/plugin-installer/install.php CHANGED
@@ -66,12 +66,16 @@
66
  return ;
67
  }
68
  global $saswp_installer_config;
69
- saswp_steps_call();
 
 
 
 
70
  }
71
 
72
  function saswp_steps_call(){
73
  global $saswp_installer_config;
74
- if ( empty( $_GET['page'] ) || $saswp_installer_config['installerpage'] !== $_GET['page'] ) {
75
  return;
76
  }
77
  if ( ob_get_length() ) {
66
  return ;
67
  }
68
  global $saswp_installer_config;
69
+
70
+ if( wp_verify_nonce($_GET['_saswp_nonce'], 'saswp_install_wizard_nonce')){
71
+ saswp_steps_call();
72
+ }
73
+
74
  }
75
 
76
  function saswp_steps_call(){
77
  global $saswp_installer_config;
78
+ if ( !wp_verify_nonce($_GET['_saswp_nonce'], 'saswp_install_wizard_nonce') || empty( $_GET['page'] ) || $saswp_installer_config['installerpage'] !== $_GET['page'] ) {
79
  return;
80
  }
81
  if ( ob_get_length() ) {
admin_section/settings.php CHANGED
@@ -6,8 +6,9 @@
6
  */
7
  add_action( 'plugin_action_links_' . plugin_basename( SASWP_DIR_NAME_FILE ), 'saswp_plugin_action_links' );
8
  function saswp_plugin_action_links( $links ) {
 
9
  $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>';
10
- $links[] = '<a href="'. esc_url( admin_url( 'plugins.php?page=saswp-setup-wizard' ) ).'">' . esc_html__( 'Start setup wizard &raquo;', 'schema-and-structured-data-for-wp' ) . '</a>';
11
  return $links;
12
  }
13
 
@@ -32,9 +33,9 @@ function saswp_admin_interface_render(){
32
  $is_amp = true;
33
  }
34
  if($is_amp){
35
- $tab = saswp_get_tab('general', array('general','knowledge','schema', 'tools', 'amp','support'));
36
  }else{
37
- $tab = saswp_get_tab('general', array('general','knowledge','schema','tools' ,'support'));
38
  }
39
 
40
  ?>
@@ -56,12 +57,14 @@ function saswp_admin_interface_render(){
56
 
57
  echo '<a href="' . esc_url(saswp_admin_link('schema')) . '" class="nav-tab ' . esc_attr( $tab == 'schema' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Misc','schema-and-structured-data-for-wp') . '</a>';
58
 
 
 
59
  echo '<a href="' . esc_url(saswp_admin_link('support')) . '" class="nav-tab ' . esc_attr( $tab == 'support' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Support','schema-and-structured-data-for-wp') . '</a>';
60
  ?>
61
 
62
  </h2>
63
  </div>
64
- <form action="options.php" method="post" enctype="multipart/form-data" class="saswp-settings-form">
65
  <div class="form-wrap saswp-settings-form-wrap">
66
  <?php
67
  // Output nonce, action, and option_page fields for a settings page.
@@ -87,7 +90,12 @@ function saswp_admin_interface_render(){
87
  // Status
88
  do_settings_sections( 'saswp_tools_section' ); // Page slug
89
  echo "</div>";
90
-
 
 
 
 
 
91
  echo "<div class='saswp-support' ".( $tab != 'support' ? 'style="display:none;"' : '').">";
92
  // Status
93
  do_settings_sections( 'saswp_support_section' ); // Page slug
@@ -105,7 +113,9 @@ function saswp_admin_interface_render(){
105
  </form>
106
  </div>
107
  <div class="saswp-settings-second-div">
108
- <p style="float:left;"><?php echo esc_html('Need Quick Setup?', 'schema-and-structured-data-for-wp'); ?></p><a href="<?php echo esc_url( admin_url( 'plugins.php?page=saswp-setup-wizard' ) ); ?>" class="page-title-action saswp-start-quck-setup button button-primary"><?php echo esc_html('Try Installation Wizard', 'schema-and-structured-data-for-wp'); ?></a>
 
 
109
  <div class="saswp-feedback-panel">
110
 
111
  <h2><?php echo esc_html__( 'Leave A Feedback', 'schema-and-structured-data-for-wp' ); ?></h2>
@@ -178,6 +188,18 @@ function saswp_settings_init(){
178
  'saswp_amp_section' // Settings Section ID
179
  );
180
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  add_settings_section('saswp_support_section', __return_false(), '__return_false', 'saswp_support_section');
182
 
183
  add_settings_field(
@@ -269,7 +291,7 @@ function saswp_schema_page_callback(){
269
  }
270
 
271
  function saswp_amp_page_callback(){
272
- $settings = saswp_defaultSettings();
273
  $field_objs = new saswp_fields_generator();
274
  $meta_fields = array(
275
 
@@ -752,7 +774,7 @@ function saswp_import_callback(){
752
  <div class="saswp-tools-field-title"><div class="saswp-tooltip"><strong><?php echo esc_html__('Import All Settings & Schema','schema-and-structured-data-for-wp'); ?></strong></div><input type="file" name="saswp_import_backup" id="saswp_import_backup">
753
  </div>
754
  </li>
755
- </ul>
756
  <?php
757
 
758
  $settings = saswp_defaultSettings();
@@ -852,6 +874,30 @@ function saswp_imported_callback(){
852
  ?>
853
  <?php
854
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
  function saswp_support_page_callback(){
856
 
857
  ?>
@@ -865,7 +911,7 @@ function saswp_support_page_callback(){
865
  <span class="saswp-query-success saswp_hide"><?php echo esc_html__('Message sent successfully, Please wait we will get back to you shortly', 'schema-and-structured-data-for-wp'); ?></span>
866
  <span class="saswp-query-error saswp_hide"><?php echo esc_html__('Message not sent. please check your network connection', 'schema-and-structured-data-for-wp'); ?></span>
867
  </li>
868
- <li><button class="button saswp-send-query"><?php echo esc_html('Send Message', 'schema-and-structured-data-for-wp'); ?></button></li>
869
  </ul>
870
 
871
  </div>
@@ -901,6 +947,7 @@ function saswp_enqueue_style_js( $hook ) {
901
  wp_register_script( 'saswp-main-js', SASWP_PLUGIN_URL . 'admin_section/js/main-script.js', array('jquery'), SASWP_VERSION , true );
902
 
903
  $data = array(
 
904
  'ajax_url' => admin_url( 'admin-ajax.php' ),
905
  'saswp_security_nonce' => wp_create_nonce('saswp_ajax_check_nonce')
906
  );
6
  */
7
  add_action( 'plugin_action_links_' . plugin_basename( SASWP_DIR_NAME_FILE ), 'saswp_plugin_action_links' );
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
 
33
  $is_amp = true;
34
  }
35
  if($is_amp){
36
+ $tab = saswp_get_tab('general', array('general','knowledge','schema', 'tools', 'amp','review','support'));
37
  }else{
38
+ $tab = saswp_get_tab('general', array('general','knowledge','schema','tools' ,'review','support'));
39
  }
40
 
41
  ?>
57
 
58
  echo '<a href="' . esc_url(saswp_admin_link('schema')) . '" class="nav-tab ' . esc_attr( $tab == 'schema' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Misc','schema-and-structured-data-for-wp') . '</a>';
59
 
60
+ echo '<a href="' . esc_url(saswp_admin_link('review')) . '" class="nav-tab ' . esc_attr( $tab == 'review' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Review','schema-and-structured-data-for-wp') . '</a>';
61
+
62
  echo '<a href="' . esc_url(saswp_admin_link('support')) . '" class="nav-tab ' . esc_attr( $tab == 'support' ? 'nav-tab-active' : '') . '"><span class=""></span> ' . esc_html__('Support','schema-and-structured-data-for-wp') . '</a>';
63
  ?>
64
 
65
  </h2>
66
  </div>
67
+ <form action="<?php echo admin_url("options.php") ?>" method="post" enctype="multipart/form-data" class="saswp-settings-form">
68
  <div class="form-wrap saswp-settings-form-wrap">
69
  <?php
70
  // Output nonce, action, and option_page fields for a settings page.
90
  // Status
91
  do_settings_sections( 'saswp_tools_section' ); // Page slug
92
  echo "</div>";
93
+
94
+ echo "<div class='saswp-review' ".( $tab != 'review' ? 'style="display:none;"' : '').">";
95
+ // Status
96
+ do_settings_sections( 'saswp_review_section' ); // Page slug
97
+ echo "</div>";
98
+
99
  echo "<div class='saswp-support' ".( $tab != 'support' ? 'style="display:none;"' : '').">";
100
  // Status
101
  do_settings_sections( 'saswp_support_section' ); // Page slug
113
  </form>
114
  </div>
115
  <div class="saswp-settings-second-div">
116
+ <p style="float:left;"><?php
117
+ $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
118
+ echo esc_html('Need Quick Setup?', 'schema-and-structured-data-for-wp'); ?></p><a href="<?php echo esc_url(admin_url( 'plugins.php?page=saswp-setup-wizard' ).'&_saswp_nonce='.$nonce); ?>" class="page-title-action saswp-start-quck-setup button button-primary"><?php echo esc_html('Try Installation Wizard', 'schema-and-structured-data-for-wp'); ?></a>
119
  <div class="saswp-feedback-panel">
120
 
121
  <h2><?php echo esc_html__( 'Leave A Feedback', 'schema-and-structured-data-for-wp' ); ?></h2>
188
  'saswp_amp_section' // Settings Section ID
189
  );
190
 
191
+
192
+ add_settings_section('saswp_review_section', __return_false(), '__return_false', 'saswp_review_section');
193
+
194
+ add_settings_field(
195
+ 'saswp_review_settings', // ID
196
+ '', // Title
197
+ 'saswp_review_page_callback', // CB
198
+ 'saswp_review_section', // Page slug
199
+ 'saswp_review_section' // Settings Section ID
200
+ );
201
+
202
+
203
  add_settings_section('saswp_support_section', __return_false(), '__return_false', 'saswp_support_section');
204
 
205
  add_settings_field(
291
  }
292
 
293
  function saswp_amp_page_callback(){
294
+ $settings = saswp_defaultSettings();
295
  $field_objs = new saswp_fields_generator();
296
  $meta_fields = array(
297
 
774
  <div class="saswp-tools-field-title"><div class="saswp-tooltip"><strong><?php echo esc_html__('Import All Settings & Schema','schema-and-structured-data-for-wp'); ?></strong></div><input type="file" name="saswp_import_backup" id="saswp_import_backup">
775
  </div>
776
  </li>
777
+ </ul>
778
  <?php
779
 
780
  $settings = saswp_defaultSettings();
874
  ?>
875
  <?php
876
  }
877
+
878
+ function saswp_review_page_callback(){
879
+
880
+ $settings = saswp_defaultSettings();
881
+ $field_objs = new saswp_fields_generator();
882
+ $meta_fields = array(
883
+ array(
884
+ 'label' => 'Review Module',
885
+ 'id' => 'saswp-review-module-checkbox',
886
+ 'name' => 'saswp-review-module-checkbox',
887
+ 'type' => 'checkbox',
888
+ 'class' => 'checkbox saswp-checkbox',
889
+ 'hidden' => array(
890
+ 'id' => 'saswp-review-module',
891
+ 'name' => 'sd_data[saswp-review-module]',
892
+ )
893
+ ),
894
+
895
+ );
896
+ //echo '<h2>'.esc_html__('Set Up','schema-and-structured-data-for-wp').'</h2>';
897
+ $field_objs->saswp_field_generator($meta_fields, $settings);
898
+
899
+ }
900
+
901
  function saswp_support_page_callback(){
902
 
903
  ?>
911
  <span class="saswp-query-success saswp_hide"><?php echo esc_html__('Message sent successfully, Please wait we will get back to you shortly', 'schema-and-structured-data-for-wp'); ?></span>
912
  <span class="saswp-query-error saswp_hide"><?php echo esc_html__('Message not sent. please check your network connection', 'schema-and-structured-data-for-wp'); ?></span>
913
  </li>
914
+ <li><button class="button saswp-send-query"><?php echo esc_html__('Send Message', 'schema-and-structured-data-for-wp'); ?></button></li>
915
  </ul>
916
 
917
  </div>
947
  wp_register_script( 'saswp-main-js', SASWP_PLUGIN_URL . 'admin_section/js/main-script.js', array('jquery'), SASWP_VERSION , true );
948
 
949
  $data = array(
950
+ 'post_id' => get_the_ID(),
951
  'ajax_url' => admin_url( 'admin-ajax.php' ),
952
  'saswp_security_nonce' => wp_create_nonce('saswp_ajax_check_nonce')
953
  );
admin_section/structure_admin.php CHANGED
@@ -315,8 +315,8 @@ function saswp_comparison_logic_checker($input){
315
  if(is_admin()){
316
  add_action( 'init', 'saswp_create_post_type' );
317
  function saswp_create_post_type() {
318
-
319
-
320
  register_post_type( 'saswp',
321
  array(
322
  'labels' => array(
@@ -325,7 +325,8 @@ if(is_admin()){
325
  'add_new' => esc_html__( 'Add Schema Type', 'schema-and-structured-data-for-wp' ),
326
  'add_new_item' => esc_html__( '', 'schema-and-structured-data-for-wp' ),
327
  'edit_item' => esc_html__( 'Edit Schema Type','schema-and-structured-data-for-wp'),
328
- 'all_items' => esc_html__( 'Schema Types', 'schema-and-structured-data-for-wp' ),
 
329
  ),
330
  'public' => true,
331
  'has_archive' => false,
@@ -347,12 +348,12 @@ if(is_admin()){
347
 
348
  add_action( 'admin_head','saswp_change_add_new_url');
349
  function saswp_change_add_new_url() {
350
- $admin_url = admin_url();
351
  ?>
352
 
353
  <script type="text/javascript">
354
  jQuery(function($) {
355
- $('a[href="<?php echo $admin_url; ?>post-new.php?post_type=saswp"]').attr( 'href', '<?php echo $admin_url; ?>index.php?page=saswp_add_new_data_type' );
356
  });
357
  </script>
358
  <?php
@@ -510,10 +511,7 @@ $admin_url = admin_url();
510
  $data_array = array(
511
  'ajax_url' => admin_url( 'admin-ajax.php' ),
512
  'post_found_status' => $post_found_status,
513
- 'post_type' =>$post_type,
514
- 'wizard_url' => esc_url( admin_url( 'plugins.php?page=saswp-setup-wizard' ) ),
515
- 'thankyou' => esc_html__("Thank you for using Schema & Structured Data For WP plugin!",'schema-and-structured-data-for-wp'),
516
- 'quicksetup' => esc_html__("Start Quick Setup?",'schema-and-structured-data-for-wp')
517
  );
518
  wp_localize_script( 'structure_admin', 'saswp_app_object', $data_array );
519
  wp_enqueue_script('structure_admin');
@@ -521,11 +519,15 @@ $admin_url = admin_url();
521
  wp_enqueue_script( 'saswp-timepicker-js', SASWP_PLUGIN_URL . 'admin_section/js/jquery.timepicker.js', false, SASWP_VERSION);
522
  //Main Css
523
  wp_enqueue_style( 'saswp-timepicker-css', SASWP_PLUGIN_URL . 'admin_section/css/jquery.timepicker.css', false , SASWP_VERSION );
 
 
 
 
524
 
525
 
526
  }
527
  }
528
-
529
  // Save PHP Editor
530
  add_action ( 'save_post' , 'saswp_select_save_data' );
531
  function saswp_select_save_data ( $post_id ) {
315
  if(is_admin()){
316
  add_action( 'init', 'saswp_create_post_type' );
317
  function saswp_create_post_type() {
318
+ $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
319
+ $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>';
320
  register_post_type( 'saswp',
321
  array(
322
  'labels' => array(
325
  'add_new' => esc_html__( 'Add Schema Type', 'schema-and-structured-data-for-wp' ),
326
  'add_new_item' => esc_html__( '', 'schema-and-structured-data-for-wp' ),
327
  'edit_item' => esc_html__( 'Edit Schema Type','schema-and-structured-data-for-wp'),
328
+ 'all_items' => esc_html__( 'Schema Types', 'schema-and-structured-data-for-wp' ),
329
+ 'not_found' => $not_found_button
330
  ),
331
  'public' => true,
332
  'has_archive' => false,
348
 
349
  add_action( 'admin_head','saswp_change_add_new_url');
350
  function saswp_change_add_new_url() {
351
+
352
  ?>
353
 
354
  <script type="text/javascript">
355
  jQuery(function($) {
356
+ $('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')); ?>');
357
  });
358
  </script>
359
  <?php
511
  $data_array = array(
512
  'ajax_url' => admin_url( 'admin-ajax.php' ),
513
  'post_found_status' => $post_found_status,
514
+ 'post_type' =>$post_type,
 
 
 
515
  );
516
  wp_localize_script( 'structure_admin', 'saswp_app_object', $data_array );
517
  wp_enqueue_script('structure_admin');
519
  wp_enqueue_script( 'saswp-timepicker-js', SASWP_PLUGIN_URL . 'admin_section/js/jquery.timepicker.js', false, SASWP_VERSION);
520
  //Main Css
521
  wp_enqueue_style( 'saswp-timepicker-css', SASWP_PLUGIN_URL . 'admin_section/css/jquery.timepicker.css', false , SASWP_VERSION );
522
+
523
+ wp_enqueue_script( 'jquery-ui-datepicker' );
524
+ wp_register_style( 'jquery-ui', 'https://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
525
+ wp_enqueue_style( 'jquery-ui' );
526
 
527
 
528
  }
529
  }
530
+
531
  // Save PHP Editor
532
  add_action ( 'save_post' , 'saswp_select_save_data' );
533
  function saswp_select_save_data ( $post_id ) {
output/function.php CHANGED
@@ -10,7 +10,8 @@ function saswp_structured_data()
10
  }
11
  add_action('wp_head', 'saswp_data_generator');
12
  function saswp_data_generator() {
13
- global $sd_data;
 
14
  $output ='';
15
  $contact_page_output = saswp_contact_page_output();
16
  $about_page_output = saswp_about_page_output();
@@ -18,7 +19,14 @@ function saswp_data_generator() {
18
  $archive_output = saswp_archive_output();
19
  $kb_website_output = saswp_kb_website_output();
20
  $schema_breadcrumb_output = saswp_schema_breadcrumb_output($sd_data);
 
 
 
 
 
 
21
  $schema_output = saswp_schema_output();
 
22
  if($schema_output || $schema_breadcrumb_output || $kb_website_output || $archive_output || $author_output || $about_page_output || $contact_page_output){
23
  add_filter( 'amp_post_template_metadata', 'saswp_remove_amp_default_structure_data');
24
  }
@@ -150,4 +158,5 @@ function saswp_memberpress_form_update($form){
150
  $form = '<a class="amp-mem-login" href="'.wp_login_url( $redirect ) .'">'.esc_html__( 'Login', 'schema-and-structured-data-for-wp' ).'</a>';
151
  }
152
  return $form;
153
- }
 
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();
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
+ $post_specific_enable = $option = get_option('modify_schema_post_enable_'.$post->ID);
24
+
25
+ if($post_specific_enable =='enable'){
26
+ $schema_output = saswp_post_specific_schema_output();
27
+ }else{
28
  $schema_output = saswp_schema_output();
29
+ }
30
  if($schema_output || $schema_breadcrumb_output || $kb_website_output || $archive_output || $author_output || $about_page_output || $contact_page_output){
31
  add_filter( 'amp_post_template_metadata', 'saswp_remove_amp_default_structure_data');
32
  }
158
  $form = '<a class="amp-mem-login" href="'.wp_login_url( $redirect ) .'">'.esc_html__( 'Login', 'schema-and-structured-data-for-wp' ).'</a>';
159
  }
160
  return $form;
161
+ }
162
+
output/output.php CHANGED
@@ -173,12 +173,12 @@ function saswp_schema_output() {
173
  }
174
  if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
175
  return ;
176
- }
177
  $all_schema_output = array();
178
  foreach($Conditionals as $schemaConditionals){
179
 
180
  $schema_options = $schemaConditionals['schema_options'];
181
- $schema_type = $schemaConditionals['schema_type'];
182
  $schema_post_id = $schemaConditionals['post_id'];
183
  $logo = $sd_data['sd_logo']['url'];
184
  if( '' == $logo && empty($logo) && isset($sd_data['sd_default_image'])){
@@ -203,7 +203,28 @@ function saswp_schema_output() {
203
  $date = get_the_date("Y-m-d\TH:i:s\Z");
204
  $modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
205
  $aurthor_name = get_the_author();
206
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  if(is_page()){
208
  $schema_type = $schema_type; //$sd_data['sd_page_type'];
209
  }
@@ -240,6 +261,7 @@ function saswp_schema_output() {
240
  );
241
  // For WebPage
242
  if( 'WebPage' === $schema_type){
 
243
  if(empty($image_details[0]) || $image_details[0] === NULL ){
244
  $image_details[0] = $logo;
245
  }
@@ -271,15 +293,20 @@ function saswp_schema_output() {
271
  ),
272
  'name' => $sd_data['sd_name'],
273
  ),
 
274
  ),
275
 
276
 
277
  );
 
 
 
278
  }
279
 
280
  // For Article
281
 
282
  if( 'Article' === $schema_type ){
 
283
  $input1 = array(
284
  '@context' => 'http://schema.org',
285
  '@type' => 'Article',
@@ -291,7 +318,8 @@ function saswp_schema_output() {
291
  'dateModified' => $modified_date,
292
  'author' => array(
293
  '@type' => 'Person',
294
- 'name' => $aurthor_name, ),
 
295
  'Publisher' => array(
296
  '@type' => 'Organization',
297
  'logo' => array(
@@ -302,11 +330,13 @@ function saswp_schema_output() {
302
  ),
303
  'name' => $sd_data['sd_name'],
304
  ),
 
305
  );
306
  }
307
 
308
  // Recipe
309
  if( 'Recipe' === $schema_type){
 
310
  if(empty($image_details[0]) || $image_details[0] === NULL ){
311
  $image_details[0] = $sd_data['sd_logo']['url'];
312
  }
@@ -341,15 +371,20 @@ function saswp_schema_output() {
341
  ),
342
  'name' => $sd_data['sd_name'],
343
  ),
344
- ),
345
-
 
346
 
347
  );
 
 
 
348
  }
349
 
350
  // Product
351
 
352
  if( 'Product' === $schema_type){
 
353
  if(empty($image_details[0]) || $image_details[0] === NULL ){
354
  $image_details[0] = $logo;
355
  }
@@ -358,27 +393,17 @@ function saswp_schema_output() {
358
  '@type' => $schema_type ,
359
  'url' => get_permalink(),
360
  'name' => get_the_title(),
361
- 'description' => get_the_excerpt(),
362
- 'mainEntity' => array(
363
- '@type' => 'WebPage',
364
- '@id' => get_permalink(),
365
- ),
366
-
367
-
368
  );
 
 
 
369
  }
370
-
371
- // VideoObject
372
- if( 'VideoObject' === $schema_type){
373
- if(empty($image_details[0]) || $image_details[0] === NULL ){
374
- $image_details[0] = $sd_data['sd_logo']['url'];
375
- }
376
-
377
- if( 'NewsArticle' === $schema_type ){
378
  $input1 = array(
379
  '@context' => 'http://schema.org',
380
- '@type' => $schema_type ,
381
- '@type' => $schema_type,
382
  'mainEntityOfPage' => get_permalink(),
383
  'url' => get_permalink(),
384
  'headline' => get_the_title(),
@@ -410,10 +435,19 @@ function saswp_schema_output() {
410
  'height' => $sd_data['sd_logo']['height'],
411
  ),
412
  'name' => $sd_data['sd_name'],
413
- ),
414
  );
 
 
 
415
  }
416
- else {
 
 
 
 
 
 
417
 
418
  $input1 = array(
419
  '@context' => 'http://schema.org',
@@ -449,9 +483,13 @@ function saswp_schema_output() {
449
  'height' => $sd_data['sd_logo']['height'],
450
  ),
451
  'name' => $sd_data['sd_name'],
452
- ),
 
453
  );
454
- }
 
 
 
455
  }
456
 
457
  if( 'local_business' === $schema_type){
@@ -476,10 +514,9 @@ function saswp_schema_output() {
476
  $input1 = array(
477
  '@context' => 'http://schema.org',
478
  '@type' => $local_business ,
479
- 'url' => get_permalink(),
480
- 'name' => $business_details['local_business_name'],
481
- //'description' => get_the_excerpt(),
482
- '@id' => get_permalink(),
483
  'address' => array(
484
  "@type" => "PostalAddress",
485
  "streetAddress" => $business_details['local_street_address'],
@@ -493,8 +530,12 @@ function saswp_schema_output() {
493
  'dayOfWeek' => $business_details['saswp_dayofweek'],
494
  'opens' => $business_details['local_opens_time'],
495
  'closes'=> $business_details['local_closes_time'],
496
- ),
 
497
  );
 
 
 
498
 
499
  if(isset($business_details['local_price_range'])){
500
  $input1['priceRange'] = $business_details['local_price_range'];
@@ -568,6 +609,376 @@ function saswp_schema_output() {
568
  return $all_schema_output;
569
  }
570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
  function saswp_structure_data_access_scripts($data){
572
  if ( empty( $data['amp_component_scripts']['amp-access'] ) ) {
573
  $data['amp_component_scripts']['amp-access'] = 'https://cdn.ampproject.org/v0/amp-access-0.1.js';
@@ -609,15 +1020,6 @@ function saswp_list_items_generator(){
609
  );
610
  $j++;
611
  }}
612
- $breadcrumbslist[] = array(
613
- '@type' =>'ListItem',
614
- 'position' => $j,
615
- 'item' => array(
616
- '@id' => get_permalink(),
617
- 'name' => get_the_title(),
618
-
619
- ),
620
- );
621
 
622
  }
623
  if(is_page()){
@@ -740,11 +1142,11 @@ function saswp_archive_output(){
740
 
741
  wp_reset_postdata();
742
 
743
- $category = get_the_category();
744
  $category_id = intval($category[0]->term_id);
745
- $category_link = get_category_link( $category_id );
746
- $category_link = get_term_link( $category[0]->term_id , 'category' );
747
- $category_headline = single_cat_title( '', false ) . __(' Category', 'schema-wp');
748
  $input = array
749
  (
750
  '@context' => 'http://schema.org/',
173
  }
174
  if( (!saswp_non_amp() && $sd_data['saswp-for-amp']!=1) || (saswp_non_amp() && $sd_data['saswp-for-wordpress']!=1) ) {
175
  return ;
176
+ }
177
  $all_schema_output = array();
178
  foreach($Conditionals as $schemaConditionals){
179
 
180
  $schema_options = $schemaConditionals['schema_options'];
181
+ $schema_type = $schemaConditionals['schema_type'];
182
  $schema_post_id = $schemaConditionals['post_id'];
183
  $logo = $sd_data['sd_logo']['url'];
184
  if( '' == $logo && empty($logo) && isset($sd_data['sd_default_image'])){
203
  $date = get_the_date("Y-m-d\TH:i:s\Z");
204
  $modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
205
  $aurthor_name = get_the_author();
206
+
207
+ $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
208
+ $aggregateRating = array();
209
+
210
+ if(isset($saswp_review_details['saswp-review-item-over-all'])){
211
+ $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
212
+ }
213
+ $saswp_review_item_enable = 0;
214
+ if(isset($saswp_review_details['saswp-review-item-enable'])){
215
+ $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
216
+ }
217
+ $saswp_review_count = "1";
218
+
219
+
220
+ if($saswp_over_all_rating && $saswp_review_count && $saswp_review_item_enable ==1){
221
+ $aggregateRating = array(
222
+ "@type"=> "AggregateRating",
223
+ "ratingValue" => $saswp_over_all_rating,
224
+ "reviewCount" => $saswp_review_count
225
+ );
226
+ }
227
+
228
  if(is_page()){
229
  $schema_type = $schema_type; //$sd_data['sd_page_type'];
230
  }
261
  );
262
  // For WebPage
263
  if( 'WebPage' === $schema_type){
264
+
265
  if(empty($image_details[0]) || $image_details[0] === NULL ){
266
  $image_details[0] = $logo;
267
  }
293
  ),
294
  'name' => $sd_data['sd_name'],
295
  ),
296
+
297
  ),
298
 
299
 
300
  );
301
+ if(!empty($aggregateRating)){
302
+ $input1['mainEntity']['aggregateRating'] = $aggregateRating;
303
+ }
304
  }
305
 
306
  // For Article
307
 
308
  if( 'Article' === $schema_type ){
309
+
310
  $input1 = array(
311
  '@context' => 'http://schema.org',
312
  '@type' => 'Article',
318
  'dateModified' => $modified_date,
319
  'author' => array(
320
  '@type' => 'Person',
321
+ 'name' => $aurthor_name
322
+ ),
323
  'Publisher' => array(
324
  '@type' => 'Organization',
325
  'logo' => array(
330
  ),
331
  'name' => $sd_data['sd_name'],
332
  ),
333
+
334
  );
335
  }
336
 
337
  // Recipe
338
  if( 'Recipe' === $schema_type){
339
+
340
  if(empty($image_details[0]) || $image_details[0] === NULL ){
341
  $image_details[0] = $sd_data['sd_logo']['url'];
342
  }
371
  ),
372
  'name' => $sd_data['sd_name'],
373
  ),
374
+
375
+
376
+ ),
377
 
378
  );
379
+ if(!empty($aggregateRating)){
380
+ $input1['aggregateRating'] = $aggregateRating;
381
+ }
382
  }
383
 
384
  // Product
385
 
386
  if( 'Product' === $schema_type){
387
+
388
  if(empty($image_details[0]) || $image_details[0] === NULL ){
389
  $image_details[0] = $logo;
390
  }
393
  '@type' => $schema_type ,
394
  'url' => get_permalink(),
395
  'name' => get_the_title(),
396
+ 'description' => get_the_excerpt(),
 
 
 
 
 
 
397
  );
398
+ if(!empty($aggregateRating)){
399
+ $input1['aggregateRating'] = $aggregateRating;
400
+ }
401
  }
402
+
403
+ if( 'NewsArticle' === $schema_type ){
 
 
 
 
 
 
404
  $input1 = array(
405
  '@context' => 'http://schema.org',
406
+ '@type' => $schema_type ,
 
407
  'mainEntityOfPage' => get_permalink(),
408
  'url' => get_permalink(),
409
  'headline' => get_the_title(),
435
  'height' => $sd_data['sd_logo']['height'],
436
  ),
437
  'name' => $sd_data['sd_name'],
438
+ ),
439
  );
440
+ if(!empty($aggregateRating)){
441
+ $input1['aggregateRating'] = $aggregateRating;
442
+ }
443
  }
444
+
445
+ // VideoObject
446
+ if( 'VideoObject' === $schema_type){
447
+
448
+ if(empty($image_details[0]) || $image_details[0] === NULL ){
449
+ $image_details[0] = $sd_data['sd_logo']['url'];
450
+ }
451
 
452
  $input1 = array(
453
  '@context' => 'http://schema.org',
483
  'height' => $sd_data['sd_logo']['height'],
484
  ),
485
  'name' => $sd_data['sd_name'],
486
+ ),
487
+
488
  );
489
+ if(!empty($aggregateRating)){
490
+ $input1['aggregateRating'] = $aggregateRating;
491
+ }
492
+
493
  }
494
 
495
  if( 'local_business' === $schema_type){
514
  $input1 = array(
515
  '@context' => 'http://schema.org',
516
  '@type' => $local_business ,
517
+ 'name' => $business_details['local_business_name'],
518
+ 'url' => get_permalink(),
519
+ 'description' => get_the_excerpt(),
 
520
  'address' => array(
521
  "@type" => "PostalAddress",
522
  "streetAddress" => $business_details['local_street_address'],
530
  'dayOfWeek' => $business_details['saswp_dayofweek'],
531
  'opens' => $business_details['local_opens_time'],
532
  'closes'=> $business_details['local_closes_time'],
533
+ ),
534
+
535
  );
536
+ if(!empty($aggregateRating)){
537
+ $input1['aggregateRating'] = $aggregateRating;
538
+ }
539
 
540
  if(isset($business_details['local_price_range'])){
541
  $input1['priceRange'] = $business_details['local_price_range'];
609
  return $all_schema_output;
610
  }
611
 
612
+ function saswp_post_specific_schema_output() {
613
+ global $post;
614
+ $all_schemas = get_posts(
615
+ array(
616
+ 'post_type' => 'saswp',
617
+ 'posts_per_page' => -1,
618
+ 'post_status' => 'publish',
619
+ )
620
+ );
621
+ $all_schema_output = array();
622
+ foreach($all_schemas as $schema){
623
+ $schema_id = $schema->ID;
624
+ $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
625
+ $schema_post_id = $post->ID;
626
+ $all_post_meta = esc_sql ( get_post_meta($schema_post_id, $key='', true) );
627
+
628
+ if(is_singular()){
629
+
630
+ $saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
631
+ $aggregateRating = array();
632
+
633
+ if(isset($saswp_review_details['saswp-review-item-over-all'])){
634
+ $saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
635
+ }
636
+ $saswp_review_item_enable = 0;
637
+ if(isset($saswp_review_details['saswp-review-item-enable'])){
638
+ $saswp_review_item_enable = $saswp_review_details['saswp-review-item-enable'];
639
+ }
640
+ $saswp_review_count = "1";
641
+
642
+ if($saswp_over_all_rating && $saswp_review_count && $saswp_review_item_enable ==1){
643
+ $aggregateRating = array(
644
+ "@type"=> "AggregateRating",
645
+ "ratingValue" => $saswp_over_all_rating,
646
+ "reviewCount" => $saswp_review_count
647
+ );
648
+ }
649
+
650
+ if( 'Blogposting' === $schema_type){
651
+ // Blogposting Schema
652
+ $input1 = array(
653
+ '@context' => 'http://schema.org',
654
+ '@type' => $schema_type ,
655
+
656
+ 'mainEntityOfPage' => $all_post_meta['saswp_blogposting_main_entity_of_page_'.$schema_id][0],
657
+ 'headline' => $all_post_meta['saswp_blogposting_headline_'.$schema_id][0],
658
+ 'description' => $all_post_meta['saswp_blogposting_description'.$schema_id][0],
659
+ 'name' => $all_post_meta['saswp_blogposting_name_'.$schema_id][0],
660
+ 'url' => $all_post_meta['saswp_blogposting_url_'.$schema_id][0],
661
+ 'datePublished' => $all_post_meta['saswp_blogposting_date_published_'.$schema_id][0],
662
+ 'dateModified' => $all_post_meta['saswp_blogposting_date_modified_'.$schema_id][0],
663
+ 'author' => array(
664
+ '@type' => 'Person',
665
+ 'name' => $all_post_meta['saswp_blogposting_author_name_'.$schema_id][0], ),
666
+ 'Publisher' => array(
667
+ '@type' => 'Organization',
668
+ 'logo' => array(
669
+ '@type' => 'ImageObject',
670
+ 'url' => $all_post_meta['saswp_blogposting_organization_logo_'.$schema_id][0],
671
+ 'width' => $all_post_meta['saswp_blogposting_organization_logo_'.$schema_id.'_width'][0],
672
+ 'height' => $all_post_meta['saswp_blogposting_organization_logo_'.$schema_id.'_height'][0],
673
+ ),
674
+ 'name' => $all_post_meta['saswp_blogposting_organization_name_'.$schema_id][0],
675
+ ),
676
+ );
677
+ }
678
+
679
+ if( 'WebPage' === $schema_type){
680
+
681
+ $input1 = array(
682
+ '@context' => 'http://schema.org',
683
+ '@type' => $schema_type ,
684
+ 'name' => $all_post_meta['saswp_webpage_name_'.$schema_id][0],
685
+ 'url' => $all_post_meta['saswp_webpage_url_'.$schema_id][0],
686
+ 'description' => $all_post_meta['saswp_webpage_description_'.$schema_id][0],
687
+ 'mainEntity' => array(
688
+ '@type' => 'Article',
689
+ 'mainEntityOfPage' => $all_post_meta['saswp_webpage_main_entity_of_page_'.$schema_id][0],
690
+ 'image' => $all_post_meta['saswp_webpage_image_'.$schema_id][0],
691
+ 'headline' => $all_post_meta['saswp_webpage_headline_'.$schema_id][0],
692
+ 'description' => $all_post_meta['saswp_webpage_description_'.$schema_id][0],
693
+ 'datePublished' => $all_post_meta['saswp_webpage_date_published_'.$schema_id][0],
694
+ 'dateModified' => $all_post_meta['saswp_webpage_date_modified_'.$schema_id][0],
695
+ 'author' => array(
696
+ '@type' => 'Person',
697
+ 'name' => $all_post_meta['saswp_webpage_author_name_'.$schema_id][0], ),
698
+ 'Publisher' => array(
699
+ '@type' => 'Organization',
700
+ 'logo' => array(
701
+ '@type' => 'ImageObject',
702
+ 'url' => $all_post_meta['saswp_webpage_organization_logo_'.$schema_id][0],
703
+ 'width' => $all_post_meta['saswp_webpage_organization_logo_'.$schema_id.'_width'][0],
704
+ 'height' => $all_post_meta['saswp_webpage_organization_logo_'.$schema_id.'_height'][0],
705
+ ),
706
+ 'name' => $all_post_meta['saswp_webpage_organization_name_'.$schema_id][0],
707
+ ),
708
+ ),
709
+
710
+
711
+ );
712
+ if(!empty($aggregateRating)){
713
+ $input1['mainEntity']['aggregateRating'] = $aggregateRating;
714
+ }
715
+ }
716
+
717
+ if( 'Article' === $schema_type ){
718
+ $input1 = array(
719
+ '@context' => 'http://schema.org',
720
+ '@type' => 'Article',
721
+ 'mainEntityOfPage' => $all_post_meta['saswp_article_main_entity_of_page_'.$schema_id][0],
722
+ 'image' => $all_post_meta['saswp_article_image_'.$schema_id][0],
723
+ 'headline' => $all_post_meta['saswp_article_headline_'.$schema_id][0],
724
+ 'description' => $all_post_meta['saswp_article_description_'.$schema_id][0],
725
+ 'datePublished' => $all_post_meta['saswp_article_date_published_'.$schema_id][0],
726
+ 'dateModified' => $all_post_meta['saswp_article_date_modified_'.$schema_id][0],
727
+ 'author' => array(
728
+ '@type' => 'Person',
729
+ 'name' => $all_post_meta['saswp_article_author_name_'.$schema_id][0]
730
+ ),
731
+ 'Publisher' => array(
732
+ '@type' => 'Organization',
733
+ 'logo' => array(
734
+ '@type' => 'ImageObject',
735
+ 'url' => $all_post_meta['saswp_article_organization_logo_'.$schema_id][0],
736
+ 'width' => $all_post_meta['saswp_article_organization_logo_'.$schema_id.'_width'][0],
737
+ 'height' => $all_post_meta['saswp_article_organization_logo_'.$schema_id.'_height'][0],
738
+ ),
739
+ 'name' => $all_post_meta['saswp_article_organization_name_'.$schema_id][0],
740
+ ),
741
+
742
+ );
743
+ }
744
+
745
+ if( 'Recipe' === $schema_type){
746
+
747
+ $input1 = array(
748
+ '@context' => 'http://schema.org',
749
+ '@type' => $schema_type ,
750
+ 'url' => $all_post_meta['saswp_recipe_url_'.$schema_id][0],
751
+ 'name' => $all_post_meta['saswp_recipe_name_'.$schema_id][0],
752
+ 'datePublished' => $all_post_meta['saswp_recipe_date_published_'.$schema_id][0],
753
+ 'dateModified' => $all_post_meta['saswp_recipe_date_modified_'.$schema_id][0],
754
+ 'description' => $all_post_meta['saswp_recipe_description_'.$schema_id][0],
755
+ 'mainEntity' => array(
756
+ '@type' => 'WebPage',
757
+ '@id' => $all_post_meta['saswp_recipe_main_entity_'.$schema_id][0],
758
+ 'author' => array(
759
+ '@type' => 'Person',
760
+ 'name' => $all_post_meta['saswp_recipe_author_name_'.$schema_id][0],
761
+ 'Image' => array(
762
+ '@type' => 'ImageObject',
763
+ 'url' => $all_post_meta['saswp_recipe_author_image_'.$schema_id][0],
764
+ 'height' => $all_post_meta['saswp_recipe_author_image_'.$schema_id.'_height'][0],
765
+ 'width' => $all_post_meta['saswp_recipe_author_image_'.$schema_id.'_width'][0]
766
+ ),
767
+ ),
768
+ 'Publisher' => array(
769
+ '@type' => 'Organization',
770
+ 'logo' => array(
771
+ '@type' => 'ImageObject',
772
+ 'url' => $all_post_meta['saswp_recipe_organization_logo_'.$schema_id][0],
773
+ 'width' => $all_post_meta['saswp_recipe_organization_logo_'.$schema_id.'_width'][0],
774
+ 'height' => $all_post_meta['saswp_recipe_organization_logo_'.$schema_id.'_height'][0],
775
+ ),
776
+ 'name' => $all_post_meta['saswp_recipe_organization_name_'.$schema_id][0],
777
+ ),
778
+ ),
779
+
780
+
781
+ );
782
+ if(!empty($aggregateRating)){
783
+ $input1['aggregateRating'] = $aggregateRating;
784
+ }
785
+ }
786
+
787
+ if( 'Product' === $schema_type){
788
+
789
+ $input1 = array(
790
+ '@context' => 'http://schema.org',
791
+ '@type' => $schema_type ,
792
+ 'url' => $all_post_meta['saswp_product_url_'.$schema_id][0],
793
+ 'name' => $all_post_meta['saswp_product_name_'.$schema_id][0],
794
+ 'description' => $all_post_meta['saswp_product_description_'.$schema_id][0],
795
+
796
+ );
797
+ if(!empty($aggregateRating)){
798
+ $input1['aggregateRating'] = $aggregateRating;
799
+ }
800
+ }
801
+
802
+ if( 'NewsArticle' === $schema_type ){
803
+ $input1 = array(
804
+ '@context' => 'http://schema.org',
805
+ '@type' => $schema_type ,
806
+ 'mainEntityOfPage' => $all_post_meta['saswp_newsarticle_main_entity_of_page_'.$schema_id][0],
807
+ 'url' => $all_post_meta['saswp_newsarticle_URL_'.$schema_id][0],
808
+ 'headline' => $all_post_meta['saswp_newsarticle_headline_'.$schema_id][0],
809
+ 'datePublished' => $all_post_meta['saswp_newsarticle_date_published_'.$schema_id][0],
810
+ 'dateModified' => $all_post_meta['saswp_newsarticle_date_modified_'.$schema_id][0],
811
+ 'description' => $all_post_meta['saswp_newsarticle_description_'.$schema_id][0],
812
+ 'name' => $all_post_meta['saswp_newsarticle_name_'.$schema_id][0],
813
+ 'thumbnailUrl' => $all_post_meta['saswp_newsarticle_thumbnailurl_'.$schema_id][0],
814
+ 'mainEntity' => array(
815
+ '@type' => 'WebPage',
816
+ '@id' => $all_post_meta['saswp_newsarticle_main_entity_id_'.$schema_id][0],
817
+ ),
818
+ 'author' => array(
819
+ '@type' => 'Person',
820
+ 'name' => $all_post_meta['saswp_newsarticle_author_name_'.$schema_id][0],
821
+ 'Image' => array(
822
+ '@type' => 'ImageObject',
823
+ 'url' => $all_post_meta['saswp_newsarticle_author_image_'.$schema_id][0],
824
+ 'height' => $all_post_meta['saswp_newsarticle_author_image_'.$schema_id.'_height'][0],
825
+ 'width' => $all_post_meta['saswp_newsarticle_author_image_'.$schema_id.'_width'][0]
826
+ ),
827
+ ),
828
+ 'Publisher' => array(
829
+ '@type' => 'Organization',
830
+ 'logo' => array(
831
+ '@type' => 'ImageObject',
832
+ 'url' => $all_post_meta['saswp_newsarticle_organization_logo_'.$schema_id][0],
833
+ 'width' => $all_post_meta['saswp_newsarticle_organization_logo_'.$schema_id.'_width'][0],
834
+ 'height' => $all_post_meta['saswp_newsarticle_organization_logo_'.$schema_id.'_height'][0],
835
+ ),
836
+ 'name' => $all_post_meta['saswp_newsarticle_organization_name_'.$schema_id][0],
837
+ ),
838
+ );
839
+ if(!empty($aggregateRating)){
840
+ $input1['aggregateRating'] = $aggregateRating;
841
+ }
842
+ }
843
+
844
+ if( 'VideoObject' === $schema_type){
845
+
846
+ $input1 = array(
847
+ '@context' => 'http://schema.org',
848
+ '@type' => $schema_type,
849
+ 'url' => $all_post_meta['saswp_video_object_url_'.$schema_id][0],
850
+ 'headline' => $all_post_meta['saswp_video_object_headline_'.$schema_id][0],
851
+ 'datePublished' => $all_post_meta['saswp_video_object_date_published_'.$schema_id][0],
852
+ 'dateModified' => $all_post_meta['saswp_video_object_date_modified_'.$schema_id][0],
853
+ 'description' => $all_post_meta['saswp_video_object_description_'.$schema_id][0],
854
+ 'name' => $all_post_meta['saswp_video_object_name_'.$schema_id][0],
855
+ 'uploadDate' => $all_post_meta['saswp_video_object_upload_date_'.$schema_id][0],
856
+ 'thumbnailUrl' => $all_post_meta['saswp_video_object_thumbnail_url_'.$schema_id][0],
857
+ 'mainEntity' => array(
858
+ '@type' => 'WebPage',
859
+ '@id' => $all_post_meta['saswp_video_object_main_entity_id_'.$schema_id][0],
860
+ ),
861
+ 'author' => array(
862
+ '@type' => 'Person',
863
+ 'name' => $all_post_meta['saswp_video_object_author_name_'.$schema_id][0],
864
+ 'Image' => array(
865
+ '@type' => 'ImageObject',
866
+ 'url' => $all_post_meta['saswp_video_object_author_image_'.$schema_id][0],
867
+ 'height' => $all_post_meta['saswp_video_object_author_image_'.$schema_id.'_height'][0],
868
+ 'width' => $all_post_meta['saswp_video_object_author_image_'.$schema_id.'_width'][0]
869
+ ),
870
+ ),
871
+ 'Publisher' => array(
872
+ '@type' => 'Organization',
873
+ 'logo' => array(
874
+ '@type' => 'ImageObject',
875
+ 'url' => $all_post_meta['saswp_video_object_organization_logo_'.$schema_id][0],
876
+ 'width' => $all_post_meta['saswp_video_object_organization_logo_'.$schema_id.'_width'][0],
877
+ 'height' => $all_post_meta['saswp_video_object_organization_logo_'.$schema_id.'_height'][0],
878
+ ),
879
+ 'name' => $all_post_meta['saswp_video_object_organization_name_'.$schema_id][0],
880
+ ),
881
+ );
882
+ if(!empty($aggregateRating)){
883
+ $input1['aggregateRating'] = $aggregateRating;
884
+ }
885
+
886
+ }
887
+
888
+ if( 'local_business' === $schema_type){
889
+
890
+ $business_sub_name ='';
891
+ $business_type = $all_post_meta['saswp_business_type_'.$schema_id][0];
892
+ $post_specific_obj = new saswp_post_specific();
893
+ $check_business_type = $post_specific_obj->saswp_get_sub_business_array($business_type);
894
+ if(!empty($check_business_type)){
895
+ $business_sub_name = $all_post_meta['saswp_business_name_'.$schema_id][0];
896
+ }
897
+ if($business_sub_name){
898
+ $local_business = $business_sub_name;
899
+ }else{
900
+ $local_business = $business_type;
901
+ }
902
+ $input1 = array(
903
+ '@context' => 'http://schema.org',
904
+ '@type' => $local_business ,
905
+ 'name' => $all_post_meta['local_business_name_'.$schema_id][0],
906
+ 'url' => $all_post_meta['local_business_name_url_'.$schema_id][0],
907
+ 'description' => $all_post_meta['local_business_description_'.$schema_id][0],
908
+ 'address' => array(
909
+ "@type" => "PostalAddress",
910
+ "streetAddress" => $all_post_meta['local_street_address_'.$schema_id][0],
911
+ "addressLocality"=> $all_post_meta['local_city_'.$schema_id][0],
912
+ "addressRegion" => $all_post_meta['local_state_'.$schema_id][0],
913
+ "postalCode" => $all_post_meta['local_postal_code_'.$schema_id][0],
914
+ ),
915
+ 'telephone' => $all_post_meta['local_phone_'.$schema_id][0],
916
+ 'openingHoursSpecification' => array(
917
+ '@type' => 'OpeningHoursSpecification',
918
+ 'dayOfWeek' => $all_post_meta['saswp_dayofweek_'.$schema_id][0],
919
+ 'opens' => $all_post_meta['local_opens_time_'.$schema_id][0],
920
+ 'closes'=> $all_post_meta['local_closes_time_'.$schema_id][0],
921
+ ),
922
+ );
923
+
924
+ if(!empty($aggregateRating)){
925
+ $input1['aggregateRating'] = $aggregateRating;
926
+ }
927
+ if(isset($all_post_meta['local_price_range_'.$schema_id][0])){
928
+ $input1['priceRange'] = $all_post_meta['local_price_range_'.$schema_id][0];
929
+ }
930
+
931
+ if(isset($all_post_meta['local_accepts_reservations_'.$schema_id][0])){
932
+ $input1['acceptsReservations'] = $all_post_meta['local_price_accepts_reservations_'.$schema_id][0];
933
+ }
934
+
935
+ if(isset($all_post_meta['local_serves_cuisine_'.$schema_id][0])){
936
+ $input1['servesCuisine'] = $all_post_meta['local_price_serves_cuisine_'.$schema_id][0];
937
+ }
938
+
939
+ if(isset($all_post_meta['local_menu_'.$schema_id][0])){
940
+ $input1['menu'] = $all_post_meta['local_menu_'.$schema_id][0];
941
+ }
942
+ }
943
+
944
+ $image_id = get_post_thumbnail_id();
945
+ $image_details = wp_get_attachment_image_src($image_id, 'full');
946
+ global $sd_data;
947
+ if( is_array($image_details) ){
948
+ if(isset($image_details[1]) ){
949
+ $width = $image_details[1];
950
+ }
951
+ if(isset($image_details[2])){
952
+ $height = $image_details[2];
953
+ }
954
+ $input2 = array(
955
+ 'image' =>array(
956
+ '@type' =>'ImageObject',
957
+ 'url' =>$image_details[0],
958
+ 'width' =>$width,
959
+ 'height' =>$height,
960
+ ),
961
+ );
962
+ $input = array_merge($input1,$input2);
963
+ }
964
+ else{
965
+ $input2 = array(
966
+ 'image' =>array(
967
+ '@type' =>'ImageObject',
968
+ 'url' => $sd_data['sd_logo']['url'],
969
+ 'width' => $sd_data['sd_logo']['width'],
970
+ 'height' => $sd_data['sd_logo']['height'],
971
+ ),
972
+ );
973
+ $input = array_merge($input1,$input2);
974
+ }
975
+
976
+ $all_schema_output[] = $input;
977
+ }
978
+ }
979
+ return $all_schema_output;
980
+ }
981
+
982
  function saswp_structure_data_access_scripts($data){
983
  if ( empty( $data['amp_component_scripts']['amp-access'] ) ) {
984
  $data['amp_component_scripts']['amp-access'] = 'https://cdn.ampproject.org/v0/amp-access-0.1.js';
1020
  );
1021
  $j++;
1022
  }}
 
 
 
 
 
 
 
 
 
1023
 
1024
  }
1025
  if(is_page()){
1142
 
1143
  wp_reset_postdata();
1144
 
1145
+ $category = get_the_category();
1146
  $category_id = intval($category[0]->term_id);
1147
+ $category_link = get_category_link( $category_id );
1148
+ $category_link = get_term_link( $category[0]->term_id , 'category' );
1149
+ $category_headline = single_cat_title( '', false ) . __(' Category', 'schema-wp');
1150
  $input = array
1151
  (
1152
  '@context' => 'http://schema.org/',
output/review-output.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ Class saswp_review_output{
3
+ public function __construct() {
4
+ }
5
+
6
+ public function saswp_review_hooks(){
7
+ add_filter('the_content', array($this, 'saswp_display_review_box'));
8
+
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
+ }
35
+ if(isset($saswp_review_details['saswp-review-item-star-rating'])){
36
+ $saswp_review_item_star_rating = $saswp_review_details['saswp-review-item-star-rating'];
37
+ }
38
+ if(isset($saswp_review_details['saswp-review-item-title'])){
39
+ $saswp_review_title = $saswp_review_details['saswp-review-item-title'];
40
+ }
41
+ if(isset($saswp_review_details['saswp-review-item-description-title'])){
42
+ $saswp_review_description_title = $saswp_review_details['saswp-review-item-description-title'];
43
+ }
44
+
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">
53
+ <span>'.esc_html__('Pros', 'schema-and-structured-data-for-wp').'</span><br>
54
+ '.wpautop( stripslashes ( $saswp_review_props ) ).'
55
+ </div>
56
+ <div class="saswp-lst">
57
+ <span>'.esc_html__('Cons', 'schema-and-structured-data-for-wp').'</span><br>
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
+
94
+ $boxdata.='</div>
95
+ </td>
96
+ </tr>';
97
+ }
98
+ }
99
+ $boxdata.='<tr>
100
+ <td class="saswp-rvw-sm">
101
+ <span>'.esc_html__('SUMMARY', 'schema-and-structured-data-for-wp').'</span>
102
+ <div class="rvw-dsc">
103
+ '.wpautop( stripslashes ( $saswp_review_description ) ).'
104
+ </div>
105
+ </td>
106
+ <td>
107
+ <div class="saswp-rvw-ov">
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
+ }
138
+ $boxdata.=' </div>
139
+ </td>
140
+ <tr>
141
+ </tbody>
142
+ </table>';
143
+ }
144
+
145
+ return $boxdata;
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
+ if($sd_data['saswp-review-module']==0 || $saswp_review_item_enable ==0){
156
+ return $content;
157
+ }
158
+ $result = $this->saswp_get_review_box_content();
159
+
160
+ if(isset($saswp_review_details['saswp-review-location'])){
161
+ switch ($saswp_review_details['saswp-review-location']) {
162
+ case 1:
163
+ $content = $content.$result;
164
+ break;
165
+ case 2:
166
+ $content = $result.$content;
167
+ break;
168
+ case 3:
169
+ add_shortcode('saswp-review', array($this,'saswp_review_display_via_shortcode'));
170
+ break;
171
+
172
+ default:
173
+ break;
174
+ }
175
+ }
176
+
177
+ return $content;
178
+ }
179
+
180
+ }
181
+ if (class_exists('saswp_review_output')) {
182
+ $object = new saswp_review_output();
183
+ $object->saswp_review_hooks();
184
+ };
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: 4.9.8
6
- Stable tag: 1.0.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -65,6 +65,11 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
68
  = 1.0.3 (24 October 2018) =
69
  * Schema Pro migrator
70
  * Import / export functionality, so it can be transferred from staging to live website
3
  Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
4
  Requires at least: 3.0
5
  Tested up to: 4.9.8
6
+ Stable tag: 1.0.4
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.4 (16 November 2018) =
69
+ * Major Feature: Post Specific Meta boxes to override the schemas on posts
70
+ * Major Feature: Rich Snippets for Reviews and Ratings
71
+ * Security and other bug fixed
72
+
73
  = 1.0.3 (24 October 2018) =
74
  * Schema Pro migrator
75
  * Import / export functionality, so it can be transferred from staging to live website
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.3
6
  Text Domain: schema-and-structured-data-for-wp
7
  Author: Mohammed Kaludi, Ahmed Kaludi
8
  Author URI: http://structured-data-for-wp.com/
@@ -12,7 +12,7 @@ License: GPL2
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
 
15
- define('SASWP_VERSION', '1.0.3');
16
  define('SASWP_DIR_NAME_FILE', __FILE__ );
17
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
18
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
@@ -55,6 +55,9 @@ require_once SASWP_DIR_NAME.'/view/help.php';
55
  require_once SASWP_DIR_NAME.'/view/schema_type.php';
56
  require_once SASWP_DIR_NAME.'/view/paywall.php';
57
  require_once SASWP_DIR_NAME.'/admin_section/add-schema/add_new.php';
 
 
 
58
 
59
 
60
  /**
@@ -68,10 +71,11 @@ function saswp_admin_notice_activation_hook() {
68
  add_action( 'admin_notices', 'saswp_admin_notice' );
69
 
70
  function saswp_admin_notice(){
 
71
  ?>
72
  <div class="updated notice is-dismissible message notice notice-alt saswp-setup-notice saswp_hide">
73
  <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') ?>
74
- <a href="<?php echo esc_url( admin_url( 'plugins.php?page=saswp-setup-wizard' ) ); ?>"> <?php echo esc_html__('Start Quick Setup', 'schema-and-structured-data-for-wp') ?></a>
75
  </p>
76
  </div>
77
 
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.4
6
  Text Domain: schema-and-structured-data-for-wp
7
  Author: Mohammed Kaludi, Ahmed Kaludi
8
  Author URI: http://structured-data-for-wp.com/
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
 
15
+ define('SASWP_VERSION', '1.0.4');
16
  define('SASWP_DIR_NAME_FILE', __FILE__ );
17
  define('SASWP_DIR_NAME', dirname( __FILE__ ));
18
  define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
55
  require_once SASWP_DIR_NAME.'/view/schema_type.php';
56
  require_once SASWP_DIR_NAME.'/view/paywall.php';
57
  require_once SASWP_DIR_NAME.'/admin_section/add-schema/add_new.php';
58
+ require_once SASWP_DIR_NAME.'/view/post_specific.php';
59
+ require_once SASWP_DIR_NAME.'/view/review.php';
60
+ require_once SASWP_DIR_NAME.'/output/review-output.php';
61
 
62
 
63
  /**
71
  add_action( 'admin_notices', 'saswp_admin_notice' );
72
 
73
  function saswp_admin_notice(){
74
+ $nonce = wp_create_nonce( 'saswp_install_wizard_nonce' );
75
  ?>
76
  <div class="updated notice is-dismissible message notice notice-alt saswp-setup-notice saswp_hide">
77
  <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') ?>
78
+ <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>
79
  </p>
80
  </div>
81
 
view/post_specific.php ADDED
@@ -0,0 +1,1246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class saswp_post_specific {
3
+ private $screen = array(
4
+ 'post',
5
+ );
6
+ private $meta_fields = array(
7
+
8
+ );
9
+ protected $all_schema = null;
10
+ protected $options_response = array();
11
+ protected $modify_schema_post_enable = false;
12
+ public function __construct() {
13
+ }
14
+ public function saswp_post_specific_hooks(){
15
+ $this->saswp_get_all_schema_list();
16
+ add_action( 'add_meta_boxes', array( $this, 'saswp_post_specifc_add_meta_boxes' ) );
17
+ add_action( 'save_post', array( $this, 'saswp_post_specific_save_fields' ) );
18
+ add_action( 'wp_ajax_saswp_get_sub_business_ajax', array($this,'saswp_get_sub_business_ajax'));
19
+
20
+ add_action( 'wp_ajax_saswp_modify_schema_post_enable', array($this,'saswp_modify_schema_post_enable'));
21
+
22
+ add_action( 'wp_ajax_saswp_restore_schema', array($this,'saswp_restore_schema'));
23
+ }
24
+ public function saswp_get_all_schema_list(){
25
+
26
+ if($this->all_schema == null){
27
+
28
+ $all_schema = get_posts(
29
+ array(
30
+ 'post_type' => 'saswp',
31
+ 'posts_per_page' => -1,
32
+ 'post_status' => 'publish',
33
+ )
34
+ );
35
+
36
+ $this->all_schema = $all_schema;
37
+ }
38
+
39
+ }
40
+
41
+ public function saswp_post_specifc_add_meta_boxes($post) {
42
+ if(count($this->all_schema)>0 && get_post_status($post->ID)=='publish'){
43
+ foreach ( $this->screen as $single_screen ) {
44
+ $post_title ='';
45
+ if(count($this->all_schema)==1){
46
+ $all_schemas = $this->all_schema;
47
+ $post_title = '('.$all_schemas[0]->post_title.')';
48
+ }
49
+ add_meta_box(
50
+ 'post_specific',
51
+ __( 'Post Specific Schema '.$post_title, 'schema-and-structured-data-for-wp' ),
52
+ array( $this, 'saswp_post_meta_box_callback' ),
53
+ $single_screen,
54
+ 'advanced',
55
+ 'default'
56
+ );
57
+
58
+ }
59
+ }
60
+ }
61
+
62
+ public function saswp_post_meta_box_fields($post){
63
+ if(count($this->all_schema)>1){
64
+ $tabs = '';
65
+ $tabs_fields = '';
66
+ $schema_ids = array();
67
+ foreach($this->all_schema as $key => $schema){
68
+ $response = $this->saswp_get_fields_by_schema_type($schema->ID);
69
+ $this->meta_fields = $response;
70
+ $output = $this->saswp_saswp_post_specific( $post, $schema->ID );
71
+ if($key==0){
72
+ $tabs .='<li><a data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links selected">'.esc_attr($schema->post_title).'</a></li>';
73
+ $tabs_fields .= '<div data-id="'.esc_attr($schema->ID).'" id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-post-specific-wrapper">';
74
+ $tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
75
+ $tabs_fields .= '</div>';
76
+ }else{
77
+ $tabs .='<li><a data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links">'.esc_attr($schema->post_title).'</a></li>';
78
+ $tabs_fields .= '<div data-id="'.esc_attr($schema->ID).'" id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-post-specific-wrapper saswp_hide">';
79
+ $tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
80
+ $tabs_fields .= '</div>';
81
+
82
+ }
83
+ $schema_ids[] =$schema->ID;
84
+ }
85
+
86
+ echo '<div>';
87
+ echo '<div><a href="#" class="saswp-restore-post-schema button">Restore Default Schama</a></div>';
88
+ echo '<div class="saswp-tab saswp-post-specific-tab-wrapper">';
89
+ echo '<ul class="saswp-tab-nav">';
90
+ echo $tabs;
91
+ echo '</ul>';
92
+ echo '</div>';
93
+ echo '<div class="saswp-post-specific-container">';
94
+ echo $tabs_fields;
95
+ echo '</div>';
96
+ echo '<input class="saswp-post-specific-schema-ids" type="hidden" value="'. json_encode($schema_ids).'">';
97
+ echo '</div>';
98
+
99
+ }else{
100
+
101
+ $all_schema = $this->all_schema;
102
+ $response = $this->saswp_get_fields_by_schema_type($all_schema[0]->ID);
103
+
104
+ $schema_ids[] =$all_schema[0]->ID;
105
+
106
+ $this->meta_fields = $response;
107
+ $output = $this->saswp_saswp_post_specific( $post, $all_schema[0]->ID );
108
+ $tabs_fields .= '<div>';
109
+ $tabs_fields .= '<div><a href="#" class="saswp-restore-post-schema button">Restore Default Schama</a></div>';
110
+ $tabs_fields .= '<div id="saswp_specific_'.esc_attr($all_schema[0]->ID).'" class="saswp-post-specific-wrapper">';
111
+ $tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
112
+ $tabs_fields .= '</div>';
113
+ $tabs_fields .= '<input class="saswp-post-specific-schema-ids" type="hidden" value="'. json_encode($schema_ids).'">';
114
+ $tabs_fields .= '</div>';
115
+ echo $tabs_fields;
116
+ }
117
+ }
118
+
119
+ public function saswp_post_meta_box_callback() {
120
+ wp_nonce_field( 'post_specific_data', 'post_specific_nonce' );
121
+ global $post;
122
+ $option = get_option('modify_schema_post_enable_'.$post->ID);
123
+ if($option == 'enable'){
124
+ $this->saswp_post_meta_box_fields($post);
125
+ }else{
126
+ echo '<a class="button saswp-modify_schema_post_enable">Modify Schema</a>' ;
127
+ }
128
+
129
+ }
130
+
131
+ public function saswp_restore_schema(){
132
+ if ( ! isset( $_POST['saswp_security_nonce'] ) ){
133
+ return;
134
+ }
135
+ if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
136
+ return;
137
+ }
138
+ $result ='';
139
+ $post_id = sanitize_text_field($_POST['post_id']);
140
+ $schema_ids = $_POST['schema_ids'];
141
+ foreach($schema_ids as $id){
142
+ $meta_field = $this->saswp_get_fields_by_schema_type($id);
143
+ foreach($meta_field as $field){
144
+ $result = delete_post_meta($post_id, $field['id']);
145
+ }
146
+ }
147
+ if($result){
148
+ echo json_encode(array('status'=> 't', 'msg'=>esc_html__( 'Schema has been restored', 'schema-and-structured-data-for-wp' )));
149
+ }else{
150
+ echo json_encode(array('status'=> 'f', 'msg'=>esc_html__( 'Schema has already been restored', 'schema-and-structured-data-for-wp' )));
151
+ }
152
+
153
+ wp_die();
154
+ }
155
+
156
+ public function saswp_modify_schema_post_enable(){
157
+ if ( ! isset( $_GET['saswp_security_nonce'] ) ){
158
+ return;
159
+ }
160
+ if ( !wp_verify_nonce( $_GET['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
161
+ return;
162
+ }
163
+
164
+ $post_id = sanitize_text_field($_GET['post_id']);
165
+ update_option('modify_schema_post_enable_'.$post_id, 'enable');
166
+ $args = array(
167
+ 'p' => $post_id, // ID of a page, post, or custom type
168
+ 'post_type' => 'any'
169
+ );
170
+ $my_posts = new WP_Query($args);
171
+ if ( $my_posts->have_posts() ) {
172
+ while ( $my_posts->have_posts() ) : $my_posts->the_post();
173
+ echo $this->saswp_post_meta_box_callback();
174
+ endwhile;
175
+ }
176
+
177
+ wp_die();
178
+ }
179
+
180
+ public function saswp_saswp_post_specific( $post, $schema_id ) {
181
+
182
+ global $post;
183
+ global $sd_data;
184
+ $image_id = get_post_thumbnail_id();
185
+ $image_details = wp_get_attachment_image_src($image_id, 'full');
186
+ if(empty($image_details[0]) || $image_details[0] === NULL ){
187
+ $image_details[0] = $sd_data['sd_logo']['url'];
188
+ }
189
+ $current_user = wp_get_current_user();
190
+ $author_details = get_avatar_data($current_user->ID);
191
+ $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
192
+ $output = '';
193
+ $this->meta_fields = array_filter($this->meta_fields);
194
+ foreach ( $this->meta_fields as $meta_field ) {
195
+ $input ='';
196
+ $label = '<label for="' . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
197
+ $meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
198
+ if ( empty( $meta_value ) ) {
199
+ $meta_value = $meta_field['default'];
200
+ }
201
+ switch ( $meta_field['type'] ) {
202
+ case 'media':
203
+ $media_value = array();
204
+ $media_key = $meta_field['id'].'detail';
205
+ $media_value_meta = get_post_meta( $post->ID, $media_key, true );
206
+ if(!empty($media_value_meta)){
207
+ $media_value =$media_value_meta;
208
+ }
209
+ if (strpos($meta_field['id'], 'author_image') !== false && empty($media_value_meta)) {
210
+ $media_value['height'] = $author_details['height'];
211
+ $media_value['width'] = $author_details['width'];
212
+ $media_value['thumbnail'] = $author_details['url'];
213
+ }
214
+ if (strpos($meta_field['id'], 'organization_logo') !== false && empty($media_value_meta)) {
215
+
216
+ $media_value['height'] = $sd_data['sd_logo']['height'];
217
+ $media_value['width'] = $sd_data['sd_logo']['width'];
218
+ $media_value['thumbnail'] = $sd_data['sd_logo']['url'];
219
+ }
220
+ if (strpos($meta_field['id'], 'business_logo') !== false && empty($media_value_meta)) {
221
+
222
+ $business_details = esc_sql ( get_post_meta($schema_id, 'saswp_local_business_details', true) );
223
+ $media_value['height'] = $business_details['local_business_logo']['height'];
224
+ $media_value['width'] = $business_details['local_business_logo']['width'];
225
+ $media_value['thumbnail'] = $business_details['local_business_logo']['url'];
226
+ }
227
+
228
+ $input = sprintf(
229
+ '<fieldset><input style="width: 80%%" id="%s" name="%s" type="text" value="%s">'
230
+ . '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
231
+ // . '<input type="hidden" data-id="'.esc_attr($meta_field['id']).'_id" class="upload-id " name="'.esc_attr($meta_field['id']).'_id" id="'.esc_attr($meta_field['id']).'_id" value="'.esc_attr($media_value['id']).'">'
232
+ . '<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="'.esc_attr($media_value['height']).'">'
233
+ . '<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="'.esc_attr($media_value['width']).'">'
234
+ . '<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="'.esc_attr($media_value['thumbnail']).'">'
235
+ .'</fieldset>',
236
+ $meta_field['id'],
237
+ $meta_field['id'],
238
+ $meta_value,
239
+ $meta_field['id'],
240
+ $meta_field['id']
241
+ );
242
+ break;
243
+ case 'radio':
244
+ $input = '<fieldset>';
245
+ $input .= '<legend class="screen-reader-text">' . $meta_field['label'] . '</legend>';
246
+ $i = 0;
247
+ foreach ( $meta_field['options'] as $key => $value ) {
248
+ $meta_field_value = !is_numeric( $key ) ? $key : $value;
249
+ $input .= sprintf(
250
+ '<label><input %s id=" % s" name="% s" type="radio" value="% s"> %s</label>%s',
251
+ $meta_value === $meta_field_value ? 'checked' : '',
252
+ $meta_field['id'],
253
+ $meta_field['id'],
254
+ $meta_field_value,
255
+ $value,
256
+ $i < count( $meta_field['options'] ) - 1 ? '<br>' : ''
257
+ );
258
+ $i++;
259
+ }
260
+ $input .= '</fieldset>';
261
+ break;
262
+ case 'select':
263
+ $class = '';
264
+ if (strpos($meta_field['id'], 'business_type') !== false){
265
+ $class='saswp-local-business-type-select';
266
+ }
267
+ if (strpos($meta_field['id'], 'business_name') !== false){
268
+ $class='saswp-local-business-name-select';
269
+ }
270
+
271
+ $input = sprintf(
272
+ '<select class="%s" id="%s" name="%s">',
273
+ $class,
274
+ $meta_field['id'],
275
+ $meta_field['id']
276
+ );
277
+ foreach ( $meta_field['options'] as $key => $value ) {
278
+ $meta_field_value = !is_numeric( $key ) ? $key : $value;
279
+ $input .= sprintf(
280
+ '<option %s value="%s">%s</option>',
281
+ $meta_value === $meta_field_value ? 'selected' : '',
282
+ $meta_field_value,
283
+ $value
284
+ );
285
+ }
286
+ $input .= '</select>';
287
+ break;
288
+
289
+ case 'multiselect':
290
+ $input = sprintf(
291
+ '<select multiple id="%s" name="%s[]">',
292
+ $meta_field['id'],
293
+ $meta_field['id']
294
+ );
295
+ foreach ( $meta_field['options'] as $key => $value ) {
296
+ $meta_field_selected='';
297
+ if(isset($meta_value)){
298
+ if(in_array($key, $meta_value)){
299
+ $meta_field_selected = 'selected';
300
+ }
301
+ }
302
+ $input .= sprintf(
303
+ '<option %s value="%s">%s</option>',
304
+ $meta_field_selected,
305
+ $key,
306
+ $value
307
+ );
308
+ }
309
+ $input .= '</select>';
310
+ break;
311
+
312
+
313
+ case 'textarea':
314
+ $input = sprintf(
315
+ '<textarea style="width: 100%%" id="%s" name="%s" rows="5">%s</textarea>',
316
+ $meta_field['id'],
317
+ $meta_field['id'],
318
+ $meta_value
319
+ );
320
+ break;
321
+ case 'text':
322
+ case 'number':
323
+ $class = '';
324
+ if (strpos($meta_field['id'], 'closes_time') !== false || strpos($meta_field['id'], 'opens_time') !== false){
325
+ $class='saswp-local-schema-time-picker';
326
+ }
327
+ if (strpos($meta_field['id'], 'date_modified') !== false || strpos($meta_field['id'], 'date_published') !== false){
328
+ $class='saswp-local-schema-datepicker-picker';
329
+ }
330
+ $input = sprintf(
331
+ '<input class="%s" %s id="%s" name="%s" type="%s" value="%s">',
332
+ $class,
333
+ $meta_field['type'] !== 'color' ? 'style="width: 100%"' : '',
334
+ $meta_field['id'],
335
+ $meta_field['id'],
336
+ $meta_field['type'],
337
+ $meta_value
338
+ );
339
+ break;
340
+
341
+ default:
342
+
343
+ }
344
+ $output .= '<tr><th>'.$label.'</th><td>'.$input.'</td></tr>';
345
+ }
346
+ return $output;
347
+ }
348
+ public function saswp_post_specific_save_fields( $post_id ) {
349
+ if ( ! isset( $_POST['post_specific_nonce'] ) )
350
+ return $post_id;
351
+ $nonce = $_POST['post_specific_nonce'];
352
+ if ( !wp_verify_nonce( $nonce, 'post_specific_data' ) )
353
+ return $post_id;
354
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
355
+ return $post_id;
356
+
357
+ $option = get_option('modify_schema_post_enable_'.$post_id);
358
+ if($option != 'enable'){
359
+ return;
360
+ }
361
+ if(count($this->all_schema)>0){
362
+
363
+ foreach($this->all_schema as $schema){
364
+ $response = $this->saswp_get_fields_by_schema_type($schema->ID);
365
+ $this->meta_fields = $response;
366
+ foreach ( $this->meta_fields as $meta_field ) {
367
+ if ( isset( $_POST[ $meta_field['id'] ] ) ) {
368
+ switch ( $meta_field['type'] ) {
369
+ case 'media':
370
+ $media_key = $meta_field['id'].'detail';
371
+ //$media_id = sanitize_text_field( $_POST[ $meta_field['id'].'_id' ] );
372
+ $media_height = sanitize_text_field( $_POST[ $meta_field['id'].'_height' ] );
373
+ $media_width = sanitize_text_field( $_POST[ $meta_field['id'].'_width' ] );
374
+ $media_thumbnail = sanitize_text_field( $_POST[ $meta_field['id'].'_thumbnail' ] );
375
+ $media_detail = array(
376
+ //'id' =>$media_id,
377
+ 'height' =>$media_height,
378
+ 'width' =>$media_width,
379
+ 'thumbnail' =>$media_thumbnail,
380
+ );
381
+
382
+ update_post_meta( $post_id, $media_key, $media_detail);
383
+ break;
384
+ case 'email':
385
+ $_POST[ $meta_field['id'] ] = sanitize_email( $_POST[ $meta_field['id'] ] );
386
+ break;
387
+ case 'text':
388
+ $_POST[ $meta_field['id'] ] = sanitize_text_field( $_POST[ $meta_field['id'] ] );
389
+ break;
390
+ }
391
+ update_post_meta( $post_id, $meta_field['id'], $_POST[ $meta_field['id'] ] );
392
+ } else if ( $meta_field['type'] === 'checkbox' ) {
393
+ update_post_meta( $post_id, $meta_field['id'], '0' );
394
+ }
395
+ }
396
+ }
397
+ }
398
+ }
399
+ public function saswp_get_sub_business_ajax(){
400
+
401
+ if ( ! isset( $_GET['saswp_security_nonce'] ) ){
402
+ return;
403
+ }
404
+ if ( !wp_verify_nonce( $_GET['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
405
+ return;
406
+ }
407
+ $business_type = sanitize_text_field($_GET['business_type']);
408
+
409
+ $response = $this->saswp_get_sub_business_array($business_type);
410
+
411
+ if($response){
412
+ $this->options_response = $response;
413
+ echo json_encode(array('status'=>'t', 'result'=>$response));
414
+ }else{
415
+ echo json_encode(array('status'=>'f', 'result'=>'data not available'));
416
+ }
417
+ wp_die();
418
+ }
419
+ public function saswp_get_sub_business_array($business_type){
420
+ $sub_business_options = array();
421
+ switch ($business_type) {
422
+ case 'automotivebusiness':
423
+ $sub_business_options = array(
424
+ 'autobodyshop' => 'Auto Body Shop',
425
+ 'autodealer' => 'Auto Dealer',
426
+ 'autopartsstore' => 'Auto Parts Store',
427
+ 'autorental' => 'Auto Rental',
428
+ 'autorepair' => 'Auto Repair',
429
+ 'autowash' => 'Auto Wash',
430
+ 'gasstation' => 'Gas Station',
431
+ 'motorcycledealer' => 'Motorcycle Dealer',
432
+ 'motorcyclerepair' => 'Motorcycle Repair'
433
+ );
434
+ break;
435
+ case 'emergencyservice':
436
+ $sub_business_options = array(
437
+ 'firestation' => 'Fire Station',
438
+ 'hospital' => 'Hospital',
439
+ 'policestation' => 'Police Station',
440
+ );
441
+ break;
442
+ case 'entertainmentbusiness':
443
+ $sub_business_options = array(
444
+ 'adultentertainment' => 'Adult Entertainment',
445
+ 'amusementpark' => 'Amusement Park',
446
+ 'artgallery' => 'Art Gallery',
447
+ 'casino' => 'Casino',
448
+ 'comedyclub' => 'Comedy Club',
449
+ 'movietheater' => 'Movie Theater',
450
+ 'nightclub' => 'Night Club',
451
+
452
+ );
453
+ break;
454
+ case 'financialservice':
455
+ $sub_business_options = array(
456
+ 'accountingservice' => 'Accounting Service',
457
+ 'automatedteller' => 'Automated Teller',
458
+ 'bankorcredit_union' => 'Bank Or Credit Union',
459
+ 'insuranceagency' => 'Insurance Agency',
460
+
461
+ );
462
+ break;
463
+ case 'foodestablishment':
464
+ $sub_business_options = array(
465
+ 'bakery' => 'Bakery',
466
+ 'barorpub' => 'Bar Or Pub',
467
+ 'brewery' => 'Brewery',
468
+ 'cafeorcoffee_shop' => 'Cafe Or Coffee Shop',
469
+ 'fastfoodrestaurant' => 'Fast Food Restaurant',
470
+ 'icecreamshop' => 'Ice Cream Shop',
471
+ 'restaurant' => 'Restaurant',
472
+ 'winery' => 'Winery',
473
+
474
+ );
475
+ break;
476
+ case 'healthandbeautybusiness':
477
+ $sub_business_options = array(
478
+ 'beautysalon' => 'Beauty Salon',
479
+ 'dayspa' => 'DaySpa',
480
+ 'hairsalon' => 'Hair Salon',
481
+ 'healthclub' => 'Health Club',
482
+ 'nailsalon' => 'Nail Salon',
483
+ 'tattooparlor' => 'Tattoo Parlor',
484
+ );
485
+ break;
486
+ case 'homeandconstructionbusiness':
487
+ $sub_business_options = array(
488
+ 'electrician' => 'Electrician',
489
+ 'generalcontractor' => 'General Contractor',
490
+ 'hvacbusiness' => 'HVAC Business',
491
+ 'locksmith' => 'Locksmith',
492
+ 'movingcompany' => 'Moving Company',
493
+ 'plumber' => 'Plumber',
494
+ 'roofingcontractor' => 'Roofing Contractor',
495
+ );
496
+ break;
497
+ case 'legalservice':
498
+ $sub_business_options = array(
499
+ 'attorney' => 'Attorney',
500
+ 'notary' => 'Notary',
501
+ );
502
+ break;
503
+ case 'lodgingbusiness':
504
+ $sub_business_options = array(
505
+ 'bedandbreakfast' => 'Bed And Breakfast',
506
+ 'campground' => 'Campground',
507
+ 'hostel' => 'Hostel',
508
+ 'hotel' => 'Hotel',
509
+ 'motel' => 'Motel',
510
+ 'resort' => 'Resort',
511
+ );
512
+ break;
513
+ case 'sportsactivitylocation':
514
+ $sub_business_options = array(
515
+ 'bowlingalley' => 'Bowling Alley',
516
+ 'exercisegym' => 'Exercise Gym',
517
+ 'golfcourse' => 'Golf Course',
518
+ 'healthclub' => 'Health Club',
519
+ 'publicswimming_pool' => 'Public Swimming Pool',
520
+ 'skiresort' => 'Ski Resort',
521
+ 'sportsclub' => 'Sports Club',
522
+ 'stadiumorarena' => 'Stadium Or Arena',
523
+ 'tenniscomplex' => 'Tennis Complex'
524
+ );
525
+ break;
526
+ case 'store':
527
+ $sub_business_options = array(
528
+ 'autopartsstore'=>'Auto Parts Store',
529
+ 'bikestore'=>'Bike Store',
530
+ 'bookstore'=>'Book Store',
531
+ 'clothingstore'=>'Clothing Store',
532
+ 'computerstore'=>'Computer Store',
533
+ 'conveniencestore'=>'Convenience Store',
534
+ 'departmentstore'=>'Department Store',
535
+ 'electronicsstore'=>'Electronics Store',
536
+ 'florist'=>'Florist',
537
+ 'furniturestore'=>'Furniture Store',
538
+ 'gardenstore'=>'Garden Store',
539
+ 'grocerystore'=>'Grocery Store',
540
+ 'hardwarestore'=>'Hardware Store',
541
+ 'hobbyshop'=>'Hobby Shop',
542
+ 'homegoodsstore'=>'HomeGoods Store',
543
+ 'jewelrystore'=>'Jewelry Store',
544
+ 'liquorstore'=>'Liquor Store',
545
+ 'mensclothingstore'=>'Mens Clothing Store',
546
+ 'mobilephonestore'=>'Mobile Phone Store',
547
+ 'movierentalstore'=>'Movie Rental Store',
548
+ 'musicstore'=>'Music Store',
549
+ 'officeequipmentstore'=>'Office Equipment Store',
550
+ 'outletstore'=>'Outlet Store',
551
+ 'pawnshop'=>'Pawn Shop',
552
+ 'petstore'=>'Pet Store',
553
+ 'shoestore'=>'Shoe Store',
554
+ 'sportinggoodsstore'=>'Sporting Goods Store',
555
+ 'tireshop'=>'Tire Shop',
556
+ 'toystore'=>'Toy Store',
557
+ 'wholesalestore'=>'Wholesale Store'
558
+ );
559
+ break;
560
+ default:
561
+ break;
562
+ }
563
+ return $sub_business_options;
564
+ }
565
+
566
+ public function saswp_get_fields_by_schema_type( $schema_id ) {
567
+ global $post;
568
+ global $sd_data;
569
+ $image_id = get_post_thumbnail_id();
570
+ $image_details = wp_get_attachment_image_src($image_id, 'full');
571
+ if(empty($image_details[0]) || $image_details[0] === NULL ){
572
+ $image_details[0] = $sd_data['sd_logo']['url'];
573
+ }
574
+ $current_user = wp_get_current_user();
575
+ $author_details = get_avatar_data($current_user->ID);
576
+ $schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
577
+
578
+ $business_type = esc_sql ( get_post_meta($schema_id, 'saswp_business_type', true) );
579
+ $business_name = esc_sql ( get_post_meta($schema_id, 'saswp_business_name', true) );
580
+ $business_details = esc_sql ( get_post_meta($schema_id, 'saswp_local_business_details', true) );
581
+ $saswp_business_type_key = 'saswp_business_type_'.$schema_id;
582
+ $saved_business_type = get_post_meta( $post->ID, $saswp_business_type_key, true );
583
+ $saved_saswp_business_name = get_post_meta( $post->ID, 'saswp_business_name_'.$schema_id, true );
584
+ if($saved_business_type){
585
+ $business_type = $saved_business_type;
586
+ }
587
+ if($saved_saswp_business_name){
588
+ $business_name = $saved_saswp_business_name;
589
+ }
590
+ $meta_field = array();
591
+ switch ($schema_type) {
592
+
593
+ case 'local_business':
594
+ $sub_business_options = array();
595
+ switch ($business_type) {
596
+ case 'automotivebusiness':
597
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
598
+ break;
599
+ case 'emergencyservice':
600
+
601
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
602
+ break;
603
+ case 'entertainmentbusiness':
604
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
605
+ break;
606
+ case 'financialservice':
607
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
608
+ break;
609
+ case 'foodestablishment':
610
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
611
+ break;
612
+ case 'healthandbeautybusiness':
613
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
614
+ break;
615
+ case 'homeandconstructionbusiness':
616
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
617
+ break;
618
+ case 'legalservice':
619
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
620
+ break;
621
+ case 'lodgingbusiness':
622
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
623
+ break;
624
+ case 'sportsactivitylocation':
625
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
626
+ break;
627
+ case 'store':
628
+ $this->options_response = $this->saswp_get_sub_business_array($business_type);
629
+ break;
630
+ default:
631
+ break;
632
+ }
633
+
634
+ if(!empty($this->options_response)){
635
+ $sub_business_options = array(
636
+ 'label' => 'Sub Business Type',
637
+ 'id' => 'saswp_business_name_'.$schema_id,
638
+ 'type' => 'select',
639
+ 'options' => $this->options_response,
640
+ 'default' => $business_name
641
+ );
642
+ }
643
+
644
+ $meta_field = array(
645
+ array(
646
+ 'label' => 'Business Type',
647
+ 'id' => 'saswp_business_type_'.$schema_id,
648
+ 'type' => 'select',
649
+ 'default' => $business_type,
650
+ 'options' => array(
651
+ 'animalshelter' => 'Animal Shelter',
652
+ 'automotivebusiness' => 'Automotive Business',
653
+ 'childcare' => 'ChildCare',
654
+ 'dentist' => 'Dentist',
655
+ 'drycleaningorlaundry' => 'Dry Cleaning Or Laundry',
656
+ 'emergencyservice' => 'Emergency Service',
657
+ 'employmentagency' => 'Employment Agency',
658
+ 'entertainmentbusiness' => 'Entertainment Business',
659
+ 'financialservice' => 'Financial Service',
660
+ 'foodestablishment' => 'Food Establishment',
661
+ 'governmentoffice' => 'Government Office',
662
+ 'healthandbeautybusiness' => 'Health And Beauty Business',
663
+ 'homeandconstructionbusiness' => 'Home And Construction Business',
664
+ 'internetcafe' => 'Internet Cafe',
665
+ 'legalservice' => 'Legal Service',
666
+ 'library' => 'Library',
667
+ 'lodgingbusiness' => 'Lodging Business',
668
+ 'professionalservice' => 'Professional Service',
669
+ 'radiostation' => 'Radio Station',
670
+ 'realestateagent' => 'Real Estate Agent',
671
+ 'recyclingcenter' => 'Recycling Center',
672
+ 'selfstorage' => 'Self Storage',
673
+ 'shoppingcenter' => 'Shopping Center',
674
+ 'sportsactivitylocation' => 'Sports Activity Location',
675
+ 'store' => 'Store',
676
+ 'televisionstation' => 'Television Station',
677
+ 'touristinformationcenter' => 'Tourist Information Center',
678
+ 'travelagency' => 'Travel Agency',
679
+ )
680
+ ),
681
+ $sub_business_options,
682
+ array(
683
+ 'label' => 'Business Name',
684
+ 'id' => 'local_business_name_'.$schema_id,
685
+ 'type' => 'text',
686
+ 'default' => $business_details['local_business_name']
687
+ ),
688
+
689
+ array(
690
+ 'label' => 'URL',
691
+ 'id' => 'local_business_name_url_'.$schema_id,
692
+ 'type' => 'text',
693
+ 'default' => get_permalink()
694
+ ),
695
+ array(
696
+ 'label' => 'Description',
697
+ 'id' => 'local_business_description_'.$schema_id,
698
+ 'type' => 'text',
699
+ 'default' => $post->post_excerpt
700
+ ),
701
+ array(
702
+ 'label' => 'Street Address',
703
+ 'id' => 'local_street_address_'.$schema_id,
704
+ 'type' => 'text',
705
+ 'default' => $business_details['local_street_address']
706
+ ),
707
+ array(
708
+ 'label' => 'City',
709
+ 'id' => 'local_city_'.$schema_id,
710
+ 'type' => 'text',
711
+ 'default' => $business_details['local_city']
712
+ ),
713
+ array(
714
+ 'label' => 'State',
715
+ 'id' => 'local_state_'.$schema_id,
716
+ 'type' => 'text',
717
+ 'default' => $business_details['local_state']
718
+ ),
719
+ array(
720
+ 'label' => 'Postal Code',
721
+ 'id' => 'local_postal_code_'.$schema_id,
722
+ 'type' => 'text',
723
+ 'default' => $business_details['local_postal_code']
724
+ ),
725
+ array(
726
+ 'label' => 'Phone',
727
+ 'id' => 'local_phone_'.$schema_id,
728
+ 'type' => 'text',
729
+ 'default' => $business_details['local_phone']
730
+ ),
731
+ array(
732
+ 'label' => 'Website',
733
+ 'id' => 'local_website_'.$schema_id,
734
+ 'type' => 'text',
735
+ 'default' => $business_details['local_website']
736
+ ),
737
+ array(
738
+ 'label' => 'Image',
739
+ 'id' => 'local_business_logo_'.$schema_id,
740
+ 'type' => 'media',
741
+ 'default' => $business_details['local_business_logo']['url']
742
+ ),
743
+ array(
744
+ 'label' => 'Operation Days',
745
+ 'id' => 'saswp_dayofweek_'.$schema_id,
746
+ 'type' => 'multiselect',
747
+ 'options' => array(
748
+ 'monday' => 'Monday',
749
+ 'tuesday' => 'Tuesday',
750
+ 'wednesday' => 'Wednesday',
751
+ 'thursday' => 'Thursday',
752
+ 'friday' => 'Friday',
753
+ 'staturday' => 'Staturday',
754
+ 'sunday' => 'Sunday',
755
+ ),
756
+ 'default' => $business_details['saswp_dayofweek']
757
+ ),
758
+ array(
759
+ 'label' => 'Opens',
760
+ 'id' => 'local_opens_time_'.$schema_id,
761
+ 'type' => 'text',
762
+ 'default' => $business_details['local_opens_time']
763
+ ),
764
+ array(
765
+ 'label' => 'Closes',
766
+ 'id' => 'local_closes_time_'.$schema_id,
767
+ 'type' => 'text',
768
+ 'default' => $business_details['local_closes_time']
769
+ ),
770
+ array(
771
+ 'label' => 'Price Range',
772
+ 'id' => 'local_price_range_'.$schema_id,
773
+ 'type' => 'text',
774
+ 'default' => $business_details['local_price_range']
775
+ ),
776
+ );
777
+
778
+ break;
779
+
780
+ case 'Blogposting':
781
+ $meta_field = array(
782
+ array(
783
+ 'label' => 'Main Entity Of Page',
784
+ 'id' => 'saswp_blogposting_main_entity_of_page_'.$schema_id,
785
+ 'type' => 'text',
786
+ 'default' => get_permalink()
787
+ ),
788
+ array(
789
+ 'label' => 'Headline',
790
+ 'id' => 'saswp_blogposting_headline_'.$schema_id,
791
+ 'type' => 'text',
792
+ 'default'=> get_the_title()
793
+ ),
794
+ array(
795
+ 'label' => 'Description',
796
+ 'id' => 'saswp_blogposting_description_'.$schema_id,
797
+ 'type' => 'text',
798
+ 'default' => $post->post_excerpt,
799
+ ),
800
+ array(
801
+ 'label' => 'Name',
802
+ 'id' => 'saswp_blogposting_name_'.$schema_id,
803
+ 'type' => 'text',
804
+ 'default' => get_the_title()
805
+ ),
806
+ array(
807
+ 'label' => 'URL',
808
+ 'id' => 'saswp_blogposting_url_'.$schema_id,
809
+ 'type' => 'text',
810
+ 'default' => get_permalink()
811
+ ),
812
+ array(
813
+ 'label' => 'Date Published',
814
+ 'id' => 'saswp_blogposting_date_published_'.$schema_id,
815
+ 'type' => 'text',
816
+ 'default' => get_the_date("Y-m-d")
817
+ ),
818
+ array(
819
+ 'label' => 'Date Modified',
820
+ 'id' => 'saswp_blogposting_date_modified_'.$schema_id,
821
+ 'type' => 'text',
822
+ 'default' => get_the_modified_date("Y-m-d")
823
+ ),
824
+ array(
825
+ 'label' => 'Author Name',
826
+ 'id' => 'saswp_blogposting_author_name_'.$schema_id,
827
+ 'type' => 'text',
828
+ 'default' => $current_user->display_name
829
+ ),
830
+ array(
831
+ 'label' => 'Organization Name',
832
+ 'id' => 'saswp_blogposting_organization_name_'.$schema_id,
833
+ 'type' => 'text',
834
+ 'default' => $sd_data['sd_name']
835
+ ),
836
+ array(
837
+ 'label' => 'Organization Logo',
838
+ 'id' => 'saswp_blogposting_organization_logo_'.$schema_id,
839
+ 'type' => 'media',
840
+ 'default' => $sd_data['sd_logo']['url']
841
+ )
842
+ );
843
+ break;
844
+
845
+ case 'NewsArticle':
846
+ $meta_field = array(
847
+ array(
848
+ 'label' => 'Main Entity Of Page',
849
+ 'id' => 'saswp_newsarticle_main_entity_of_page_'.$schema_id,
850
+ 'type' => 'text',
851
+ 'default' => get_permalink()
852
+ ),
853
+ array(
854
+ 'label' => 'URL',
855
+ 'id' => 'saswp_newsarticle_URL_'.$schema_id,
856
+ 'type' => 'text',
857
+ 'default' => get_permalink(),
858
+ ),
859
+ array(
860
+ 'label' => 'Headline',
861
+ 'id' => 'saswp_newsarticle_headline_'.$schema_id,
862
+ 'type' => 'text',
863
+ 'default' => get_the_title(),
864
+ ),
865
+ array(
866
+ 'label' => 'Date Published',
867
+ 'id' => 'saswp_newsarticle_date_published_'.$schema_id,
868
+ 'type' => 'text',
869
+ 'default' => get_the_date("Y-m-d")
870
+ ),
871
+ array(
872
+ 'label' => 'Date Modified',
873
+ 'id' => 'saswp_newsarticle_date_modified_'.$schema_id,
874
+ 'type' => 'text',
875
+ 'default' => get_the_modified_date("Y-m-d")
876
+ ),
877
+ array(
878
+ 'label' => 'Description',
879
+ 'id' => 'saswp_newsarticle_description_'.$schema_id,
880
+ 'type' => 'text',
881
+ 'default' => $post->post_excerpt
882
+ ),
883
+ array(
884
+ 'label' => 'Name',
885
+ 'id' => 'saswp_newsarticle_name_'.$schema_id,
886
+ 'type' => 'text',
887
+ 'default' => get_the_title()
888
+ ),
889
+ array(
890
+ 'label' => 'Thumbnail URL',
891
+ 'id' => 'saswp_newsarticle_thumbnailurl_'.$schema_id,
892
+ 'type' => 'text',
893
+ 'default' => $image_details[0]
894
+ ),
895
+ array(
896
+ 'label' => 'Main Entity Id',
897
+ 'id' => 'saswp_newsarticle_main_entity_id_'.$schema_id,
898
+ 'type' => 'text',
899
+ 'default' => get_permalink()
900
+ ),
901
+ array(
902
+ 'label' => 'Author Name',
903
+ 'id' => 'saswp_newsarticle_author_name_'.$schema_id,
904
+ 'type' => 'text',
905
+ 'default' => $current_user->display_name
906
+ ),
907
+ array(
908
+ 'label' => 'Author Image',
909
+ 'id' => 'saswp_newsarticle_author_image_'.$schema_id,
910
+ 'type' => 'media',
911
+ 'default' => $author_details['url']
912
+ ),
913
+ array(
914
+ 'label' => 'Organization Name',
915
+ 'id' => 'saswp_newsarticle_organization_name_'.$schema_id,
916
+ 'type' => 'text',
917
+ 'default'=>$sd_data['sd_name']
918
+ ),
919
+ array(
920
+ 'label' => 'Organization Logo',
921
+ 'id' => 'saswp_newsarticle_organization_logo_'.$schema_id,
922
+ 'type' => 'media',
923
+ 'default' => $sd_data['sd_logo']['url']
924
+ ),
925
+ );
926
+ break;
927
+
928
+ case 'WebPage':
929
+ $meta_field = array(
930
+ array(
931
+ 'label' => 'Name',
932
+ 'id' => 'saswp_webpage_name_'.$schema_id,
933
+ 'type' => 'text',
934
+ 'default' => get_the_title()
935
+ ),
936
+ array(
937
+ 'label' => 'URL',
938
+ 'id' => 'saswp_webpage_url_'.$schema_id,
939
+ 'type' => 'text',
940
+ 'default' => get_permalink()
941
+ ),
942
+ array(
943
+ 'label' => 'Description',
944
+ 'id' => 'saswp_webpage_description_'.$schema_id,
945
+ 'type' => 'text',
946
+ 'default' => $post->post_excerpt
947
+ ),
948
+ array(
949
+ 'label' => 'Main Entity Of Page',
950
+ 'id' => 'saswp_webpage_main_entity_of_page_'.$schema_id,
951
+ 'type' => 'text',
952
+ 'default' => get_permalink()
953
+ ),
954
+ array(
955
+ 'label' => 'Image',
956
+ 'id' => 'saswp_webpage_image_'.$schema_id,
957
+ 'type' => 'media',
958
+ 'default' => $image_details[0]
959
+ ),
960
+ array(
961
+ 'label' => 'Headline',
962
+ 'id' => 'saswp_webpage_headline_'.$schema_id,
963
+ 'type' => 'text',
964
+ 'default' => get_the_title(),
965
+ ),
966
+ array(
967
+ 'label' => 'Description',
968
+ 'id' => 'saswp_webpage_description_'.$schema_id,
969
+ 'type' => 'text',
970
+ 'default' => $post->post_excerpt
971
+ ),
972
+ array(
973
+ 'label' => 'Date Published',
974
+ 'id' => 'saswp_webpage_date_published_'.$schema_id,
975
+ 'type' => 'text',
976
+ 'default' => get_the_date("Y-m-d")
977
+ ),
978
+ array(
979
+ 'label' => 'Date Modified',
980
+ 'id' => 'saswp_webpage_date_modified_'.$schema_id,
981
+ 'type' => 'text',
982
+ 'default' => get_the_modified_date("Y-m-d")
983
+ ),
984
+ array(
985
+ 'label' => 'Author Name',
986
+ 'id' => 'saswp_webpage_author_name_'.$schema_id,
987
+ 'type' => 'text',
988
+ 'default' => $current_user->display_name
989
+ ),
990
+ array(
991
+ 'label' => 'Organization Name',
992
+ 'id' => 'saswp_webpage_organization_name_'.$schema_id,
993
+ 'type' => 'text',
994
+ 'default' => $sd_data['sd_name']
995
+ ),
996
+ array(
997
+ 'label' => 'Organization Logo',
998
+ 'id' => 'saswp_webpage_organization_logo_'.$schema_id,
999
+ 'type' => 'media',
1000
+ 'default' => $sd_data['sd_logo']['url']
1001
+ ),
1002
+ );
1003
+ break;
1004
+
1005
+ case 'Article':
1006
+ $meta_field = array(
1007
+ array(
1008
+ 'label' => 'Main Entity Of Page',
1009
+ 'id' => 'saswp_article_main_entity_of_page_'.$schema_id,
1010
+ 'type' => 'text',
1011
+ 'default' => get_permalink()
1012
+ ),
1013
+ array(
1014
+ 'label' => 'Image',
1015
+ 'id' => 'saswp_article_image_'.$schema_id,
1016
+ 'type' => 'media',
1017
+ 'default' => $image_details[0]
1018
+ ),
1019
+ array(
1020
+ 'label' => 'Headline',
1021
+ 'id' => 'saswp_article_headline_'.$schema_id,
1022
+ 'type' => 'text',
1023
+ 'default' => get_the_title()
1024
+ ),
1025
+ array(
1026
+ 'label' => 'Description',
1027
+ 'id' => 'saswp_article_description_'.$schema_id,
1028
+ 'type' => 'textarea',
1029
+ 'default' => $post->post_excerpt
1030
+ ) ,
1031
+ array(
1032
+ 'label' => 'Date Published',
1033
+ 'id' => 'saswp_article_date_published_'.$schema_id,
1034
+ 'type' => 'text',
1035
+ 'default' => get_the_date("Y-m-d")
1036
+ ),
1037
+ array(
1038
+ 'label' => 'Date Modified',
1039
+ 'id' => 'saswp_article_date_modified_'.$schema_id,
1040
+ 'type' => 'text',
1041
+ 'default' => get_the_modified_date("Y-m-d")
1042
+ ),
1043
+ array(
1044
+ 'label' => 'Author Name',
1045
+ 'id' => 'saswp_article_author_name_'.$schema_id,
1046
+ 'type' => 'text',
1047
+ 'default' => $current_user->display_name
1048
+ ),
1049
+ array(
1050
+ 'label' => 'Organization Name',
1051
+ 'id' => 'saswp_article_organization_name_'.$schema_id,
1052
+ 'type' => 'text',
1053
+ 'default' => $sd_data['sd_name']
1054
+ ),
1055
+ array(
1056
+ 'label' => 'Organization Logo',
1057
+ 'id' => 'saswp_article_organization_logo_'.$schema_id,
1058
+ 'type' => 'media',
1059
+ 'default' => $sd_data['sd_logo']['url']
1060
+ )
1061
+ );
1062
+ break;
1063
+
1064
+ case 'Recipe':
1065
+ $meta_field = array(
1066
+ array(
1067
+ 'label' => 'URL',
1068
+ 'id' => 'saswp_recipe_url_'.$schema_id,
1069
+ 'type' => 'text',
1070
+ 'default' => get_permalink(),
1071
+ ),
1072
+ array(
1073
+ 'label' => 'Name',
1074
+ 'id' => 'saswp_recipe_name_'.$schema_id,
1075
+ 'type' => 'text',
1076
+ 'default' => get_the_title()
1077
+ ),
1078
+ array(
1079
+ 'label' => 'Date Published',
1080
+ 'id' => 'saswp_recipe_date_published_'.$schema_id,
1081
+ 'type' => 'text',
1082
+ 'default' => get_the_date("Y-m-d")
1083
+ ),
1084
+ array(
1085
+ 'label' => 'Date Modified',
1086
+ 'id' => 'saswp_recipe_date_modified_'.$schema_id,
1087
+ 'type' => 'text',
1088
+ 'default' => get_the_modified_date("Y-m-d")
1089
+ ),
1090
+ array(
1091
+ 'label' => 'Description',
1092
+ 'id' => 'saswp_recipe_description_'.$schema_id,
1093
+ 'type' => 'text',
1094
+ 'default' => $post->post_excerpt
1095
+ ),
1096
+ array(
1097
+ 'label' => 'Main Entity Id',
1098
+ 'id' => 'saswp_recipe_main_entity_'.$schema_id,
1099
+ 'type' => 'text',
1100
+ 'default' => get_permalink()
1101
+ ),
1102
+ array(
1103
+ 'label' => 'Author Name',
1104
+ 'id' => 'saswp_recipe_author_name_'.$schema_id,
1105
+ 'type' => 'text',
1106
+ 'default' => $current_user->display_name
1107
+ ),
1108
+ array(
1109
+ 'label' => 'Author Image',
1110
+ 'id' => 'saswp_recipe_author_image_'.$schema_id,
1111
+ 'type' => 'media',
1112
+ 'default' => $author_details['url']
1113
+ ),
1114
+ array(
1115
+ 'label' => 'Organization Name',
1116
+ 'id' => 'saswp_recipe_organization_name_'.$schema_id,
1117
+ 'type' => 'text',
1118
+ 'default' => $sd_data['sd_name']
1119
+ ),
1120
+ array(
1121
+ 'label' => 'Organization Logo',
1122
+ 'id' => 'saswp_recipe_organization_logo_'.$schema_id,
1123
+ 'type' => 'media',
1124
+ 'default' => $sd_data['sd_logo']['url']
1125
+ ),
1126
+ );
1127
+ break;
1128
+
1129
+ case 'Product':
1130
+ $meta_field = array(
1131
+ array(
1132
+ 'label' => 'URL',
1133
+ 'id' => 'saswp_product_url_'.$schema_id,
1134
+ 'type' => 'text',
1135
+ 'default' => get_permalink()
1136
+ ),
1137
+ array(
1138
+ 'label' => 'Name',
1139
+ 'id' => 'saswp_product_name_'.$schema_id,
1140
+ 'type' => 'text',
1141
+ 'default' => get_the_title(),
1142
+ ),
1143
+ array(
1144
+ 'label' => 'Description',
1145
+ 'id' => 'saswp_product_description_'.$schema_id,
1146
+ 'type' => 'text',
1147
+ 'default' => $post->post_excerpt
1148
+ ),
1149
+ );
1150
+ break;
1151
+
1152
+ case 'VideoObject':
1153
+ $meta_field = array(
1154
+ array(
1155
+ 'label' => 'URL',
1156
+ 'id' => 'saswp_video_object_url_'.$schema_id,
1157
+ 'type' => 'text',
1158
+ 'default' => get_permalink()
1159
+ ),
1160
+ array(
1161
+ 'label' => 'Headline',
1162
+ 'id' => 'saswp_video_object_headline_'.$schema_id,
1163
+ 'type' => 'text',
1164
+ 'default' => get_the_title()
1165
+ ),
1166
+ array(
1167
+ 'label' => 'Date Published',
1168
+ 'id' => 'saswp_video_object_date_published_'.$schema_id,
1169
+ 'type' => 'text',
1170
+ 'default' => get_the_date("Y-m-d")
1171
+ ),
1172
+ array(
1173
+ 'label' => 'Date date Modified',
1174
+ 'id' => 'saswp_video_object_date_modified_'.$schema_id,
1175
+ 'type' => 'text',
1176
+ 'default' => get_the_modified_date("Y-m-d")
1177
+ ),
1178
+ array(
1179
+ 'label' => 'Description',
1180
+ 'id' => 'saswp_video_object_description_'.$schema_id,
1181
+ 'type' => 'text',
1182
+ 'default' => $post->post_excerpt
1183
+ ),
1184
+ array(
1185
+ 'label' => 'Name',
1186
+ 'id' => 'saswp_video_object_name_'.$schema_id,
1187
+ 'type' => 'text',
1188
+ 'default' => get_the_title()
1189
+ ),
1190
+ array(
1191
+ 'label' => 'Upload Date',
1192
+ 'id' => 'saswp_video_object_upload_date_'.$schema_id,
1193
+ 'type' => 'text',
1194
+ 'default' => get_the_date("Y-m-d")
1195
+ ),
1196
+ array(
1197
+ 'label' => 'Thumbnail Url',
1198
+ 'id' => 'saswp_video_object_thumbnail_url_'.$schema_id,
1199
+ 'type' => 'text',
1200
+ 'default' => $image_details[0]
1201
+ ),
1202
+ array(
1203
+ 'label' => 'Main Entity Id',
1204
+ 'id' => 'saswp_video_object_main_entity_id_'.$schema_id,
1205
+ 'type' => 'text',
1206
+ 'default' => get_permalink()
1207
+ ),
1208
+ array(
1209
+ 'label' => 'Author Name',
1210
+ 'id' => 'saswp_video_object_author_name_'.$schema_id,
1211
+ 'type' => 'text',
1212
+ 'default' => $current_user->display_name
1213
+ ),
1214
+ array(
1215
+ 'label' => 'Author Image',
1216
+ 'id' => 'saswp_video_object_author_image_'.$schema_id,
1217
+ 'type' => 'media',
1218
+ 'default' => $author_details['url']
1219
+ ),
1220
+ array(
1221
+ 'label' => 'Organization Name',
1222
+ 'id' => 'saswp_video_object_organization_name_'.$schema_id,
1223
+ 'type' => 'text',
1224
+ 'default' => $sd_data['sd_name']
1225
+ ),
1226
+ array(
1227
+ 'label' => 'Organization Logo',
1228
+ 'id' => 'saswp_video_object_organization_logo_'.$schema_id,
1229
+ 'type' => 'media',
1230
+ 'default' => $sd_data['sd_logo']['url']
1231
+ ),
1232
+ );
1233
+ break;
1234
+
1235
+ default:
1236
+ break;
1237
+ }
1238
+ return $meta_field;
1239
+ }
1240
+ }
1241
+ if (class_exists('saswp_post_specific')) {
1242
+ $object = new saswp_post_specific();
1243
+ $object->saswp_post_specific_hooks();
1244
+ };
1245
+
1246
+
view/review.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class saswp_metaboxes_review {
3
+
4
+ public function __construct() {
5
+ add_action( 'add_meta_boxes', array( $this, 'saswp_review_add_meta_box' ) );
6
+ add_action( 'save_post', array( $this, 'saswp_review_save' ) );
7
+ }
8
+ function saswp_review_add_meta_box($post) {
9
+ global $sd_data;
10
+ if(get_post_status($post->ID)=='publish' && $sd_data['saswp-review-module']==1){
11
+ add_meta_box(
12
+ 'sasw-review',
13
+ esc_html__( 'Review', 'schema-and-structured-data-for-wp' ),
14
+ array( $this, 'saswp_meta_box_callback' ),
15
+ 'post',
16
+ 'advanced',
17
+ 'default'
18
+ );
19
+ }
20
+ }
21
+ function saswp_review_get_meta( $value ) {
22
+ global $post;
23
+
24
+ $field = get_post_meta( $post->ID, $value, true );
25
+
26
+ if ( ! empty( $field ) ) {
27
+ return is_array( $field ) ? stripslashes_deep( $field ) : stripslashes( wp_kses_decode_entities( $field ) );
28
+ } else {
29
+ return false;
30
+ }
31
+ }
32
+ function saswp_meta_box_callback( $post) {
33
+
34
+ wp_nonce_field( 'saswp_review_nonce', 'saswp_review_nonce' );
35
+ $saswp_review_details = esc_sql ( get_post_meta($post->ID, 'saswp_review_details', true));
36
+ $saswp_review_item_feature = array();
37
+ $saswp_review_item_star_rating = array();
38
+
39
+ if(isset($saswp_review_details['saswp-review-item-feature'])){
40
+ $saswp_review_item_feature = $saswp_review_details['saswp-review-item-feature'];
41
+ }
42
+ if(isset($saswp_review_details['saswp-review-item-star-rating'])){
43
+ $saswp_review_item_star_rating = $saswp_review_details['saswp-review-item-star-rating'];
44
+ }
45
+
46
+ ?>
47
+ <div>
48
+ <div class="saswp-enable-review-on-post"><label><?php echo esc_html__('Enable/Disable', 'schema-and-structured-data-for-wp'); ?> <input type="checkbox" id="saswp-review-item-enable" name="saswp-review-item-enable" <?php echo (isset( $saswp_review_details['saswp-review-item-enable'] ) && $saswp_review_details['saswp-review-item-enable'] == 1 ? 'checked="checked"' : ''); ?> value="1"></label></div>
49
+
50
+ <div class="saswp-review-fields">
51
+ <div class="saswp-review-item">
52
+ <table class="saswp-review-tables">
53
+ <tr>
54
+ <td><label><?php echo esc_html__('Review Title', 'schema-and-structured-data-for-wp'); ?></label></td>
55
+ <td><div class="saswp-field"><input type="text" id="saswp-review-item-title" name="saswp-review-item-title" value="<?php if ( isset( $saswp_review_details['saswp-review-item-title'] ) && ( ! empty( $saswp_review_details['saswp-review-item-title'] ) ) ) echo esc_attr( $saswp_review_details['saswp-review-item-title'] ); ?>"></div></td>
56
+ </tr>
57
+ <tr>
58
+ <td><label><?php echo esc_html__('Review Location', 'schema-and-structured-data-for-wp'); ?></label></td>
59
+ <td>
60
+ <div class="saswp-field">
61
+ <select id="saswp-review-location" name="saswp-review-location">
62
+ <option value="1" <?php if ( isset( $saswp_review_details['saswp-review-location'] ) && ( $saswp_review_details['saswp-review-location'] == 1 ) ) echo 'selected'; ?>><?php echo esc_html__('After The Content', 'schema-and-structured-data-for-wp'); ?></option>
63
+ <option value="2" <?php if ( isset( $saswp_review_details['saswp-review-location'] ) && ( $saswp_review_details['saswp-review-location'] == 2 ) ) echo 'selected'; ?>><?php echo esc_html__('Before The Content', 'schema-and-structured-data-for-wp'); ?></option>
64
+ <option value="3" <?php if ( isset( $saswp_review_details['saswp-review-location'] ) && ( $saswp_review_details['saswp-review-location'] == 3 ) ) echo 'selected'; ?>><?php echo esc_html__('Custom (Use ShortCode)', 'schema-and-structured-data-for-wp'); ?></option>
65
+ </select>
66
+ <input class="saswp-review-shortcode" type="text" value="<?php echo '[saswp-review id=&quot;review&quot;]'; ?>" readonly>
67
+ </div>
68
+ </td>
69
+ </tr>
70
+
71
+ </table>
72
+ </div>
73
+
74
+ <div class="saspw-review-item-list">
75
+ <table class="saswp-review-item-list-table saswp-review-tables">
76
+
77
+ <?php
78
+ if(!empty($saswp_review_item_feature)){
79
+ for ($i=0; $i<count($saswp_review_item_feature); $i++){
80
+ ?>
81
+ <tr class="saswp-review-item-tr">
82
+ <td><?php echo esc_html__('Review Item Feature', 'schema-and-structured-data-for-wp'); ?></td>
83
+ <td><input type="text" name="saswp-review-item-feature[]" value="<?php echo esc_attr($saswp_review_item_feature[$i]); ?>"></td>
84
+ <td><?php echo esc_html__('Rating', 'schema-and-structured-data-for-wp'); ?></td>
85
+ <td><input step="0.1" min="0" max="5" type="number" name="saswp-review-item-star-rating[]" value="<?php echo esc_attr($saswp_review_item_star_rating[$i]); ?>"></td>
86
+ <td><a type="button" class="saswp-remove-review-item button">x</a></td>
87
+ </tr>
88
+ <?php
89
+ }
90
+ }
91
+ ?>
92
+ </table>
93
+ <div class="saswp-over-all-raring"><label><?php echo esc_html__('Over All Rating', 'schema-and-structured-data-for-wp'); ?></label><input type="text" id="saswp-review-item-over-all" name="saswp-review-item-over-all" value="<?php if ( isset( $saswp_review_details['saswp-review-item-over-all'] ) && ( ! empty( $saswp_review_details['saswp-review-item-over-all'] ) ) ) echo esc_attr( $saswp_review_details['saswp-review-item-over-all'] ); ?>" readonly></div>
94
+ <div><a class="button saswp-add-more-item"><?php echo esc_html__('Add Item', 'schema-and-structured-data-for-wp'); ?></a></div>
95
+ </div>
96
+
97
+ <div class="saswp-review-description">
98
+ <div><label><?php echo esc_html__('Summary Title', 'schema-and-structured-data-for-wp'); ?></label> <input type="text" id="saswp-review-item-description-title" name="saswp-review-item-description-title" value="<?php if ( isset( $saswp_review_details['saswp-review-item-description-title'] ) && ( ! empty( $saswp_review_details['saswp-review-item-description-title'] ) ) ) echo esc_attr( $saswp_review_details['saswp-review-item-description-title'] ); ?>"></div>
99
+ <div class="saswp-wp-ediot-desc"><label>Description</label></div>
100
+ <?php
101
+ $content = get_post_meta( $post->ID, 'saswp-review-item-description', true );
102
+ wp_editor( $content, 'saswp-review-item-description', array('textarea_rows'=> '5', 'media_buttons' => FALSE,) );
103
+ ?>
104
+ </div>
105
+
106
+ <div class="saswp-review-pros-and-cons">
107
+ <div class="saswp-props">
108
+ <div class="saswp-wp-ediot-desc"><label><?php echo esc_html__('Pros', 'schema-and-structured-data-for-wp'); ?></label></div>
109
+ <?php
110
+ $content = get_post_meta( $post->ID, 'saswp-review-item-props', true );
111
+ wp_editor( $content, 'saswp-review-item-props',
112
+ array(
113
+ 'tinymce' => array(
114
+ 'toolbar1' => 'bold,italic,underline,bullist,numlist,separator,separator,link,unlink,undo,redo,removeformat',
115
+ 'toolbar2' => '',
116
+ 'toolbar3' => '',
117
+ ),
118
+ 'quicktags' => true,
119
+ 'media_buttons' => false,
120
+ 'textarea_rows' => 6,
121
+ )
122
+ );
123
+ ?>
124
+ </div>
125
+ <div class="saswp-cons">
126
+ <div class="saswp-wp-ediot-desc"><label><?php echo esc_html__('Cons', 'schema-and-structured-data-for-wp'); ?></label></div>
127
+ <?php
128
+ $content = get_post_meta( $post->ID, 'saswp-review-item-cons', true );
129
+ wp_editor( $content,
130
+ 'saswp-review-item-cons',
131
+ array(
132
+ 'tinymce' => array(
133
+ 'toolbar1' => 'bold,italic,underline,bullist,numlist,separator,separator,link,unlink,undo,redo,removeformat',
134
+ 'toolbar2' => '',
135
+ 'toolbar3' => '',
136
+ ),
137
+ 'quicktags' => true,
138
+ 'media_buttons' => false,
139
+ 'textarea_rows' => 6,
140
+ )
141
+ );
142
+ ?>
143
+ </div>
144
+ <div class="clearfix"></div>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ <?php
149
+ }
150
+
151
+ function saswp_review_save( $post_id ) {
152
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
153
+ if ( ! isset( $_POST['saswp_review_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_review_nonce'], 'saswp_review_nonce' ) ) return;
154
+ if ( ! current_user_can( 'edit_post', $post_id ) ) return;
155
+
156
+ $saswp_review_details = array();
157
+
158
+ if(isset($_POST['saswp-review-item-title'])){
159
+ $saswp_review_details['saswp-review-item-title'] = sanitize_text_field($_POST['saswp-review-item-title']);
160
+ }
161
+ if(isset($_POST['saswp-review-location'])){
162
+ $saswp_review_details['saswp-review-location'] = sanitize_text_field($_POST['saswp-review-location']);
163
+ }
164
+ if(isset($_POST['saswp-review-item-feature'])){
165
+ $saswp_review_details['saswp-review-item-feature'] = array_map( 'sanitize_text_field', wp_unslash( $_POST['saswp-review-item-feature'] ) );
166
+ }
167
+ if(isset($_POST['saswp-review-item-star-rating'])){
168
+ $saswp_review_details['saswp-review-item-star-rating'] = array_map( 'sanitize_text_field', wp_unslash( $_POST['saswp-review-item-star-rating'] ) );
169
+ }
170
+ if(isset($_POST['saswp-review-item-over-all'])){
171
+ $saswp_review_details['saswp-review-item-over-all'] = sanitize_text_field($_POST['saswp-review-item-over-all']);
172
+ }
173
+ if(isset($_POST['saswp-review-item-description-title'])){
174
+ $saswp_review_details['saswp-review-item-description-title'] = sanitize_text_field($_POST['saswp-review-item-description-title']);
175
+ }
176
+ if(isset($_POST['saswp-review-item-enable'])){
177
+ $saswp_review_details['saswp-review-item-enable'] = sanitize_text_field($_POST['saswp-review-item-enable']);
178
+ }
179
+ if(isset($_POST['saswp-review-item-description'])){
180
+ update_post_meta( $post_id, 'saswp-review-item-description', wp_kses_post( wp_unslash( $_POST['saswp-review-item-description'] )) );
181
+
182
+ }
183
+ if(isset($_POST['saswp-review-item-props'])){
184
+ update_post_meta( $post_id, 'saswp-review-item-props', wp_kses_post( wp_unslash( $_POST['saswp-review-item-props'] )) );
185
+ }
186
+ if(isset($_POST['saswp-review-item-cons'])){
187
+ update_post_meta( $post_id, 'saswp-review-item-cons', wp_kses_post( wp_unslash( $_POST['saswp-review-item-cons'] )) );
188
+ }
189
+ if(!empty($saswp_review_details)){
190
+ update_post_meta( $post_id, 'saswp_review_details', $saswp_review_details );
191
+ }
192
+ }
193
+ }
194
+ if (class_exists('saswp_metaboxes_review')) {
195
+ new saswp_metaboxes_review;
196
+ };
view/schema_type.php CHANGED
@@ -537,10 +537,14 @@
537
 
538
  if ( isset( $_POST['saswp_business_type'] ) ){
539
  update_post_meta( $post_id, 'saswp_business_type', esc_attr( $_POST['saswp_business_type'] ) );
 
 
540
  }
541
 
542
  if ( isset( $_POST['saswp_business_name'] ) ){
543
  update_post_meta( $post_id, 'saswp_business_name', esc_attr( $_POST['saswp_business_name'] ) );
 
 
544
  }
545
 
546
  $local_business_details = array();
537
 
538
  if ( isset( $_POST['saswp_business_type'] ) ){
539
  update_post_meta( $post_id, 'saswp_business_type', esc_attr( $_POST['saswp_business_type'] ) );
540
+ }else{
541
+ update_post_meta( $post_id, 'saswp_business_type', '' );
542
  }
543
 
544
  if ( isset( $_POST['saswp_business_name'] ) ){
545
  update_post_meta( $post_id, 'saswp_business_name', esc_attr( $_POST['saswp_business_name'] ) );
546
+ }else{
547
+ update_post_meta( $post_id, 'saswp_business_name', '' );
548
  }
549
 
550
  $local_business_details = array();