Version Description
(14 December 2018) =
- New Feature: Review schema type add to the schema type list
- New Feature: Compatibility with Extra theme by Elegant Themes ( https://www.elegantthemes.com ) , Now extra theme built in review and rating will be indexed in google after enabling option
- New Feature: Compatibility with WooCommerce ( https://wordpress.org/plugins/woocommerce ), Now the product schema with its WooCommerce product details will be indexed in google search
- New Feature: Q&A schema type add to the schema type list, Currently it is compatible with DW Question & Answer plugin ( https://wordpress.org/plugins/dw-question-answer )
- New Feature: Modify Schema output, custom fields can be selected for schema fields
- Improvement: Different opening and closing hours for different days of the week in local business schema type
- Improvement: Now post specific modify schema will support on page and custom post type
- Improvement: Added missing recipe fields in the post specific metabox #81
- Bug Fixed: Compatibility issue with the Blackbar plugin #83
- Bug Fixed: Restore schema button was not working on first load #81
Download this release
Release Info
Developer | ampforwp |
Plugin | Schema & Structured Data for WP & AMP |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.6
- admin_section/add-schema/add_new.php +5 -0
- admin_section/css/main-style.css +7 -0
- admin_section/css/saswp-add-new.css +6 -0
- admin_section/js/main-script.js +135 -4
- admin_section/js/saswp-add-new.js +10 -1
- admin_section/settings.php +59 -3
- admin_section/structure_admin.php +8 -0
- output/function.php +5 -5
- output/output.php +627 -154
- output/service.php +1043 -0
- readme.txt +16 -7
- structured-data-for-wp.php +4 -3
- view/paywall.php +73 -8
- view/post_specific.php +453 -57
- view/review.php +20 -3
- view/schema_type.php +138 -61
admin_section/add-schema/add_new.php
CHANGED
@@ -1,4 +1,9 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
add_action( 'admin_menu', 'saswp_add_new_data_menu' );
|
3 |
add_action( 'admin_init', 'saswp_add_new_init');
|
4 |
add_action( 'admin_footer', 'saswp_add_new_svg_sprite');
|
1 |
<?php
|
2 |
+
//compatible with the Blackbar plugin starts here
|
3 |
+
if( in_array( filter_input( INPUT_GET, 'page' ), array( 'saswp-setup-wizard', 'saswp_add_new_data_type' ))) {
|
4 |
+
add_filter( 'blackbar/enabled', '__return_false' );
|
5 |
+
}
|
6 |
+
//compatible with the Blackbar plugin ends here
|
7 |
add_action( 'admin_menu', 'saswp_add_new_data_menu' );
|
8 |
add_action( 'admin_init', 'saswp_add_new_init');
|
9 |
add_action( 'admin_footer', 'saswp_add_new_svg_sprite');
|
admin_section/css/main-style.css
CHANGED
@@ -452,6 +452,13 @@ Compatibility tab css starts here
|
|
452 |
width: 75%;
|
453 |
padding-bottom: 10px;
|
454 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
/*
|
456 |
Compatibility tab css ends
|
457 |
*/
|
452 |
width: 75%;
|
453 |
padding-bottom: 10px;
|
454 |
}
|
455 |
+
.saswp-schem-type-note{
|
456 |
+
color: chocolate;
|
457 |
+
}
|
458 |
+
.saswp-custom-fields-name{
|
459 |
+
border: 1px solid #aaa;
|
460 |
+
border-radius: 4px;
|
461 |
+
}
|
462 |
/*
|
463 |
Compatibility tab css ends
|
464 |
*/
|
admin_section/css/saswp-add-new.css
CHANGED
@@ -2430,4 +2430,10 @@ body .amp_install_center {text-align: center}
|
|
2430 |
}
|
2431 |
#saswp_amp_select{
|
2432 |
border: 0px;
|
|
|
|
|
|
|
|
|
|
|
|
|
2433 |
}
|
2430 |
}
|
2431 |
#saswp_amp_select{
|
2432 |
border: 0px;
|
2433 |
+
}
|
2434 |
+
.saswp_hide{
|
2435 |
+
display: none;
|
2436 |
+
}
|
2437 |
+
.saswp-schem-type-note{
|
2438 |
+
color: chocolate;
|
2439 |
}
|
admin_section/js/main-script.js
CHANGED
@@ -25,6 +25,7 @@ jQuery(document).ready(function($){
|
|
25 |
});
|
26 |
|
27 |
$(".saswp-schame-type-select").change(function(){
|
|
|
28 |
var schematype = $ (this).val();
|
29 |
|
30 |
$(".saswp-option-table-class tr").each(function(index,value){
|
@@ -43,6 +44,13 @@ jQuery(document).ready(function($){
|
|
43 |
if(schematype == 'Service'){
|
44 |
$(".saswp-service-text-field-tr").show();
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
});
|
47 |
|
48 |
$("#saswp_business_type").change(function(){
|
@@ -64,6 +72,9 @@ jQuery(document).ready(function($){
|
|
64 |
if(schematype == 'Service'){
|
65 |
$(".saswp-service-text-field-tr").show();
|
66 |
}
|
|
|
|
|
|
|
67 |
|
68 |
}).change();
|
69 |
|
@@ -251,6 +262,32 @@ jQuery(document).ready(function($){
|
|
251 |
$("#saswp-kk-star-raring").val(0);
|
252 |
}
|
253 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
default:
|
256 |
break;
|
@@ -396,13 +433,14 @@ jQuery(document).ready(function($){
|
|
396 |
}
|
397 |
$('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
|
398 |
$(".saswp-modify_schema_post_enable").on("click", function(e){
|
399 |
-
$(this)
|
400 |
e.preventDefault();
|
401 |
$.get(ajaxurl,
|
402 |
{ action:"saswp_modify_schema_post_enable", post_id: saswp_localize_data.post_id,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
|
403 |
-
function(response){
|
|
|
404 |
$("#post_specific .inside").append(response);
|
405 |
-
saswpAddTimepicker();
|
406 |
});
|
407 |
});
|
408 |
|
@@ -466,7 +504,7 @@ jQuery(document).ready(function($){
|
|
466 |
}
|
467 |
}).change();
|
468 |
|
469 |
-
$(".saswp-restore-post-schema"
|
470 |
e.preventDefault();
|
471 |
var schema_ids = JSON.parse($(".saswp-post-specific-schema-ids").val());
|
472 |
$.post(ajaxurl,
|
@@ -476,6 +514,7 @@ jQuery(document).ready(function($){
|
|
476 |
setTimeout(function(){ location.reload(); }, 1000);
|
477 |
}else{
|
478 |
alert(response['msg']);
|
|
|
479 |
}
|
480 |
},'json');
|
481 |
});
|
@@ -492,5 +531,97 @@ jQuery(document).ready(function($){
|
|
492 |
});
|
493 |
|
494 |
//Importer from schema plugin ends here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
|
496 |
});
|
25 |
});
|
26 |
|
27 |
$(".saswp-schame-type-select").change(function(){
|
28 |
+
$(".saswp-custom-fields-table").html('');
|
29 |
var schematype = $ (this).val();
|
30 |
|
31 |
$(".saswp-option-table-class tr").each(function(index,value){
|
44 |
if(schematype == 'Service'){
|
45 |
$(".saswp-service-text-field-tr").show();
|
46 |
}
|
47 |
+
if(schematype == 'Review'){
|
48 |
+
$(".saswp-review-text-field-tr").show();
|
49 |
+
}
|
50 |
+
$(".saswp-schem-type-note").addClass('saswp_hide');
|
51 |
+
if(schematype == 'qanda'){
|
52 |
+
$(".saswp-schem-type-note").removeClass('saswp_hide');
|
53 |
+
}
|
54 |
});
|
55 |
|
56 |
$("#saswp_business_type").change(function(){
|
72 |
if(schematype == 'Service'){
|
73 |
$(".saswp-service-text-field-tr").show();
|
74 |
}
|
75 |
+
if(schematype == 'Review'){
|
76 |
+
$(".saswp-review-text-field-tr").show();
|
77 |
+
}
|
78 |
|
79 |
}).change();
|
80 |
|
262 |
$("#saswp-kk-star-raring").val(0);
|
263 |
}
|
264 |
break;
|
265 |
+
case 'saswp-woocommerce-checkbox':
|
266 |
+
|
267 |
+
if ($(this).is(':checked')) {
|
268 |
+
$("#saswp-woocommerce").val(1);
|
269 |
+
}else{
|
270 |
+
$("#saswp-woocommerce").val(0);
|
271 |
+
}
|
272 |
+
break;
|
273 |
+
|
274 |
+
case 'saswp-extra-checkbox':
|
275 |
+
|
276 |
+
if ($(this).is(':checked')) {
|
277 |
+
$("#saswp-extra").val(1);
|
278 |
+
}else{
|
279 |
+
$("#saswp-extra").val(0);
|
280 |
+
}
|
281 |
+
break;
|
282 |
+
|
283 |
+
case 'saswp-dw-question-answer-checkbox':
|
284 |
+
|
285 |
+
if ($(this).is(':checked')) {
|
286 |
+
$("#saswp-dw-question-answer").val(1);
|
287 |
+
}else{
|
288 |
+
$("#saswp-dw-question-answer").val(0);
|
289 |
+
}
|
290 |
+
break;
|
291 |
|
292 |
default:
|
293 |
break;
|
433 |
}
|
434 |
$('.saswp-local-schema-time-picker').timepicker({ 'timeFormat': 'H:i:s'});
|
435 |
$(".saswp-modify_schema_post_enable").on("click", function(e){
|
436 |
+
var current = $(this);
|
437 |
e.preventDefault();
|
438 |
$.get(ajaxurl,
|
439 |
{ action:"saswp_modify_schema_post_enable", post_id: saswp_localize_data.post_id,saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
|
440 |
+
function(response){
|
441 |
+
current.remove();
|
442 |
$("#post_specific .inside").append(response);
|
443 |
+
saswpAddTimepicker();
|
444 |
});
|
445 |
});
|
446 |
|
504 |
}
|
505 |
}).change();
|
506 |
|
507 |
+
$(document).on("click", ".saswp-restore-post-schema", function(e){
|
508 |
e.preventDefault();
|
509 |
var schema_ids = JSON.parse($(".saswp-post-specific-schema-ids").val());
|
510 |
$.post(ajaxurl,
|
514 |
setTimeout(function(){ location.reload(); }, 1000);
|
515 |
}else{
|
516 |
alert(response['msg']);
|
517 |
+
setTimeout(function(){ location.reload(); }, 1000);
|
518 |
}
|
519 |
},'json');
|
520 |
});
|
531 |
});
|
532 |
|
533 |
//Importer from schema plugin ends here
|
534 |
+
|
535 |
+
//custom fields modify schema starts here
|
536 |
+
|
537 |
+
|
538 |
+
$("#saswp_enable_custom_field").change(function(){
|
539 |
+
if ($(this).is(':checked')) {
|
540 |
+
$(".saswp-custom-fields-div").show();
|
541 |
+
}else{
|
542 |
+
$(".saswp-custom-fields-div").hide();
|
543 |
+
}
|
544 |
+
});
|
545 |
+
$(document).on('change','.saswp-custom-fields-name',function(){
|
546 |
+
|
547 |
+
$(this).parent().parent('tr').find("td:eq(1)").html('');
|
548 |
+
var field_name = $(this).val();
|
549 |
+
var html = '';
|
550 |
+
html += '<select class="saswp-custom-fields-select2" name="saswp_custom_fields['+field_name+']">';
|
551 |
+
html += '</select>';
|
552 |
+
$(this).parent().parent('tr').find("td:eq(1)").html(html);
|
553 |
+
saswpCustomSelect2();
|
554 |
+
} );
|
555 |
+
|
556 |
+
$(document).on("click", '.saswp-add-custom-fields', function(){
|
557 |
+
var schema_type = $('select#schema_type option:selected').val();
|
558 |
+
var post_id = $('#post_ID').val();
|
559 |
+
if(schema_type !=''){
|
560 |
+
$.ajax({
|
561 |
+
type: "POST",
|
562 |
+
url:ajaxurl,
|
563 |
+
dataType: "json",
|
564 |
+
data:{action:"saswp_get_schema_type_fields",post_id:post_id, schema_type:schema_type, saswp_security_nonce:saswp_localize_data.saswp_security_nonce},
|
565 |
+
success:function(response){
|
566 |
+
|
567 |
+
if(response.length !=0){
|
568 |
+
var i =0;
|
569 |
+
var name ='';
|
570 |
+
var html = '<tr>';
|
571 |
+
html += '<td>';
|
572 |
+
|
573 |
+
html += '<select class="saswp-custom-fields-name">';
|
574 |
+
$.each(response, function(key,value){
|
575 |
+
if(i==0){
|
576 |
+
name = key;
|
577 |
+
}
|
578 |
+
html += '<option value="'+key+'">'+value+'</option>';
|
579 |
+
i++;
|
580 |
+
});
|
581 |
+
html += '</select>';
|
582 |
+
|
583 |
+
html += '</td>';
|
584 |
+
html += '<td>';
|
585 |
+
html += '<select class="saswp-custom-fields-select2" name="saswp_custom_fields['+name+']">';
|
586 |
+
html += '</select>';
|
587 |
+
html += '</td>';
|
588 |
+
html += '</tr>';
|
589 |
+
$(".saswp-custom-fields-table").append(html);
|
590 |
+
saswpCustomSelect2();
|
591 |
+
}
|
592 |
+
},
|
593 |
+
error: function(response){
|
594 |
+
console.log(response);
|
595 |
+
}
|
596 |
+
});
|
597 |
+
}
|
598 |
+
});
|
599 |
+
saswpCustomSelect2();
|
600 |
+
function saswpCustomSelect2(){
|
601 |
+
$('.saswp-custom-fields-select2').select2({
|
602 |
+
ajax: {
|
603 |
+
type: "POST",
|
604 |
+
url: ajaxurl, // AJAX URL is predefined in WordPress admin
|
605 |
+
dataType: 'json',
|
606 |
+
delay: 250, // delay in ms while typing when to perform a AJAX search
|
607 |
+
data: function (params) {
|
608 |
+
return {
|
609 |
+
saswp_security_nonce: saswp_localize_data.saswp_security_nonce,
|
610 |
+
q: params.term, // search query
|
611 |
+
action: 'saswp_get_custom_meta_fields' // AJAX action for admin-ajax.php
|
612 |
+
};
|
613 |
+
},
|
614 |
+
processResults: function( data ) {
|
615 |
+
return {
|
616 |
+
results: data
|
617 |
+
};
|
618 |
+
},
|
619 |
+
cache: true
|
620 |
+
},
|
621 |
+
minimumInputLength: 2 // the minimum of symbols to input before perform a search
|
622 |
+
});
|
623 |
+
}
|
624 |
+
|
625 |
+
//custom fields modify schema ends here
|
626 |
|
627 |
});
|
admin_section/js/saswp-add-new.js
CHANGED
@@ -266,6 +266,13 @@ jQuery(document).ready(function($) {
|
|
266 |
if(schematype == 'Service'){
|
267 |
$(".saswp-service-text-field-tr").show();
|
268 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
}).change();
|
271 |
|
@@ -288,7 +295,9 @@ jQuery(document).ready(function($) {
|
|
288 |
if(schematype == 'Service'){
|
289 |
$(".saswp-service-text-field-tr").show();
|
290 |
}
|
291 |
-
|
|
|
|
|
292 |
}).change();
|
293 |
|
294 |
$("input[data-id=media]").click(function(e) { // Application Icon upload
|
266 |
if(schematype == 'Service'){
|
267 |
$(".saswp-service-text-field-tr").show();
|
268 |
}
|
269 |
+
if(schematype == 'Review'){
|
270 |
+
$(".saswp-review-text-field-tr").show();
|
271 |
+
}
|
272 |
+
$(".saswp-schem-type-note").addClass('saswp_hide');
|
273 |
+
if(schematype == 'qanda'){
|
274 |
+
$(".saswp-schem-type-note").removeClass('saswp_hide');
|
275 |
+
}
|
276 |
|
277 |
}).change();
|
278 |
|
295 |
if(schematype == 'Service'){
|
296 |
$(".saswp-service-text-field-tr").show();
|
297 |
}
|
298 |
+
if(schematype == 'Review'){
|
299 |
+
$(".saswp-review-text-field-tr").show();
|
300 |
+
}
|
301 |
}).change();
|
302 |
|
303 |
$("input[data-id=media]").click(function(e) { // Application Icon upload
|
admin_section/settings.php
CHANGED
@@ -938,7 +938,9 @@ function saswp_review_page_callback(){
|
|
938 |
}
|
939 |
function saswp_compatibility_page_callback(){
|
940 |
|
941 |
-
$settings = saswp_defaultSettings();
|
|
|
|
|
942 |
$field_objs = new saswp_fields_generator();
|
943 |
$meta_fields = array(
|
944 |
array(
|
@@ -956,10 +958,64 @@ function saswp_compatibility_page_callback(){
|
|
956 |
);
|
957 |
if(is_plugin_active('kk-star-ratings/index.php')){
|
958 |
$field_objs->saswp_field_generator($meta_fields, $settings);
|
959 |
-
}
|
960 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
961 |
}
|
962 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
963 |
|
964 |
}
|
965 |
|
938 |
}
|
939 |
function saswp_compatibility_page_callback(){
|
940 |
|
941 |
+
$settings = saswp_defaultSettings();
|
942 |
+
|
943 |
+
//KK Star rating
|
944 |
$field_objs = new saswp_fields_generator();
|
945 |
$meta_fields = array(
|
946 |
array(
|
958 |
);
|
959 |
if(is_plugin_active('kk-star-ratings/index.php')){
|
960 |
$field_objs->saswp_field_generator($meta_fields, $settings);
|
961 |
+
}
|
962 |
+
//Woocommerce
|
963 |
+
$meta_fields = array(
|
964 |
+
array(
|
965 |
+
'label' => 'Woocommerce',
|
966 |
+
'id' => 'saswp-woocommerce-checkbox',
|
967 |
+
'name' => 'saswp-woocommerce-checkbox',
|
968 |
+
'type' => 'checkbox',
|
969 |
+
'class' => 'checkbox saswp-checkbox',
|
970 |
+
'hidden' => array(
|
971 |
+
'id' => 'saswp-woocommerce',
|
972 |
+
'name' => 'sd_data[saswp-woocommerce]',
|
973 |
+
)
|
974 |
+
),
|
975 |
+
|
976 |
+
);
|
977 |
+
if(is_plugin_active('woocommerce/woocommerce.php')){
|
978 |
+
$field_objs->saswp_field_generator($meta_fields, $settings);
|
979 |
+
}
|
980 |
+
//Extra theme by elegant themes
|
981 |
+
$meta_fields = array(
|
982 |
+
array(
|
983 |
+
'label' => 'Extra Theme By Elegant',
|
984 |
+
'id' => 'saswp-extra-checkbox',
|
985 |
+
'name' => 'saswp-extra-checkbox',
|
986 |
+
'type' => 'checkbox',
|
987 |
+
'class' => 'checkbox saswp-checkbox',
|
988 |
+
'hidden' => array(
|
989 |
+
'id' => 'saswp-extra',
|
990 |
+
'name' => 'sd_data[saswp-extra]',
|
991 |
+
)
|
992 |
+
),
|
993 |
+
|
994 |
+
);
|
995 |
+
|
996 |
+
if(get_template() == 'Extra'){
|
997 |
+
$field_objs->saswp_field_generator($meta_fields, $settings);
|
998 |
}
|
999 |
|
1000 |
+
//DW Question Answer
|
1001 |
+
$meta_fields = array(
|
1002 |
+
array(
|
1003 |
+
'label' => 'DW Question Answer',
|
1004 |
+
'id' => 'saswp-dw-question-answer-checkbox',
|
1005 |
+
'name' => 'saswp-dw-question-answer-checkbox',
|
1006 |
+
'type' => 'checkbox',
|
1007 |
+
'class' => 'checkbox saswp-checkbox',
|
1008 |
+
'hidden' => array(
|
1009 |
+
'id' => 'saswp-dw-question-answer',
|
1010 |
+
'name' => 'sd_data[saswp-dw-question-answer]',
|
1011 |
+
)
|
1012 |
+
),
|
1013 |
+
|
1014 |
+
);
|
1015 |
+
|
1016 |
+
if(is_plugin_active('dw-question-answer/dw-question-answer.php')){
|
1017 |
+
$field_objs->saswp_field_generator($meta_fields, $settings);
|
1018 |
+
}
|
1019 |
|
1020 |
}
|
1021 |
|
admin_section/structure_admin.php
CHANGED
@@ -524,6 +524,14 @@ function saswp_change_add_new_url() {
|
|
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 |
}
|
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 |
+
//Enque select 2 script starts here
|
528 |
+
|
529 |
+
wp_enqueue_style('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css' );
|
530 |
+
wp_enqueue_script('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js', array('jquery') );
|
531 |
+
|
532 |
+
//Enque select 2 script ends here
|
533 |
+
|
534 |
+
|
535 |
|
536 |
}
|
537 |
}
|
output/function.php
CHANGED
@@ -19,19 +19,20 @@ function saswp_data_generator() {
|
|
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 |
}
|
33 |
|
34 |
-
$kb_schema_output
|
35 |
|
36 |
if( ( 1 == $sd_data['saswp-for-wordpress'] && saswp_non_amp() ) || ( 1 == $sd_data['saswp-for-amp'] && !saswp_non_amp() ) ) {
|
37 |
|
@@ -54,8 +55,7 @@ function saswp_data_generator() {
|
|
54 |
$output .= $author_output;
|
55 |
$output .= ",";
|
56 |
$output .= "\n\n";
|
57 |
-
}
|
58 |
-
|
59 |
if(!empty($archive_output)){
|
60 |
|
61 |
$output .= $archive_output;
|
19 |
$archive_output = saswp_archive_output();
|
20 |
$kb_website_output = saswp_kb_website_output();
|
21 |
$schema_breadcrumb_output = saswp_schema_breadcrumb_output($sd_data);
|
22 |
+
|
23 |
+
|
24 |
$post_specific_enable = $option = get_option('modify_schema_post_enable_'.$post->ID);
|
25 |
|
26 |
if($post_specific_enable =='enable'){
|
27 |
$schema_output = saswp_post_specific_schema_output();
|
28 |
}else{
|
29 |
+
$schema_output = saswp_schema_output();
|
30 |
}
|
31 |
if($schema_output || $schema_breadcrumb_output || $kb_website_output || $archive_output || $author_output || $about_page_output || $contact_page_output){
|
32 |
add_filter( 'amp_post_template_metadata', 'saswp_remove_amp_default_structure_data');
|
33 |
}
|
34 |
|
35 |
+
$kb_schema_output = saswp_kb_schema_output();
|
36 |
|
37 |
if( ( 1 == $sd_data['saswp-for-wordpress'] && saswp_non_amp() ) || ( 1 == $sd_data['saswp-for-amp'] && !saswp_non_amp() ) ) {
|
38 |
|
55 |
$output .= $author_output;
|
56 |
$output .= ",";
|
57 |
$output .= "\n\n";
|
58 |
+
}
|
|
|
59 |
if(!empty($archive_output)){
|
60 |
|
61 |
$output .= $archive_output;
|
output/output.php
CHANGED
@@ -170,22 +170,38 @@ function saswp_schema_output() {
|
|
170 |
}
|
171 |
$all_schema_output = array();
|
172 |
foreach($Conditionals as $schemaConditionals){
|
173 |
-
|
|
|
|
|
|
|
|
|
174 |
$schema_options = $schemaConditionals['schema_options'];
|
175 |
$schema_type = $schemaConditionals['schema_type'];
|
176 |
$schema_post_id = $schemaConditionals['post_id'];
|
177 |
-
$logo = $sd_data['sd_logo']['url'];
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
if(is_singular()){
|
190 |
// Generate author id
|
191 |
$author_id = get_the_author_meta('ID');
|
@@ -201,7 +217,7 @@ function saswp_schema_output() {
|
|
201 |
$saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
|
202 |
$aggregateRating = array();
|
203 |
$kkstar_aggregateRating = array();
|
204 |
-
|
205 |
if(isset($saswp_review_details['saswp-review-item-over-all'])){
|
206 |
$saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
|
207 |
}
|
@@ -229,17 +245,13 @@ function saswp_schema_output() {
|
|
229 |
"ratingValue" => $kkstar_rating_data['avg']
|
230 |
);
|
231 |
}
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
if(is_front_page()){
|
240 |
-
$schema_type = $schema_type; // $sd_data['sd_page_type'];
|
241 |
-
}
|
242 |
-
$input1 = array(
|
243 |
'@context' => 'http://schema.org',
|
244 |
'@type' => $schema_type ,
|
245 |
|
@@ -261,20 +273,28 @@ function saswp_schema_output() {
|
|
261 |
'width' => $width,
|
262 |
'height' => $height,
|
263 |
),
|
264 |
-
'name' => $
|
265 |
),
|
266 |
-
|
|
|
|
|
|
|
|
|
267 |
if(!empty($aggregateRating)){
|
268 |
$input1['aggregateRating'] = $aggregateRating;
|
269 |
}
|
270 |
if(!empty($kkstar_aggregateRating)){
|
271 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
272 |
}
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
|
|
|
|
|
|
|
|
278 |
if( 'WebPage' === $schema_type){
|
279 |
|
280 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
@@ -306,13 +326,17 @@ function saswp_schema_output() {
|
|
306 |
'width' => $width,
|
307 |
'height' => $height,
|
308 |
),
|
309 |
-
'name' => $
|
310 |
),
|
311 |
|
312 |
),
|
313 |
|
314 |
|
315 |
);
|
|
|
|
|
|
|
|
|
316 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
317 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
318 |
}
|
@@ -322,9 +346,10 @@ function saswp_schema_output() {
|
|
322 |
if(!empty($kkstar_aggregateRating)){
|
323 |
$input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
|
324 |
}
|
325 |
-
|
326 |
-
|
327 |
-
|
|
|
328 |
|
329 |
if( 'Article' === $schema_type ){
|
330 |
|
@@ -345,20 +370,26 @@ function saswp_schema_output() {
|
|
345 |
'@type' => 'Organization',
|
346 |
'logo' => array(
|
347 |
'@type' => 'ImageObject',
|
348 |
-
'url' => $
|
349 |
-
'width' => $
|
350 |
-
'height' => $
|
351 |
),
|
352 |
-
'name' => $
|
353 |
),
|
354 |
|
355 |
);
|
|
|
|
|
|
|
|
|
356 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
357 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
358 |
}
|
|
|
|
|
|
|
359 |
}
|
360 |
-
|
361 |
-
// Recipe
|
362 |
if( 'Recipe' === $schema_type){
|
363 |
|
364 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
@@ -389,17 +420,21 @@ function saswp_schema_output() {
|
|
389 |
'@type' => 'Organization',
|
390 |
'logo' => array(
|
391 |
'@type' => 'ImageObject',
|
392 |
-
'url' => $
|
393 |
-
'width' => $
|
394 |
-
'height' => $
|
395 |
),
|
396 |
-
'name' => $
|
397 |
),
|
398 |
|
399 |
|
400 |
),
|
401 |
|
402 |
);
|
|
|
|
|
|
|
|
|
403 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
404 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
405 |
}
|
@@ -409,15 +444,23 @@ function saswp_schema_output() {
|
|
409 |
if(!empty($kkstar_aggregateRating)){
|
410 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
411 |
}
|
|
|
|
|
|
|
412 |
}
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
|
418 |
-
|
419 |
-
|
420 |
-
|
|
|
|
|
|
|
|
|
|
|
421 |
$input1 = array(
|
422 |
'@context' => 'http://schema.org',
|
423 |
'@type' => $schema_type ,
|
@@ -431,6 +474,76 @@ function saswp_schema_output() {
|
|
431 |
if(!empty($kkstar_aggregateRating)){
|
432 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
433 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
}
|
435 |
|
436 |
if( 'NewsArticle' === $schema_type ){
|
@@ -450,7 +563,7 @@ function saswp_schema_output() {
|
|
450 |
'dateModified' => $modified_date,
|
451 |
'description' => get_the_excerpt(),
|
452 |
'articleSection' => $article_section,
|
453 |
-
'articleBody' =>
|
454 |
'name' => get_the_title(),
|
455 |
'thumbnailUrl' => $image_details[0],
|
456 |
'wordCount' => $word_count['word_count'],
|
@@ -473,14 +586,17 @@ function saswp_schema_output() {
|
|
473 |
'@type' => 'Organization',
|
474 |
'logo' => array(
|
475 |
'@type' => 'ImageObject',
|
476 |
-
'url' => $
|
477 |
-
'width' => $
|
478 |
-
'height' => $
|
479 |
),
|
480 |
-
'name' => $
|
481 |
),
|
482 |
);
|
483 |
-
|
|
|
|
|
|
|
484 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
485 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
486 |
}
|
@@ -491,9 +607,11 @@ function saswp_schema_output() {
|
|
491 |
if(!empty($kkstar_aggregateRating)){
|
492 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
493 |
}
|
|
|
|
|
|
|
494 |
}
|
495 |
-
|
496 |
-
|
497 |
if( 'Service' === $schema_type ){
|
498 |
|
499 |
$schema_data = saswp_get_schema_data($schema_post_id, 'saswp_service_schema_details');
|
@@ -544,16 +662,85 @@ function saswp_schema_output() {
|
|
544 |
'name' => $schema_data['saswp_service_schema_name'],
|
545 |
'itemListElement' => $serviceOffer
|
546 |
);
|
547 |
-
|
|
|
|
|
|
|
|
|
548 |
if(!empty($aggregateRating)){
|
549 |
$input1['aggregateRating'] = $aggregateRating;
|
550 |
}
|
551 |
if(!empty($kkstar_aggregateRating)){
|
552 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
553 |
}
|
554 |
-
|
555 |
-
|
556 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
557 |
if( 'VideoObject' === $schema_type){
|
558 |
|
559 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
@@ -589,14 +776,18 @@ function saswp_schema_output() {
|
|
589 |
'@type' => 'Organization',
|
590 |
'logo' => array(
|
591 |
'@type' => 'ImageObject',
|
592 |
-
'url' => $
|
593 |
-
'width' => $
|
594 |
-
'height' => $
|
595 |
),
|
596 |
-
'name' => $
|
597 |
),
|
598 |
|
599 |
);
|
|
|
|
|
|
|
|
|
600 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
601 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
602 |
}
|
@@ -606,6 +797,9 @@ function saswp_schema_output() {
|
|
606 |
if(!empty($kkstar_aggregateRating)){
|
607 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
608 |
}
|
|
|
|
|
|
|
609 |
|
610 |
}
|
611 |
|
@@ -614,6 +808,8 @@ function saswp_schema_output() {
|
|
614 |
$business_type = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_type', true) );
|
615 |
$business_name = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_name', true) );
|
616 |
$business_details = esc_sql ( get_post_meta($schema_post_id, 'saswp_local_business_details', true) );
|
|
|
|
|
617 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
618 |
$image_details[0] = $logo;
|
619 |
}
|
@@ -642,20 +838,22 @@ function saswp_schema_output() {
|
|
642 |
"postalCode" => $business_details['local_postal_code'],
|
643 |
),
|
644 |
'telephone' => $business_details['local_phone'],
|
645 |
-
'
|
646 |
-
'@type' => 'OpeningHoursSpecification',
|
647 |
-
'dayOfWeek' => $business_details['saswp_dayofweek'],
|
648 |
-
'opens' => $business_details['local_opens_time'],
|
649 |
-
'closes'=> $business_details['local_closes_time'],
|
650 |
-
),
|
651 |
|
652 |
-
);
|
|
|
|
|
|
|
|
|
653 |
if(!empty($aggregateRating)){
|
654 |
$input1['aggregateRating'] = $aggregateRating;
|
655 |
}
|
656 |
if(!empty($kkstar_aggregateRating)){
|
657 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
658 |
-
}
|
|
|
|
|
|
|
659 |
if(isset($business_details['local_price_range'])){
|
660 |
$input1['priceRange'] = $business_details['local_price_range'];
|
661 |
}
|
@@ -674,34 +872,39 @@ function saswp_schema_output() {
|
|
674 |
}
|
675 |
|
676 |
//Check for Featured Image
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
|
|
|
|
695 |
$input2 = array(
|
696 |
'image' =>array(
|
697 |
'@type' =>'ImageObject',
|
698 |
-
'url' => $
|
699 |
-
|
700 |
-
|
701 |
),
|
702 |
);
|
703 |
$input = array_merge($input1,$input2);
|
704 |
}
|
|
|
|
|
|
|
705 |
if(isset($schema_options['notAccessibleForFree'])==1){
|
706 |
|
707 |
add_filter( 'amp_post_template_data', 'saswp_structure_data_access_scripts');
|
@@ -722,7 +925,10 @@ function saswp_schema_output() {
|
|
722 |
$input = array_merge($input,$paywallData);
|
723 |
}
|
724 |
}
|
725 |
-
|
|
|
|
|
|
|
726 |
}
|
727 |
}
|
728 |
return $all_schema_output;
|
@@ -730,6 +936,7 @@ function saswp_schema_output() {
|
|
730 |
|
731 |
function saswp_post_specific_schema_output() {
|
732 |
global $post;
|
|
|
733 |
$all_schemas = get_posts(
|
734 |
array(
|
735 |
'post_type' => 'saswp',
|
@@ -748,7 +955,7 @@ function saswp_post_specific_schema_output() {
|
|
748 |
|
749 |
$saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
|
750 |
$aggregateRating = array();
|
751 |
-
|
752 |
if(isset($saswp_review_details['saswp-review-item-over-all'])){
|
753 |
$saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
|
754 |
}
|
@@ -774,16 +981,59 @@ function saswp_post_specific_schema_output() {
|
|
774 |
"ratingValue" => $kkstar_rating_data['avg']
|
775 |
);
|
776 |
}
|
|
|
|
|
|
|
777 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
778 |
if( 'Blogposting' === $schema_type){
|
779 |
-
|
|
|
780 |
$input1 = array(
|
781 |
'@context' => 'http://schema.org',
|
782 |
'@type' => $schema_type ,
|
783 |
|
784 |
'mainEntityOfPage' => $all_post_meta['saswp_blogposting_main_entity_of_page_'.$schema_id][0],
|
785 |
'headline' => $all_post_meta['saswp_blogposting_headline_'.$schema_id][0],
|
786 |
-
'description' => $all_post_meta['
|
787 |
'name' => $all_post_meta['saswp_blogposting_name_'.$schema_id][0],
|
788 |
'url' => $all_post_meta['saswp_blogposting_url_'.$schema_id][0],
|
789 |
'datePublished' => $all_post_meta['saswp_blogposting_date_published_'.$schema_id][0],
|
@@ -796,8 +1046,8 @@ function saswp_post_specific_schema_output() {
|
|
796 |
'logo' => array(
|
797 |
'@type' => 'ImageObject',
|
798 |
'url' => $all_post_meta['saswp_blogposting_organization_logo_'.$schema_id][0],
|
799 |
-
'width' => $
|
800 |
-
'height' => $
|
801 |
),
|
802 |
'name' => $all_post_meta['saswp_blogposting_organization_name_'.$schema_id][0],
|
803 |
),
|
@@ -808,10 +1058,13 @@ function saswp_post_specific_schema_output() {
|
|
808 |
if(!empty($kkstar_aggregateRating)){
|
809 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
810 |
}
|
|
|
|
|
|
|
811 |
}
|
812 |
|
813 |
if( 'WebPage' === $schema_type){
|
814 |
-
|
815 |
$input1 = array(
|
816 |
'@context' => 'http://schema.org',
|
817 |
'@type' => $schema_type ,
|
@@ -834,8 +1087,8 @@ function saswp_post_specific_schema_output() {
|
|
834 |
'logo' => array(
|
835 |
'@type' => 'ImageObject',
|
836 |
'url' => $all_post_meta['saswp_webpage_organization_logo_'.$schema_id][0],
|
837 |
-
'width' => $
|
838 |
-
'height' => $
|
839 |
),
|
840 |
'name' => $all_post_meta['saswp_webpage_organization_name_'.$schema_id][0],
|
841 |
),
|
@@ -848,10 +1101,15 @@ function saswp_post_specific_schema_output() {
|
|
848 |
}
|
849 |
if(!empty($kkstar_aggregateRating)){
|
850 |
$input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
|
851 |
-
}
|
|
|
|
|
|
|
852 |
}
|
853 |
|
854 |
if( 'Article' === $schema_type ){
|
|
|
|
|
855 |
$input1 = array(
|
856 |
'@context' => 'http://schema.org',
|
857 |
'@type' => 'Article',
|
@@ -870,45 +1128,97 @@ function saswp_post_specific_schema_output() {
|
|
870 |
'logo' => array(
|
871 |
'@type' => 'ImageObject',
|
872 |
'url' => $all_post_meta['saswp_article_organization_logo_'.$schema_id][0],
|
873 |
-
'width' => $
|
874 |
-
'height' => $
|
875 |
),
|
876 |
'name' => $all_post_meta['saswp_article_organization_name_'.$schema_id][0],
|
877 |
),
|
878 |
|
879 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
880 |
}
|
881 |
|
882 |
if( 'Recipe' === $schema_type){
|
883 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
$input1 = array(
|
885 |
'@context' => 'http://schema.org',
|
886 |
'@type' => $schema_type ,
|
887 |
'url' => $all_post_meta['saswp_recipe_url_'.$schema_id][0],
|
888 |
'name' => $all_post_meta['saswp_recipe_name_'.$schema_id][0],
|
889 |
-
|
890 |
-
'dateModified' => $all_post_meta['saswp_recipe_date_modified_'.$schema_id][0],
|
891 |
-
'description' => $all_post_meta['saswp_recipe_description_'.$schema_id][0],
|
892 |
-
'mainEntity' => array(
|
893 |
-
'@type' => 'WebPage',
|
894 |
-
'@id' => $all_post_meta['saswp_recipe_main_entity_'.$schema_id][0],
|
895 |
-
'author' => array(
|
896 |
'@type' => 'Person',
|
897 |
'name' => $all_post_meta['saswp_recipe_author_name_'.$schema_id][0],
|
898 |
'Image' => array(
|
899 |
'@type' => 'ImageObject',
|
900 |
'url' => $all_post_meta['saswp_recipe_author_image_'.$schema_id][0],
|
901 |
-
'height' => $
|
902 |
-
'width' => $
|
903 |
),
|
904 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
905 |
'Publisher' => array(
|
906 |
'@type' => 'Organization',
|
907 |
'logo' => array(
|
908 |
'@type' => 'ImageObject',
|
909 |
'url' => $all_post_meta['saswp_recipe_organization_logo_'.$schema_id][0],
|
910 |
-
'width' => $
|
911 |
-
'height' => $
|
912 |
),
|
913 |
'name' => $all_post_meta['saswp_recipe_organization_name_'.$schema_id][0],
|
914 |
),
|
@@ -921,11 +1231,14 @@ function saswp_post_specific_schema_output() {
|
|
921 |
}
|
922 |
if(!empty($kkstar_aggregateRating)){
|
923 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
924 |
-
}
|
|
|
|
|
|
|
925 |
}
|
926 |
|
927 |
-
if( 'Product' === $schema_type){
|
928 |
-
|
929 |
$input1 = array(
|
930 |
'@context' => 'http://schema.org',
|
931 |
'@type' => $schema_type ,
|
@@ -940,10 +1253,76 @@ function saswp_post_specific_schema_output() {
|
|
940 |
if(!empty($kkstar_aggregateRating)){
|
941 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
942 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
}
|
944 |
|
945 |
if( 'NewsArticle' === $schema_type ){
|
946 |
|
|
|
|
|
|
|
947 |
$input1 = array(
|
948 |
'@context' => 'http://schema.org',
|
949 |
'@type' => $schema_type ,
|
@@ -969,8 +1348,8 @@ function saswp_post_specific_schema_output() {
|
|
969 |
'Image' => array(
|
970 |
'@type' => 'ImageObject',
|
971 |
'url' => $all_post_meta['saswp_newsarticle_author_image_'.$schema_id][0],
|
972 |
-
'height' => $
|
973 |
-
'width' => $
|
974 |
),
|
975 |
),
|
976 |
'Publisher' => array(
|
@@ -978,8 +1357,8 @@ function saswp_post_specific_schema_output() {
|
|
978 |
'logo' => array(
|
979 |
'@type' => 'ImageObject',
|
980 |
'url' => $all_post_meta['saswp_newsarticle_organization_logo_'.$schema_id][0],
|
981 |
-
'width' => $
|
982 |
-
'height' => $
|
983 |
),
|
984 |
'name' => $all_post_meta['saswp_newsarticle_organization_name_'.$schema_id][0],
|
985 |
),
|
@@ -993,7 +1372,10 @@ function saswp_post_specific_schema_output() {
|
|
993 |
}
|
994 |
|
995 |
if( 'VideoObject' === $schema_type){
|
996 |
-
|
|
|
|
|
|
|
997 |
$input1 = array(
|
998 |
'@context' => 'http://schema.org',
|
999 |
'@type' => $schema_type,
|
@@ -1015,8 +1397,8 @@ function saswp_post_specific_schema_output() {
|
|
1015 |
'Image' => array(
|
1016 |
'@type' => 'ImageObject',
|
1017 |
'url' => $all_post_meta['saswp_video_object_author_image_'.$schema_id][0],
|
1018 |
-
'height' => $
|
1019 |
-
'width' => $
|
1020 |
),
|
1021 |
),
|
1022 |
'Publisher' => array(
|
@@ -1024,8 +1406,8 @@ function saswp_post_specific_schema_output() {
|
|
1024 |
'logo' => array(
|
1025 |
'@type' => 'ImageObject',
|
1026 |
'url' => $all_post_meta['saswp_video_object_organization_logo_'.$schema_id][0],
|
1027 |
-
'width' => $
|
1028 |
-
'height' => $
|
1029 |
),
|
1030 |
'name' => $all_post_meta['saswp_video_object_organization_name_'.$schema_id][0],
|
1031 |
),
|
@@ -1035,7 +1417,10 @@ function saswp_post_specific_schema_output() {
|
|
1035 |
}
|
1036 |
if(!empty($kkstar_aggregateRating)){
|
1037 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1038 |
-
}
|
|
|
|
|
|
|
1039 |
|
1040 |
}
|
1041 |
|
@@ -1093,10 +1478,65 @@ function saswp_post_specific_schema_output() {
|
|
1093 |
if(!empty($kkstar_aggregateRating)){
|
1094 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1095 |
}
|
1096 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1097 |
|
1098 |
if( 'local_business' === $schema_type){
|
1099 |
-
|
1100 |
$business_sub_name ='';
|
1101 |
$business_type = $all_post_meta['saswp_business_type_'.$schema_id][0];
|
1102 |
$post_specific_obj = new saswp_post_specific();
|
@@ -1123,12 +1563,7 @@ function saswp_post_specific_schema_output() {
|
|
1123 |
"postalCode" => $all_post_meta['local_postal_code_'.$schema_id][0],
|
1124 |
),
|
1125 |
'telephone' => $all_post_meta['local_phone_'.$schema_id][0],
|
1126 |
-
'
|
1127 |
-
'@type' => 'OpeningHoursSpecification',
|
1128 |
-
'dayOfWeek' => $all_post_meta['saswp_dayofweek_'.$schema_id][0],
|
1129 |
-
'opens' => $all_post_meta['local_opens_time_'.$schema_id][0],
|
1130 |
-
'closes'=> $all_post_meta['local_closes_time_'.$schema_id][0],
|
1131 |
-
),
|
1132 |
);
|
1133 |
|
1134 |
if(!empty($aggregateRating)){
|
@@ -1137,6 +1572,9 @@ function saswp_post_specific_schema_output() {
|
|
1137 |
if(!empty($kkstar_aggregateRating)){
|
1138 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1139 |
}
|
|
|
|
|
|
|
1140 |
if(isset($all_post_meta['local_price_range_'.$schema_id][0])){
|
1141 |
$input1['priceRange'] = $all_post_meta['local_price_range_'.$schema_id][0];
|
1142 |
}
|
@@ -1157,6 +1595,9 @@ function saswp_post_specific_schema_output() {
|
|
1157 |
$image_id = get_post_thumbnail_id();
|
1158 |
$image_details = wp_get_attachment_image_src($image_id, 'full');
|
1159 |
global $sd_data;
|
|
|
|
|
|
|
1160 |
if( is_array($image_details) ){
|
1161 |
if(isset($image_details[1]) ){
|
1162 |
$width = $image_details[1];
|
@@ -1173,8 +1614,7 @@ function saswp_post_specific_schema_output() {
|
|
1173 |
),
|
1174 |
);
|
1175 |
$input = array_merge($input1,$input2);
|
1176 |
-
}
|
1177 |
-
else{
|
1178 |
$input2 = array(
|
1179 |
'image' =>array(
|
1180 |
'@type' =>'ImageObject',
|
@@ -1185,8 +1625,11 @@ function saswp_post_specific_schema_output() {
|
|
1185 |
);
|
1186 |
$input = array_merge($input1,$input2);
|
1187 |
}
|
1188 |
-
|
1189 |
-
|
|
|
|
|
|
|
1190 |
}
|
1191 |
}
|
1192 |
return $all_schema_output;
|
@@ -1310,7 +1753,37 @@ function saswp_kb_website_output(){
|
|
1310 |
}
|
1311 |
// For Archive
|
1312 |
function saswp_archive_output(){
|
1313 |
-
global $query_string, $sd_data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1314 |
|
1315 |
if(isset($sd_data['saswp_archive_schema']) && $sd_data['saswp_archive_schema'] == 1){
|
1316 |
|
@@ -1323,13 +1796,13 @@ function saswp_archive_output(){
|
|
1323 |
$image_details = wp_get_attachment_image_src($image_id, 'full');
|
1324 |
$publisher_info = array(
|
1325 |
"type" => "Organization",
|
1326 |
-
"name" => $
|
1327 |
"logo" => array(
|
1328 |
"@type" => "ImageObject",
|
1329 |
-
"name" => $
|
1330 |
-
"width" => $
|
1331 |
-
"height"=> $
|
1332 |
-
"url"=> $
|
1333 |
)
|
1334 |
);
|
1335 |
$publisher_info['name'] = get_bloginfo('name');
|
@@ -1624,4 +2097,4 @@ function saswp_reading_time_and_word_count() {
|
|
1624 |
$seconds = floor( $word_count / $words_per_second );
|
1625 |
|
1626 |
return array('word_count' => $word_count, 'timerequired' => $seconds);
|
1627 |
-
}
|
170 |
}
|
171 |
$all_schema_output = array();
|
172 |
foreach($Conditionals as $schemaConditionals){
|
173 |
+
|
174 |
+
$logo ='';
|
175 |
+
$height ='';
|
176 |
+
$width ='';
|
177 |
+
$site_name ='';
|
178 |
$schema_options = $schemaConditionals['schema_options'];
|
179 |
$schema_type = $schemaConditionals['schema_type'];
|
180 |
$schema_post_id = $schemaConditionals['post_id'];
|
181 |
+
$logo = $sd_data['sd_logo']['url'];
|
182 |
+
|
183 |
+
if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
|
184 |
+
$site_name = $sd_data['sd_name'];
|
185 |
+
}else{
|
186 |
+
$site_name = get_bloginfo();
|
187 |
+
}
|
188 |
+
|
189 |
+
if('' != $logo && !empty($logo)){
|
190 |
+
$height = $sd_data['sd_logo']['height'];
|
191 |
+
$width = $sd_data['sd_logo']['width'];
|
192 |
+
}else{
|
193 |
+
$sizes = array(
|
194 |
+
'width' => 600,
|
195 |
+
'height' => 60,
|
196 |
+
'crop' => false,
|
197 |
+
);
|
198 |
+
$custom_logo_id = get_theme_mod( 'custom_logo' );
|
199 |
+
$custom_logo = wp_get_attachment_image_src( $custom_logo_id, $sizes);
|
200 |
+
$logo = $custom_logo[0];
|
201 |
+
$height =$custom_logo[1];
|
202 |
+
$width =$custom_logo[2];
|
203 |
+
}
|
204 |
+
|
205 |
if(is_singular()){
|
206 |
// Generate author id
|
207 |
$author_id = get_the_author_meta('ID');
|
217 |
$saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
|
218 |
$aggregateRating = array();
|
219 |
$kkstar_aggregateRating = array();
|
220 |
+
$saswp_over_all_rating ='';
|
221 |
if(isset($saswp_review_details['saswp-review-item-over-all'])){
|
222 |
$saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
|
223 |
}
|
245 |
"ratingValue" => $kkstar_rating_data['avg']
|
246 |
);
|
247 |
}
|
248 |
+
$extra_theme_review = array();
|
249 |
+
$service_object = new saswp_output_service();
|
250 |
+
$extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
|
251 |
+
|
252 |
+
if( 'Blogposting' === $schema_type){
|
253 |
+
|
254 |
+
$input1 = array(
|
|
|
|
|
|
|
|
|
255 |
'@context' => 'http://schema.org',
|
256 |
'@type' => $schema_type ,
|
257 |
|
273 |
'width' => $width,
|
274 |
'height' => $height,
|
275 |
),
|
276 |
+
'name' => $site_name,
|
277 |
),
|
278 |
+
);
|
279 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
280 |
+
$service = new saswp_output_service();
|
281 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
282 |
+
}
|
283 |
if(!empty($aggregateRating)){
|
284 |
$input1['aggregateRating'] = $aggregateRating;
|
285 |
}
|
286 |
if(!empty($kkstar_aggregateRating)){
|
287 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
288 |
}
|
289 |
+
if(!empty($extra_theme_review)){
|
290 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
291 |
+
}
|
292 |
+
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
293 |
+
$input1['comment'] = saswp_get_comments(get_the_ID());
|
294 |
+
}
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
if( 'WebPage' === $schema_type){
|
299 |
|
300 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
326 |
'width' => $width,
|
327 |
'height' => $height,
|
328 |
),
|
329 |
+
'name' => $site_name,
|
330 |
),
|
331 |
|
332 |
),
|
333 |
|
334 |
|
335 |
);
|
336 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
337 |
+
$service = new saswp_output_service();
|
338 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
339 |
+
}
|
340 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
341 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
342 |
}
|
346 |
if(!empty($kkstar_aggregateRating)){
|
347 |
$input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
|
348 |
}
|
349 |
+
if(!empty($extra_theme_review)){
|
350 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
351 |
+
}
|
352 |
+
}
|
353 |
|
354 |
if( 'Article' === $schema_type ){
|
355 |
|
370 |
'@type' => 'Organization',
|
371 |
'logo' => array(
|
372 |
'@type' => 'ImageObject',
|
373 |
+
'url' => $logo,
|
374 |
+
'width' => $width,
|
375 |
+
'height' => $height,
|
376 |
),
|
377 |
+
'name' => $site_name,
|
378 |
),
|
379 |
|
380 |
);
|
381 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
382 |
+
$service = new saswp_output_service();
|
383 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
384 |
+
}
|
385 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
386 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
387 |
}
|
388 |
+
if(!empty($extra_theme_review)){
|
389 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
390 |
+
}
|
391 |
}
|
392 |
+
|
|
|
393 |
if( 'Recipe' === $schema_type){
|
394 |
|
395 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
420 |
'@type' => 'Organization',
|
421 |
'logo' => array(
|
422 |
'@type' => 'ImageObject',
|
423 |
+
'url' => $logo,
|
424 |
+
'width' => $width,
|
425 |
+
'height' => $height,
|
426 |
),
|
427 |
+
'name' => $site_name,
|
428 |
),
|
429 |
|
430 |
|
431 |
),
|
432 |
|
433 |
);
|
434 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
435 |
+
$service = new saswp_output_service();
|
436 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
437 |
+
}
|
438 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
439 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
440 |
}
|
444 |
if(!empty($kkstar_aggregateRating)){
|
445 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
446 |
}
|
447 |
+
if(!empty($extra_theme_review)){
|
448 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
449 |
+
}
|
450 |
}
|
451 |
+
|
452 |
+
if( 'qanda' === $schema_type){
|
453 |
+
$service_object = new saswp_output_service();
|
454 |
+
$input1 = $service_object->saswp_dw_question_answers_details(get_the_ID());
|
455 |
|
456 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
457 |
+
$service = new saswp_output_service();
|
458 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
462 |
+
if( 'Product' === $schema_type){
|
463 |
+
|
464 |
$input1 = array(
|
465 |
'@context' => 'http://schema.org',
|
466 |
'@type' => $schema_type ,
|
474 |
if(!empty($kkstar_aggregateRating)){
|
475 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
476 |
}
|
477 |
+
if(!empty($extra_theme_review)){
|
478 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
479 |
+
}
|
480 |
+
|
481 |
+
$service = new saswp_output_service();
|
482 |
+
$product_details = $service->saswp_woocommerce_product_details(get_the_ID());
|
483 |
+
|
484 |
+
if((isset($sd_data['saswp-woocommerce']) && $sd_data['saswp-woocommerce'] ==1) && !empty($product_details)){
|
485 |
+
|
486 |
+
$input1 = array(
|
487 |
+
'@context' => 'http://schema.org',
|
488 |
+
'@type' => 'Product',
|
489 |
+
'url' => get_permalink(),
|
490 |
+
'name' => $product_details['product_name'],
|
491 |
+
'sku' => $product_details['product_sku'],
|
492 |
+
'description' => $product_details['product_description'],
|
493 |
+
'image' => $product_details['product_image'],
|
494 |
+
'offers' => array(
|
495 |
+
'@type' => 'Offer',
|
496 |
+
'availability' => $product_details['product_availability'],
|
497 |
+
'price' => $product_details['product_price'],
|
498 |
+
'priceCurrency' => $product_details['product_currency'],
|
499 |
+
'url' => get_permalink(),
|
500 |
+
'priceValidUntil'=> $product_details['product_priceValidUntil'],
|
501 |
+
),
|
502 |
+
|
503 |
+
);
|
504 |
+
if(isset($product_details['product_gtin8']) && $product_details['product_gtin8'] !=''){
|
505 |
+
$input1['gtin8'] = $product_details['product_gtin8'];
|
506 |
+
}
|
507 |
+
if(isset($product_details['product_mpn']) && $product_details['product_mpn'] !=''){
|
508 |
+
$input1['mpn'] = $product_details['product_mpn'];
|
509 |
+
}
|
510 |
+
if(isset($product_details['product_isbn']) && $product_details['product_isbn'] !=''){
|
511 |
+
$input1['isbn'] = $product_details['product_isbn'];
|
512 |
+
}
|
513 |
+
if(isset($product_details['product_brand']) && $product_details['product_brand'] !=''){
|
514 |
+
$input1['brand'] = array('@type'=>'Thing','name'=>$product_details['product_brand']);
|
515 |
+
}
|
516 |
+
if(isset($product_details['product_review_count']) && isset($product_details['product_average_rating'])){
|
517 |
+
$input1['aggregateRating'] = array(
|
518 |
+
'@type' => 'AggregateRating',
|
519 |
+
'ratingValue' => $product_details['product_average_rating'],
|
520 |
+
'reviewCount' => (int)$product_details['product_review_count'],
|
521 |
+
);
|
522 |
+
}
|
523 |
+
if(!empty($product_details['product_reviews'])){
|
524 |
+
$reviews = array();
|
525 |
+
foreach ($product_details['product_reviews'] as $review){
|
526 |
+
$reviews[] = array(
|
527 |
+
'@type' => 'Review',
|
528 |
+
'author' => $review['author'],
|
529 |
+
'datePublished' => $review['datePublished'],
|
530 |
+
'description' => $review['description'],
|
531 |
+
'reviewRating' => array(
|
532 |
+
'@type' => 'Rating',
|
533 |
+
'bestRating' => '5',
|
534 |
+
'ratingValue' => $review['reviewRating'],
|
535 |
+
'worstRating' => '1',
|
536 |
+
)
|
537 |
+
);
|
538 |
+
}
|
539 |
+
$input1['review'] = $reviews;
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
544 |
+
$service = new saswp_output_service();
|
545 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
546 |
+
}
|
547 |
}
|
548 |
|
549 |
if( 'NewsArticle' === $schema_type ){
|
563 |
'dateModified' => $modified_date,
|
564 |
'description' => get_the_excerpt(),
|
565 |
'articleSection' => $article_section,
|
566 |
+
'articleBody' => get_the_excerpt(),
|
567 |
'name' => get_the_title(),
|
568 |
'thumbnailUrl' => $image_details[0],
|
569 |
'wordCount' => $word_count['word_count'],
|
586 |
'@type' => 'Organization',
|
587 |
'logo' => array(
|
588 |
'@type' => 'ImageObject',
|
589 |
+
'url' => $logo,
|
590 |
+
'width' => $width,
|
591 |
+
'height' => $height,
|
592 |
),
|
593 |
+
'name' => $site_name,
|
594 |
),
|
595 |
);
|
596 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
597 |
+
$service = new saswp_output_service();
|
598 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
599 |
+
}
|
600 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
601 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
602 |
}
|
607 |
if(!empty($kkstar_aggregateRating)){
|
608 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
609 |
}
|
610 |
+
if(!empty($extra_theme_review)){
|
611 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
612 |
+
}
|
613 |
}
|
614 |
+
|
|
|
615 |
if( 'Service' === $schema_type ){
|
616 |
|
617 |
$schema_data = saswp_get_schema_data($schema_post_id, 'saswp_service_schema_details');
|
662 |
'name' => $schema_data['saswp_service_schema_name'],
|
663 |
'itemListElement' => $serviceOffer
|
664 |
);
|
665 |
+
|
666 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
667 |
+
$service = new saswp_output_service();
|
668 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
669 |
+
}
|
670 |
if(!empty($aggregateRating)){
|
671 |
$input1['aggregateRating'] = $aggregateRating;
|
672 |
}
|
673 |
if(!empty($kkstar_aggregateRating)){
|
674 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
675 |
}
|
676 |
+
if(!empty($extra_theme_review)){
|
677 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
678 |
+
}
|
679 |
+
}
|
680 |
+
|
681 |
+
if( 'Review' === $schema_type ){
|
682 |
+
|
683 |
+
$schema_data = saswp_get_schema_data($schema_post_id, 'saswp_review_schema_details');
|
684 |
+
|
685 |
+
$input1 = array(
|
686 |
+
'@context' => 'http://schema.org',
|
687 |
+
'@type' => $schema_type ,
|
688 |
+
'url' => get_permalink(),
|
689 |
+
'description' => $schema_data['saswp_review_schema_description'],
|
690 |
+
'itemReviewed' => array(
|
691 |
+
'@type' => $schema_data['saswp_review_schema_item_type'],
|
692 |
+
'name' => $schema_data['saswp_review_schema_name'],
|
693 |
+
'image' => $schema_data['saswp_review_schema_image']['url'],
|
694 |
+
'priceRange' => $schema_data['saswp_review_schema_price_range'],
|
695 |
+
'address' => array(
|
696 |
+
'@type' => 'PostalAddress',
|
697 |
+
'streetAddress' => $schema_data['saswp_review_schema_street_address'],
|
698 |
+
'addressLocality' => $schema_data['saswp_review_schema_locality'],
|
699 |
+
'addressRegion' => $schema_data['saswp_review_schema_region'],
|
700 |
+
'postalCode' => $schema_data['saswp_review_schema_postal_code'],
|
701 |
+
'addressCountry' => $schema_data['saswp_review_schema_country'],
|
702 |
+
),
|
703 |
+
'telephone' => $schema_data['saswp_review_schema_telephone'],
|
704 |
+
),
|
705 |
+
'datePublished' => $date,
|
706 |
+
'dateModified' => $modified_date,
|
707 |
+
'author' => array(
|
708 |
+
'@type' => 'Person',
|
709 |
+
'name' => $aurthor_name,
|
710 |
+
'Image' => array(
|
711 |
+
'@type' => 'ImageObject',
|
712 |
+
'url' => $author_details['url'],
|
713 |
+
'height' => $author_details['height'],
|
714 |
+
'width' => $author_details['width']
|
715 |
+
),
|
716 |
+
),
|
717 |
+
'Publisher' => array(
|
718 |
+
'@type' => 'Organization',
|
719 |
+
'logo' => array(
|
720 |
+
'@type' => 'ImageObject',
|
721 |
+
'url' => $logo,
|
722 |
+
'width' => $width,
|
723 |
+
'height' => $height,
|
724 |
+
),
|
725 |
+
'name' => $site_name,
|
726 |
+
),
|
727 |
+
|
728 |
+
|
729 |
+
);
|
730 |
+
|
731 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
732 |
+
$service = new saswp_output_service();
|
733 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
734 |
+
}
|
735 |
+
|
736 |
+
if(!empty($aggregateRating)){
|
737 |
+
$input1['aggregateRating'] = $aggregateRating;
|
738 |
+
}
|
739 |
+
if(!empty($kkstar_aggregateRating)){
|
740 |
+
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
741 |
+
}
|
742 |
+
}
|
743 |
+
|
744 |
if( 'VideoObject' === $schema_type){
|
745 |
|
746 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
776 |
'@type' => 'Organization',
|
777 |
'logo' => array(
|
778 |
'@type' => 'ImageObject',
|
779 |
+
'url' => $logo,
|
780 |
+
'width' => $width,
|
781 |
+
'height' => $height,
|
782 |
),
|
783 |
+
'name' => $site_name,
|
784 |
),
|
785 |
|
786 |
);
|
787 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
788 |
+
$service = new saswp_output_service();
|
789 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
790 |
+
}
|
791 |
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
792 |
$input1['comment'] = saswp_get_comments(get_the_ID());
|
793 |
}
|
797 |
if(!empty($kkstar_aggregateRating)){
|
798 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
799 |
}
|
800 |
+
if(!empty($extra_theme_review)){
|
801 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
802 |
+
}
|
803 |
|
804 |
}
|
805 |
|
808 |
$business_type = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_type', true) );
|
809 |
$business_name = esc_sql ( get_post_meta($schema_post_id, 'saswp_business_name', true) );
|
810 |
$business_details = esc_sql ( get_post_meta($schema_post_id, 'saswp_local_business_details', true) );
|
811 |
+
$dayoftheweek = get_post_meta($schema_post_id, 'saswp_dayofweek', true);
|
812 |
+
$dayoftheweek = explode( "\r\n", $dayoftheweek);
|
813 |
if(empty($image_details[0]) || $image_details[0] === NULL ){
|
814 |
$image_details[0] = $logo;
|
815 |
}
|
838 |
"postalCode" => $business_details['local_postal_code'],
|
839 |
),
|
840 |
'telephone' => $business_details['local_phone'],
|
841 |
+
'openingHours' => $dayoftheweek,
|
|
|
|
|
|
|
|
|
|
|
842 |
|
843 |
+
);
|
844 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
845 |
+
$service = new saswp_output_service();
|
846 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
847 |
+
}
|
848 |
if(!empty($aggregateRating)){
|
849 |
$input1['aggregateRating'] = $aggregateRating;
|
850 |
}
|
851 |
if(!empty($kkstar_aggregateRating)){
|
852 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
853 |
+
}
|
854 |
+
if(!empty($extra_theme_review)){
|
855 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
856 |
+
}
|
857 |
if(isset($business_details['local_price_range'])){
|
858 |
$input1['priceRange'] = $business_details['local_price_range'];
|
859 |
}
|
872 |
}
|
873 |
|
874 |
//Check for Featured Image
|
875 |
+
if( !empty($input1)){
|
876 |
+
|
877 |
+
if( is_array($image_details) ){
|
878 |
+
if(isset($image_details[1]) ){
|
879 |
+
$width = $image_details[1];
|
880 |
+
}
|
881 |
+
if(isset($image_details[2])){
|
882 |
+
$height = $image_details[2];
|
883 |
+
}
|
884 |
+
$input2 = array(
|
885 |
+
'image' =>array(
|
886 |
+
'@type' =>'ImageObject',
|
887 |
+
'url' =>$image_details[0],
|
888 |
+
'width' =>$width,
|
889 |
+
'height' =>$height,
|
890 |
+
),
|
891 |
+
);
|
892 |
+
$input = array_merge($input1,$input2);
|
893 |
+
}
|
894 |
+
else{
|
895 |
$input2 = array(
|
896 |
'image' =>array(
|
897 |
'@type' =>'ImageObject',
|
898 |
+
'url' => $logo,
|
899 |
+
'width' => $width,
|
900 |
+
'height' => $height,
|
901 |
),
|
902 |
);
|
903 |
$input = array_merge($input1,$input2);
|
904 |
}
|
905 |
+
|
906 |
+
}
|
907 |
+
|
908 |
if(isset($schema_options['notAccessibleForFree'])==1){
|
909 |
|
910 |
add_filter( 'amp_post_template_data', 'saswp_structure_data_access_scripts');
|
925 |
$input = array_merge($input,$paywallData);
|
926 |
}
|
927 |
}
|
928 |
+
|
929 |
+
if(!empty($input)){
|
930 |
+
$all_schema_output[] = $input;
|
931 |
+
}
|
932 |
}
|
933 |
}
|
934 |
return $all_schema_output;
|
936 |
|
937 |
function saswp_post_specific_schema_output() {
|
938 |
global $post;
|
939 |
+
global $sd_data;
|
940 |
$all_schemas = get_posts(
|
941 |
array(
|
942 |
'post_type' => 'saswp',
|
955 |
|
956 |
$saswp_review_details = esc_sql ( get_post_meta(get_the_ID(), 'saswp_review_details', true));
|
957 |
$aggregateRating = array();
|
958 |
+
$saswp_over_all_rating ='';
|
959 |
if(isset($saswp_review_details['saswp-review-item-over-all'])){
|
960 |
$saswp_over_all_rating = $saswp_review_details['saswp-review-item-over-all'];
|
961 |
}
|
981 |
"ratingValue" => $kkstar_rating_data['avg']
|
982 |
);
|
983 |
}
|
984 |
+
$extra_theme_review = array();
|
985 |
+
$service_object = new saswp_output_service();
|
986 |
+
$extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
|
987 |
|
988 |
+
|
989 |
+
|
990 |
+
if( 'qanda' === $schema_type){
|
991 |
+
if(trim($all_post_meta['saswp_qa_question_title_'.$schema_id][0]) ==''){
|
992 |
+
$service_object = new saswp_output_service();
|
993 |
+
$input1 = $service_object->saswp_dw_question_answers_details(get_the_ID());
|
994 |
+
}else{
|
995 |
+
$input1 = array(
|
996 |
+
'@context' => 'http://schema.org',
|
997 |
+
'@type' => 'QAPage' ,
|
998 |
+
'mainEntity' => array(
|
999 |
+
'@type' => 'Question' ,
|
1000 |
+
'name' => $all_post_meta['saswp_qa_question_title_'.$schema_id][0],
|
1001 |
+
'text' => $all_post_meta['saswp_qa_question_description_'.$schema_id][0],
|
1002 |
+
'upvoteCount' => $all_post_meta['saswp_qa_upvote_count_'.$schema_id][0] ,
|
1003 |
+
'dateCreated' => $all_post_meta['saswp_qa_date_created_'.$schema_id][0],
|
1004 |
+
'author' => array('@type' => 'Person','name' =>$all_post_meta['saswp_qa_question_author_name_'.$schema_id][0]) ,
|
1005 |
+
'answerCount' => 2 ,
|
1006 |
+
'acceptedAnswer' => array(
|
1007 |
+
'@type' => 'Answer',
|
1008 |
+
'upvoteCount' => $all_post_meta['saswp_qa_accepted_answer_upvote_count_'.$schema_id][0],
|
1009 |
+
'url' => $all_post_meta['saswp_qa_accepted_answer_url_'.$schema_id][0],
|
1010 |
+
'text' => $all_post_meta['saswp_qa_accepted_answer_text_'.$schema_id][0],
|
1011 |
+
'dateCreated' => $all_post_meta['saswp_qa_accepted_answer_date_created_'.$schema_id][0],
|
1012 |
+
'author' => array('@type' => 'Person', 'name' => $all_post_meta['saswp_qa_accepted_author_name_'.$schema_id][0]),
|
1013 |
+
) ,
|
1014 |
+
'suggestedAnswer' => array(
|
1015 |
+
'@type' => 'Answer',
|
1016 |
+
'upvoteCount' => $all_post_meta['saswp_qa_suggested_answer_upvote_count_'.$schema_id][0],
|
1017 |
+
'url' => $all_post_meta['saswp_qa_suggested_answer_url_'.$schema_id][0],
|
1018 |
+
'text' => $all_post_meta['saswp_qa_suggested_answer_text_'.$schema_id][0],
|
1019 |
+
'dateCreated' => $all_post_meta['saswp_qa_suggested_answer_date_created_'.$schema_id][0],
|
1020 |
+
'author' => array('@type' => 'Person', 'name' => $all_post_meta['saswp_qa_suggested_author_name_'.$schema_id][0]),
|
1021 |
+
) ,
|
1022 |
+
)
|
1023 |
+
);
|
1024 |
+
}
|
1025 |
+
}
|
1026 |
+
|
1027 |
if( 'Blogposting' === $schema_type){
|
1028 |
+
|
1029 |
+
$logo = get_post_meta( get_the_ID(), 'saswp_blogposting_organization_logo_'.$schema_id.'_detail',true);
|
1030 |
$input1 = array(
|
1031 |
'@context' => 'http://schema.org',
|
1032 |
'@type' => $schema_type ,
|
1033 |
|
1034 |
'mainEntityOfPage' => $all_post_meta['saswp_blogposting_main_entity_of_page_'.$schema_id][0],
|
1035 |
'headline' => $all_post_meta['saswp_blogposting_headline_'.$schema_id][0],
|
1036 |
+
'description' => $all_post_meta['saswp_blogposting_description_'.$schema_id][0],
|
1037 |
'name' => $all_post_meta['saswp_blogposting_name_'.$schema_id][0],
|
1038 |
'url' => $all_post_meta['saswp_blogposting_url_'.$schema_id][0],
|
1039 |
'datePublished' => $all_post_meta['saswp_blogposting_date_published_'.$schema_id][0],
|
1046 |
'logo' => array(
|
1047 |
'@type' => 'ImageObject',
|
1048 |
'url' => $all_post_meta['saswp_blogposting_organization_logo_'.$schema_id][0],
|
1049 |
+
'width' => $logo['width'],
|
1050 |
+
'height' => $logo['height'],
|
1051 |
),
|
1052 |
'name' => $all_post_meta['saswp_blogposting_organization_name_'.$schema_id][0],
|
1053 |
),
|
1058 |
if(!empty($kkstar_aggregateRating)){
|
1059 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1060 |
}
|
1061 |
+
if(!empty($extra_theme_review)){
|
1062 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1063 |
+
}
|
1064 |
}
|
1065 |
|
1066 |
if( 'WebPage' === $schema_type){
|
1067 |
+
$logo = get_post_meta( get_the_ID(), 'saswp_webpage_organization_logo_'.$schema_id.'_detail',true);
|
1068 |
$input1 = array(
|
1069 |
'@context' => 'http://schema.org',
|
1070 |
'@type' => $schema_type ,
|
1087 |
'logo' => array(
|
1088 |
'@type' => 'ImageObject',
|
1089 |
'url' => $all_post_meta['saswp_webpage_organization_logo_'.$schema_id][0],
|
1090 |
+
'width' => $logo['width'],
|
1091 |
+
'height' => $logo['height'],
|
1092 |
),
|
1093 |
'name' => $all_post_meta['saswp_webpage_organization_name_'.$schema_id][0],
|
1094 |
),
|
1101 |
}
|
1102 |
if(!empty($kkstar_aggregateRating)){
|
1103 |
$input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
|
1104 |
+
}
|
1105 |
+
if(!empty($extra_theme_review)){
|
1106 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1107 |
+
}
|
1108 |
}
|
1109 |
|
1110 |
if( 'Article' === $schema_type ){
|
1111 |
+
|
1112 |
+
$logo = get_post_meta( get_the_ID(), 'saswp_article_organization_logo_'.$schema_id.'_detail',true);
|
1113 |
$input1 = array(
|
1114 |
'@context' => 'http://schema.org',
|
1115 |
'@type' => 'Article',
|
1128 |
'logo' => array(
|
1129 |
'@type' => 'ImageObject',
|
1130 |
'url' => $all_post_meta['saswp_article_organization_logo_'.$schema_id][0],
|
1131 |
+
'width' => $logo['width'],
|
1132 |
+
'height' => $logo['height'],
|
1133 |
),
|
1134 |
'name' => $all_post_meta['saswp_article_organization_name_'.$schema_id][0],
|
1135 |
),
|
1136 |
|
1137 |
);
|
1138 |
+
if(!empty($kkstar_aggregateRating)){
|
1139 |
+
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1140 |
+
}
|
1141 |
+
if(!empty($extra_theme_review)){
|
1142 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1143 |
+
}
|
1144 |
}
|
1145 |
|
1146 |
if( 'Recipe' === $schema_type){
|
1147 |
+
$recipe_logo = get_post_meta( get_the_ID(), 'saswp_article_organization_logo_'.$schema_id.'_detail',true);
|
1148 |
+
$recipe_image = get_post_meta( get_the_ID(), 'saswp_recipe_author_image_'.$schema_id.'_detail',true);
|
1149 |
+
$ingredient = array();
|
1150 |
+
$instruction = array();
|
1151 |
+
|
1152 |
+
if(isset($all_post_meta['saswp_recipe_ingredient_'.$schema_id])){
|
1153 |
+
$explod = explode(';', $all_post_meta['saswp_recipe_ingredient_'.$schema_id][0]);
|
1154 |
+
foreach ($explod as $val){
|
1155 |
+
$ingredient[] = $val;
|
1156 |
+
}
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
if(isset($all_post_meta['saswp_recipe_instructions_'.$schema_id])){
|
1160 |
+
$explod = explode(';', $all_post_meta['saswp_recipe_instructions_'.$schema_id][0]);
|
1161 |
+
foreach ($explod as $val){
|
1162 |
+
$instruction[] = array(
|
1163 |
+
'@type' => "HowToStep",
|
1164 |
+
'text' => $val,
|
1165 |
+
);
|
1166 |
+
}
|
1167 |
+
}
|
1168 |
+
|
1169 |
$input1 = array(
|
1170 |
'@context' => 'http://schema.org',
|
1171 |
'@type' => $schema_type ,
|
1172 |
'url' => $all_post_meta['saswp_recipe_url_'.$schema_id][0],
|
1173 |
'name' => $all_post_meta['saswp_recipe_name_'.$schema_id][0],
|
1174 |
+
'author' => array(
|
|
|
|
|
|
|
|
|
|
|
|
|
1175 |
'@type' => 'Person',
|
1176 |
'name' => $all_post_meta['saswp_recipe_author_name_'.$schema_id][0],
|
1177 |
'Image' => array(
|
1178 |
'@type' => 'ImageObject',
|
1179 |
'url' => $all_post_meta['saswp_recipe_author_image_'.$schema_id][0],
|
1180 |
+
'height' => $recipe_image['height'],
|
1181 |
+
'width' => $recipe_image['width']
|
1182 |
),
|
1183 |
),
|
1184 |
+
|
1185 |
+
|
1186 |
+
'prepTime' => $all_post_meta['saswp_recipe_preptime_'.$schema_id][0],
|
1187 |
+
'cookTime' => $all_post_meta['saswp_recipe_cooktime_'.$schema_id][0],
|
1188 |
+
'totalTime' => $all_post_meta['saswp_recipe_totaltime_'.$schema_id][0],
|
1189 |
+
'keywords' => $all_post_meta['saswp_recipe_keywords_'.$schema_id][0],
|
1190 |
+
'recipeYield' => $all_post_meta['saswp_recipe_recipeyield_'.$schema_id][0],
|
1191 |
+
'recipeCategory' => $all_post_meta['saswp_recipe_category_'.$schema_id][0],
|
1192 |
+
'recipeCuisine' => $all_post_meta['saswp_recipe_cuisine_'.$schema_id][0],
|
1193 |
+
'nutrition' => array(
|
1194 |
+
'@type' => "NutritionInformation",
|
1195 |
+
'calories' => $all_post_meta['saswp_recipe_nutrition_'.$schema_id][0],
|
1196 |
+
),
|
1197 |
+
'recipeIngredient' => $ingredient,
|
1198 |
+
'recipeInstructions' => $instruction,
|
1199 |
+
'video' => array(
|
1200 |
+
'name' => $all_post_meta['saswp_recipe_video_name_'.$schema_id][0],
|
1201 |
+
'description' => $all_post_meta['saswp_recipe_video_description_'.$schema_id][0],
|
1202 |
+
'thumbnailUrl' => $all_post_meta['saswp_recipe_video_thumbnailurl_'.$schema_id][0],
|
1203 |
+
'contentUrl' => $all_post_meta['saswp_recipe_video_contenturl_'.$schema_id][0],
|
1204 |
+
'embedUrl' => $all_post_meta['saswp_recipe_video_embedurl_'.$schema_id][0],
|
1205 |
+
'uploadDate' => $all_post_meta['saswp_recipe_video_upload_date_'.$schema_id][0],
|
1206 |
+
'duration' => $all_post_meta['saswp_recipe_video_duration_'.$schema_id][0],
|
1207 |
+
),
|
1208 |
+
|
1209 |
+
'datePublished' => $all_post_meta['saswp_recipe_date_published_'.$schema_id][0],
|
1210 |
+
'dateModified' => $all_post_meta['saswp_recipe_date_modified_'.$schema_id][0],
|
1211 |
+
'description' => $all_post_meta['saswp_recipe_description_'.$schema_id][0],
|
1212 |
+
'mainEntity' => array(
|
1213 |
+
'@type' => 'WebPage',
|
1214 |
+
'@id' => $all_post_meta['saswp_recipe_main_entity_'.$schema_id][0],
|
1215 |
'Publisher' => array(
|
1216 |
'@type' => 'Organization',
|
1217 |
'logo' => array(
|
1218 |
'@type' => 'ImageObject',
|
1219 |
'url' => $all_post_meta['saswp_recipe_organization_logo_'.$schema_id][0],
|
1220 |
+
'width' => $recipe_logo['width'],
|
1221 |
+
'height' => $recipe_logo['height'],
|
1222 |
),
|
1223 |
'name' => $all_post_meta['saswp_recipe_organization_name_'.$schema_id][0],
|
1224 |
),
|
1231 |
}
|
1232 |
if(!empty($kkstar_aggregateRating)){
|
1233 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1234 |
+
}
|
1235 |
+
if(!empty($extra_theme_review)){
|
1236 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1237 |
+
}
|
1238 |
}
|
1239 |
|
1240 |
+
if( 'Product' === $schema_type){
|
1241 |
+
|
1242 |
$input1 = array(
|
1243 |
'@context' => 'http://schema.org',
|
1244 |
'@type' => $schema_type ,
|
1253 |
if(!empty($kkstar_aggregateRating)){
|
1254 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1255 |
}
|
1256 |
+
if(!empty($extra_theme_review)){
|
1257 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1258 |
+
}
|
1259 |
+
$service = new saswp_output_service();
|
1260 |
+
$product_details = $service->saswp_woocommerce_product_details($post->ID);
|
1261 |
+
|
1262 |
+
if((isset($sd_data['saswp-woocommerce']) && $sd_data['saswp-woocommerce'] ==1) && !empty($product_details)){
|
1263 |
+
$input1 = array(
|
1264 |
+
'@context' => 'http://schema.org',
|
1265 |
+
'@type' => 'Product',
|
1266 |
+
'url' => $all_post_meta['saswp_product_url_'.$schema_id][0],
|
1267 |
+
'name' => $all_post_meta['saswp_product_name_'.$schema_id][0],
|
1268 |
+
'sku' => $all_post_meta['saswp_product_sku_'.$schema_id][0],
|
1269 |
+
'description' => $all_post_meta['saswp_product_description_'.$schema_id][0],
|
1270 |
+
'image' => $all_post_meta['saswp_product_image_'.$schema_id][0],
|
1271 |
+
'offers' => array(
|
1272 |
+
'@type' => 'Offer',
|
1273 |
+
'availability' => $all_post_meta['saswp_product_availability_'.$schema_id][0],
|
1274 |
+
'price' => $all_post_meta['saswp_product_price_'.$schema_id][0],
|
1275 |
+
'priceCurrency' => $all_post_meta['saswp_product_currency_'.$schema_id][0],
|
1276 |
+
'url' => $all_post_meta['saswp_product_url_'.$schema_id][0],
|
1277 |
+
'priceValidUntil'=> $all_post_meta['saswp_product_priceValidUntil_'.$schema_id][0],
|
1278 |
+
),
|
1279 |
+
|
1280 |
+
);
|
1281 |
+
if(isset($all_post_meta['saswp_product_gtin8_'.$schema_id])){
|
1282 |
+
$input1['gtin8'] = $all_post_meta['saswp_product_gtin8_'.$schema_id][0];
|
1283 |
+
}
|
1284 |
+
if(isset($all_post_meta['saswp_product_mpn_'.$schema_id])){
|
1285 |
+
$input1['mpn'] = $all_post_meta['saswp_product_mpn_'.$schema_id][0];
|
1286 |
+
}
|
1287 |
+
if(isset($all_post_meta['saswp_product_isbn_'.$schema_id][0])){
|
1288 |
+
$input1['isbn'] = $all_post_meta['saswp_product_isbn_'.$schema_id][0];
|
1289 |
+
}
|
1290 |
+
if(isset($all_post_meta['saswp_product_brand_'.$schema_id])){
|
1291 |
+
$input1['brand'] = array('@type'=>'Thing','name'=>$all_post_meta['saswp_product_brand_'.$schema_id][0]);
|
1292 |
+
}
|
1293 |
+
if(isset($product_details['product_review_count']) && isset($product_details['product_average_rating'])){
|
1294 |
+
$input1['aggregateRating'] = array(
|
1295 |
+
'@type' => 'AggregateRating',
|
1296 |
+
'ratingValue' => $product_details['product_average_rating'],
|
1297 |
+
'reviewCount' => (int)$product_details['product_review_count'],
|
1298 |
+
);
|
1299 |
+
}
|
1300 |
+
if(!empty($product_details['product_reviews'])){
|
1301 |
+
$reviews = array();
|
1302 |
+
foreach ($product_details['product_reviews'] as $review){
|
1303 |
+
$reviews[] = array(
|
1304 |
+
'@type' => 'Review',
|
1305 |
+
'author' => $review['author'],
|
1306 |
+
'datePublished' => $review['datePublished'],
|
1307 |
+
'description' => $review['description'],
|
1308 |
+
'reviewRating' => array(
|
1309 |
+
'@type' => 'Rating',
|
1310 |
+
'bestRating' => '5',
|
1311 |
+
'ratingValue' => $review['reviewRating'],
|
1312 |
+
'worstRating' => '1',
|
1313 |
+
)
|
1314 |
+
);
|
1315 |
+
}
|
1316 |
+
$input1['review'] = $reviews;
|
1317 |
+
}
|
1318 |
+
}
|
1319 |
}
|
1320 |
|
1321 |
if( 'NewsArticle' === $schema_type ){
|
1322 |
|
1323 |
+
$logo = get_post_meta( get_the_ID(), 'saswp_newsarticle_organization_logo_'.$schema_id.'_detail',true);
|
1324 |
+
$author_image = get_post_meta( get_the_ID(), 'saswp_newsarticle_author_image_'.$schema_id.'_detail',true);
|
1325 |
+
|
1326 |
$input1 = array(
|
1327 |
'@context' => 'http://schema.org',
|
1328 |
'@type' => $schema_type ,
|
1348 |
'Image' => array(
|
1349 |
'@type' => 'ImageObject',
|
1350 |
'url' => $all_post_meta['saswp_newsarticle_author_image_'.$schema_id][0],
|
1351 |
+
'height' => $author_image['height'],
|
1352 |
+
'width' => $author_image['width']
|
1353 |
),
|
1354 |
),
|
1355 |
'Publisher' => array(
|
1357 |
'logo' => array(
|
1358 |
'@type' => 'ImageObject',
|
1359 |
'url' => $all_post_meta['saswp_newsarticle_organization_logo_'.$schema_id][0],
|
1360 |
+
'width' => $logo['width'],
|
1361 |
+
'height' => $logo['height'],
|
1362 |
),
|
1363 |
'name' => $all_post_meta['saswp_newsarticle_organization_name_'.$schema_id][0],
|
1364 |
),
|
1372 |
}
|
1373 |
|
1374 |
if( 'VideoObject' === $schema_type){
|
1375 |
+
|
1376 |
+
$logo = get_post_meta( get_the_ID(), 'saswp_video_object_organization_logo_'.$schema_id.'_detail',true);
|
1377 |
+
$author_image = get_post_meta( get_the_ID(), 'saswp_video_object_author_image_'.$schema_id.'_detail',true);
|
1378 |
+
|
1379 |
$input1 = array(
|
1380 |
'@context' => 'http://schema.org',
|
1381 |
'@type' => $schema_type,
|
1397 |
'Image' => array(
|
1398 |
'@type' => 'ImageObject',
|
1399 |
'url' => $all_post_meta['saswp_video_object_author_image_'.$schema_id][0],
|
1400 |
+
'height' => $author_image['height'],
|
1401 |
+
'width' => $author_image['width']
|
1402 |
),
|
1403 |
),
|
1404 |
'Publisher' => array(
|
1406 |
'logo' => array(
|
1407 |
'@type' => 'ImageObject',
|
1408 |
'url' => $all_post_meta['saswp_video_object_organization_logo_'.$schema_id][0],
|
1409 |
+
'width' => $logo['width'],
|
1410 |
+
'height' => $logo['height'],
|
1411 |
),
|
1412 |
'name' => $all_post_meta['saswp_video_object_organization_name_'.$schema_id][0],
|
1413 |
),
|
1417 |
}
|
1418 |
if(!empty($kkstar_aggregateRating)){
|
1419 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1420 |
+
}
|
1421 |
+
if(!empty($extra_theme_review)){
|
1422 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1423 |
+
}
|
1424 |
|
1425 |
}
|
1426 |
|
1478 |
if(!empty($kkstar_aggregateRating)){
|
1479 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1480 |
}
|
1481 |
+
if(!empty($extra_theme_review)){
|
1482 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1483 |
+
}
|
1484 |
+
}
|
1485 |
+
|
1486 |
+
if( 'Review' === $schema_type ){
|
1487 |
+
|
1488 |
+
$input1 = array(
|
1489 |
+
'@context' => 'http://schema.org',
|
1490 |
+
'@type' => 'Review' ,
|
1491 |
+
'url' => get_permalink(),
|
1492 |
+
'description' => $all_post_meta['saswp_review_schema_description_'.$schema_id][0],
|
1493 |
+
'itemReviewed' => array(
|
1494 |
+
'@type' => $all_post_meta['saswp_review_schema_item_type_'.$schema_id][0],
|
1495 |
+
'name' => $all_post_meta['saswp_review_schema_name_'.$schema_id][0],
|
1496 |
+
'image' => $all_post_meta['saswp_review_schema_image_'.$schema_id][0],
|
1497 |
+
'priceRange' => $all_post_meta['saswp_review_schema_price_range_'.$schema_id][0],
|
1498 |
+
'address' => array(
|
1499 |
+
'@type' => 'PostalAddress',
|
1500 |
+
'streetAddress' => $all_post_meta['saswp_review_schema_street_address_'.$schema_id][0],
|
1501 |
+
'addressLocality' => $all_post_meta['saswp_review_schema_locality_'.$schema_id][0],
|
1502 |
+
'addressRegion' => $all_post_meta['saswp_review_schema_region_'.$schema_id][0],
|
1503 |
+
'postalCode' => $all_post_meta['saswp_review_schema_postal_code_'.$schema_id][0],
|
1504 |
+
'addressCountry' => $all_post_meta['saswp_review_schema_country_'.$schema_id][0],
|
1505 |
+
),
|
1506 |
+
'telephone' => $all_post_meta['saswp_review_schema_telephone_'.$schema_id][0],
|
1507 |
+
),
|
1508 |
+
|
1509 |
+
'datePublished' => $all_post_meta['saswp_review_schema_date_published_'.$schema_id][0],
|
1510 |
+
'dateModified' => $all_post_meta['saswp_review_schema_date_modified_'.$schema_id][0],
|
1511 |
+
'author' => array(
|
1512 |
+
'@type' => 'Person',
|
1513 |
+
'name' => get_the_author(),
|
1514 |
+
),
|
1515 |
+
'Publisher' => array(
|
1516 |
+
'@type' => 'Organization',
|
1517 |
+
'logo' => array(
|
1518 |
+
'@type' => 'ImageObject',
|
1519 |
+
'url' => $sd_data['sd_logo']['url'],
|
1520 |
+
'width' => $sd_data['sd_logo']['width'],
|
1521 |
+
'height' => $sd_data['sd_logo']['height'],
|
1522 |
+
),
|
1523 |
+
'name' => $sd_data['sd_name'],
|
1524 |
+
),
|
1525 |
+
|
1526 |
+
|
1527 |
+
);
|
1528 |
+
|
1529 |
+
|
1530 |
+
if(!empty($aggregateRating)){
|
1531 |
+
$input1['aggregateRating'] = $aggregateRating;
|
1532 |
+
}
|
1533 |
+
if(!empty($kkstar_aggregateRating)){
|
1534 |
+
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1535 |
+
}
|
1536 |
+
}
|
1537 |
|
1538 |
if( 'local_business' === $schema_type){
|
1539 |
+
$operation_days = explode( "rn", esc_html( stripslashes($all_post_meta['saswp_dayofweek_'.$schema_id][0])) );;
|
1540 |
$business_sub_name ='';
|
1541 |
$business_type = $all_post_meta['saswp_business_type_'.$schema_id][0];
|
1542 |
$post_specific_obj = new saswp_post_specific();
|
1563 |
"postalCode" => $all_post_meta['local_postal_code_'.$schema_id][0],
|
1564 |
),
|
1565 |
'telephone' => $all_post_meta['local_phone_'.$schema_id][0],
|
1566 |
+
'openingHours' => $operation_days,
|
|
|
|
|
|
|
|
|
|
|
1567 |
);
|
1568 |
|
1569 |
if(!empty($aggregateRating)){
|
1572 |
if(!empty($kkstar_aggregateRating)){
|
1573 |
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1574 |
}
|
1575 |
+
if(!empty($extra_theme_review)){
|
1576 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1577 |
+
}
|
1578 |
if(isset($all_post_meta['local_price_range_'.$schema_id][0])){
|
1579 |
$input1['priceRange'] = $all_post_meta['local_price_range_'.$schema_id][0];
|
1580 |
}
|
1595 |
$image_id = get_post_thumbnail_id();
|
1596 |
$image_details = wp_get_attachment_image_src($image_id, 'full');
|
1597 |
global $sd_data;
|
1598 |
+
|
1599 |
+
if(!empty($input1)){
|
1600 |
+
|
1601 |
if( is_array($image_details) ){
|
1602 |
if(isset($image_details[1]) ){
|
1603 |
$width = $image_details[1];
|
1614 |
),
|
1615 |
);
|
1616 |
$input = array_merge($input1,$input2);
|
1617 |
+
}else{
|
|
|
1618 |
$input2 = array(
|
1619 |
'image' =>array(
|
1620 |
'@type' =>'ImageObject',
|
1625 |
);
|
1626 |
$input = array_merge($input1,$input2);
|
1627 |
}
|
1628 |
+
|
1629 |
+
}
|
1630 |
+
if(!empty($input)){
|
1631 |
+
$all_schema_output[] = $input;
|
1632 |
+
}
|
1633 |
}
|
1634 |
}
|
1635 |
return $all_schema_output;
|
1753 |
}
|
1754 |
// For Archive
|
1755 |
function saswp_archive_output(){
|
1756 |
+
global $query_string, $sd_data;
|
1757 |
+
$logo ='';
|
1758 |
+
$height ='';
|
1759 |
+
$width ='';
|
1760 |
+
$site_name ='';
|
1761 |
+
|
1762 |
+
$logo = $sd_data['sd_logo']['url'];
|
1763 |
+
|
1764 |
+
if(isset($sd_data['sd_name']) && $sd_data['sd_name'] !=''){
|
1765 |
+
$site_name = $sd_data['sd_name'];
|
1766 |
+
}else{
|
1767 |
+
$site_name = get_bloginfo();
|
1768 |
+
}
|
1769 |
+
|
1770 |
+
|
1771 |
+
if('' != $logo && !empty($logo)){
|
1772 |
+
$height = $sd_data['sd_logo']['height'];
|
1773 |
+
$width = $sd_data['sd_logo']['width'];
|
1774 |
+
}else{
|
1775 |
+
$sizes = array(
|
1776 |
+
'width' => 600,
|
1777 |
+
'height' => 60,
|
1778 |
+
'crop' => false,
|
1779 |
+
);
|
1780 |
+
$custom_logo_id = get_theme_mod( 'custom_logo' );
|
1781 |
+
$custom_logo = wp_get_attachment_image_src( $custom_logo_id, $sizes);
|
1782 |
+
$logo = $custom_logo[0];
|
1783 |
+
$height =$custom_logo[1];
|
1784 |
+
$width =$custom_logo[2];
|
1785 |
+
}
|
1786 |
+
|
1787 |
|
1788 |
if(isset($sd_data['saswp_archive_schema']) && $sd_data['saswp_archive_schema'] == 1){
|
1789 |
|
1796 |
$image_details = wp_get_attachment_image_src($image_id, 'full');
|
1797 |
$publisher_info = array(
|
1798 |
"type" => "Organization",
|
1799 |
+
"name" => $site_name,
|
1800 |
"logo" => array(
|
1801 |
"@type" => "ImageObject",
|
1802 |
+
"name" => $site_name,
|
1803 |
+
"width" => $width,
|
1804 |
+
"height"=> $height,
|
1805 |
+
"url"=> $logo
|
1806 |
)
|
1807 |
);
|
1808 |
$publisher_info['name'] = get_bloginfo('name');
|
2097 |
$seconds = floor( $word_count / $words_per_second );
|
2098 |
|
2099 |
return array('word_count' => $word_count, 'timerequired' => $seconds);
|
2100 |
+
}
|
output/service.php
ADDED
@@ -0,0 +1,1043 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
Class saswp_output_service{
|
3 |
+
public function __construct() {
|
4 |
+
|
5 |
+
}
|
6 |
+
public function saswp_service_hooks(){
|
7 |
+
add_action( 'wp_ajax_saswp_get_custom_meta_fields', array($this, 'saswp_get_custom_meta_fields'));
|
8 |
+
add_action( 'wp_ajax_saswp_get_schema_type_fields', array($this, 'saswp_get_schema_type_fields'));
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
|
13 |
+
|
14 |
+
$custom_fields = esc_sql ( get_post_meta($schema_post_id, 'saswp_custom_fields', true) );
|
15 |
+
|
16 |
+
if(!empty($custom_fields)){
|
17 |
+
$schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
|
18 |
+
|
19 |
+
foreach ($custom_fields as $key => $field){
|
20 |
+
|
21 |
+
$custom_fields[$key] = get_post_meta($schema_post_id, $field, true);
|
22 |
+
|
23 |
+
}
|
24 |
+
switch ($schema_type) {
|
25 |
+
case 'local_business':
|
26 |
+
|
27 |
+
if(isset($custom_fields['saswp_business_type'])){
|
28 |
+
$input1['@type'] = $custom_fields['saswp_business_type'];
|
29 |
+
}
|
30 |
+
if(isset($custom_fields['saswp_business_name'])){
|
31 |
+
$input1['@type'] = $custom_fields['saswp_business_name'];
|
32 |
+
}
|
33 |
+
if(isset($custom_fields['local_business_name'])){
|
34 |
+
$input1['name'] = $custom_fields['local_business_name'];
|
35 |
+
}
|
36 |
+
|
37 |
+
if(isset($custom_fields['local_business_name_url'])){
|
38 |
+
$input1['url'] = $custom_fields['local_business_name_url'];
|
39 |
+
}
|
40 |
+
if(isset($custom_fields['local_business_description'])){
|
41 |
+
$input1['description'] = $custom_fields['local_business_description'];
|
42 |
+
}
|
43 |
+
if(isset($custom_fields['local_street_address'])){
|
44 |
+
$input1['address']['streetAddress'] = $custom_fields['local_street_address'];
|
45 |
+
}
|
46 |
+
|
47 |
+
if(isset($custom_fields['local_city'])){
|
48 |
+
$input1['address']['addressLocality'] = $custom_fields['local_city'];
|
49 |
+
}
|
50 |
+
if(isset($custom_fields['local_state'])){
|
51 |
+
$input1['address']['addressRegion'] = $custom_fields['local_state'];
|
52 |
+
}
|
53 |
+
if(isset($custom_fields['local_postal_code'])){
|
54 |
+
$input1['address']['postalCode'] = $custom_fields['local_postal_code'];
|
55 |
+
}
|
56 |
+
if(isset($custom_fields['local_phone'])){
|
57 |
+
$input1['telephone'] = $custom_fields['local_phone'];
|
58 |
+
}
|
59 |
+
if(isset($custom_fields['local_website'])){
|
60 |
+
$input1['website'] = $custom_fields['local_website'];
|
61 |
+
}
|
62 |
+
if(isset($custom_fields['local_business_logo'])){
|
63 |
+
$input1['Publisher']['logo']['url'] = $custom_fields['local_business_logo'];
|
64 |
+
}
|
65 |
+
if(isset($custom_fields['saswp_dayofweek'])){
|
66 |
+
$input1['openingHours'] = $custom_fields['saswp_dayofweek'];
|
67 |
+
}
|
68 |
+
if(isset($custom_fields['local_price_range'])){
|
69 |
+
$input1['priceRange'] = $custom_fields['local_price_range'];
|
70 |
+
}
|
71 |
+
|
72 |
+
break;
|
73 |
+
|
74 |
+
case 'Blogposting':
|
75 |
+
|
76 |
+
if(isset($custom_fields['saswp_blogposting_main_entity_of_page'])){
|
77 |
+
$input1['mainEntityOfPage'] = $custom_fields['saswp_blogposting_main_entity_of_page'];
|
78 |
+
}
|
79 |
+
if(isset($custom_fields['saswp_blogposting_headline'])){
|
80 |
+
$input1['headline'] = $custom_fields['saswp_blogposting_headline'];
|
81 |
+
}
|
82 |
+
if(isset($custom_fields['saswp_blogposting_description'])){
|
83 |
+
$input1['description'] = $custom_fields['saswp_blogposting_description'];
|
84 |
+
}
|
85 |
+
if(isset($custom_fields['saswp_blogposting_name'])){
|
86 |
+
$input1['name'] = $custom_fields['saswp_blogposting_name'];
|
87 |
+
}
|
88 |
+
if(isset($custom_fields['saswp_blogposting_url'])){
|
89 |
+
$input1['url'] = $custom_fields['saswp_blogposting_url'];
|
90 |
+
}
|
91 |
+
if(isset($custom_fields['saswp_blogposting_date_published'])){
|
92 |
+
$input1['datePublished'] = $custom_fields['saswp_blogposting_date_published'];
|
93 |
+
}
|
94 |
+
if(isset($custom_fields['saswp_blogposting_date_modified'])){
|
95 |
+
$input1['dateModified'] = $custom_fields['saswp_blogposting_date_modified'];
|
96 |
+
}
|
97 |
+
if(isset($custom_fields['saswp_blogposting_author_name'])){
|
98 |
+
$input1['author']['name'] = $custom_fields['saswp_blogposting_author_name'];
|
99 |
+
}
|
100 |
+
if(isset($custom_fields['saswp_blogposting_organization_name'])){
|
101 |
+
$input1['Publisher']['name'] = $custom_fields['saswp_blogposting_organization_name'];
|
102 |
+
}
|
103 |
+
if(isset($custom_fields['saswp_blogposting_organization_logo'])){
|
104 |
+
$input1['Publisher']['logo']['url'] = $custom_fields['saswp_blogposting_organization_logo'];
|
105 |
+
}
|
106 |
+
|
107 |
+
break;
|
108 |
+
|
109 |
+
case 'NewsArticle':
|
110 |
+
|
111 |
+
if(isset($custom_fields['saswp_newsarticle_main_entity_of_page'])){
|
112 |
+
$input1['mainEntityOfPage'] = $custom_fields['saswp_newsarticle_main_entity_of_page'];
|
113 |
+
}
|
114 |
+
if(isset($custom_fields['saswp_newsarticle_URL'])){
|
115 |
+
$input1['url'] = $custom_fields['saswp_newsarticle_URL'];
|
116 |
+
}
|
117 |
+
if(isset($custom_fields['saswp_newsarticle_headline'])){
|
118 |
+
$input1['headline'] = $custom_fields['saswp_newsarticle_headline'];
|
119 |
+
}
|
120 |
+
if(isset($custom_fields['saswp_newsarticle_date_published'])){
|
121 |
+
$input1['datePublished'] = $custom_fields['saswp_newsarticle_date_published'];
|
122 |
+
}
|
123 |
+
if(isset($custom_fields['saswp_newsarticle_date_modified'])){
|
124 |
+
$input1['dateModified'] = $custom_fields['saswp_newsarticle_date_modified'];
|
125 |
+
}
|
126 |
+
if(isset($custom_fields['saswp_newsarticle_description'])){
|
127 |
+
$input1['description'] = $custom_fields['saswp_newsarticle_description'];
|
128 |
+
}
|
129 |
+
if(isset($custom_fields['saswp_newsarticle_section'])){
|
130 |
+
$input1['articleSection'] = $custom_fields['saswp_newsarticle_section'];
|
131 |
+
}
|
132 |
+
if(isset($custom_fields['saswp_newsarticle_body'])){
|
133 |
+
$input1['articleBody'] = $custom_fields['saswp_newsarticle_body'];
|
134 |
+
}
|
135 |
+
if(isset($custom_fields['saswp_newsarticle_name'])){
|
136 |
+
$input1['name'] = $custom_fields['saswp_newsarticle_name'];
|
137 |
+
}
|
138 |
+
if(isset($custom_fields['saswp_newsarticle_thumbnailurl'])){
|
139 |
+
$input1['thumbnailUrl'] = $custom_fields['saswp_newsarticle_thumbnailurl'];
|
140 |
+
}
|
141 |
+
if(isset($custom_fields['saswp_newsarticle_timerequired'])){
|
142 |
+
$input1['timeRequired'] = $custom_fields['saswp_newsarticle_timerequired'];
|
143 |
+
}
|
144 |
+
if(isset($custom_fields['saswp_newsarticle_main_entity_id'])){
|
145 |
+
$input1['mainEntity']['@id'] = $custom_fields['saswp_newsarticle_main_entity_id'];
|
146 |
+
}
|
147 |
+
if(isset($custom_fields['saswp_newsarticle_author_name'])){
|
148 |
+
$input1['author']['name'] = $custom_fields['saswp_newsarticle_author_name'];
|
149 |
+
}
|
150 |
+
if(isset($custom_fields['saswp_newsarticle_author_image'])){
|
151 |
+
$input1['author']['Image']['url'] = $custom_fields['saswp_newsarticle_author_image'];
|
152 |
+
}
|
153 |
+
if(isset($custom_fields['saswp_newsarticle_organization_name'])){
|
154 |
+
$input1['Publisher']['name'] = $custom_fields['saswp_newsarticle_organization_name'];
|
155 |
+
}
|
156 |
+
if(isset($custom_fields['saswp_newsarticle_organization_logo'])){
|
157 |
+
$input1['Publisher']['logo']['url'] = $custom_fields['saswp_newsarticle_organization_logo'];
|
158 |
+
}
|
159 |
+
|
160 |
+
break;
|
161 |
+
|
162 |
+
case 'WebPage':
|
163 |
+
|
164 |
+
if(isset($custom_fields['saswp_webpage_name'])){
|
165 |
+
$input1['name'] = $custom_fields['saswp_webpage_name'];
|
166 |
+
}
|
167 |
+
if(isset($custom_fields['saswp_webpage_url'])){
|
168 |
+
$input1['url'] = $custom_fields['saswp_webpage_url'];
|
169 |
+
}
|
170 |
+
if(isset($custom_fields['saswp_webpage_description'])){
|
171 |
+
$input1['description'] = $custom_fields['saswp_webpage_description'];
|
172 |
+
}
|
173 |
+
|
174 |
+
if(isset($custom_fields['saswp_webpage_main_entity_of_page'])){
|
175 |
+
$input1['mainEntity']['mainEntityOfPage'] = $custom_fields['saswp_webpage_main_entity_of_page'];
|
176 |
+
}
|
177 |
+
if(isset($custom_fields['saswp_webpage_image'])){
|
178 |
+
$input1['mainEntity']['image'] = $custom_fields['saswp_webpage_image'];
|
179 |
+
}
|
180 |
+
if(isset($custom_fields['saswp_webpage_headline'])){
|
181 |
+
$input1['mainEntity']['headline'] = $custom_fields['saswp_webpage_headline'];
|
182 |
+
}
|
183 |
+
|
184 |
+
if(isset($custom_fields['saswp_webpage_date_published'])){
|
185 |
+
$input1['mainEntity']['datePublished'] = $custom_fields['saswp_webpage_date_published'];
|
186 |
+
}
|
187 |
+
if(isset($custom_fields['saswp_webpage_date_modified'])){
|
188 |
+
$input1['mainEntity']['dateModified'] = $custom_fields['saswp_webpage_date_modified'];
|
189 |
+
}
|
190 |
+
if(isset($custom_fields['saswp_webpage_author_name'])){
|
191 |
+
$input1['mainEntity']['author']['name'] = $custom_fields['saswp_webpage_author_name'];
|
192 |
+
}
|
193 |
+
|
194 |
+
if(isset($custom_fields['saswp_webpage_organization_name'])){
|
195 |
+
$input1['mainEntity']['Publisher']['name'] = $custom_fields['saswp_webpage_organization_name'];
|
196 |
+
}
|
197 |
+
if(isset($custom_fields['saswp_webpage_organization_logo'])){
|
198 |
+
$input1['mainEntity']['Publisher']['logo']['url'] = $custom_fields['saswp_webpage_organization_logo'];
|
199 |
+
}
|
200 |
+
|
201 |
+
break;
|
202 |
+
|
203 |
+
case 'Article':
|
204 |
+
|
205 |
+
if(isset($custom_fields['saswp_article_main_entity_of_page'])){
|
206 |
+
$input1['mainEntityOfPage'] = $custom_fields['saswp_article_main_entity_of_page'];
|
207 |
+
}
|
208 |
+
if(isset($custom_fields['saswp_article_image'])){
|
209 |
+
$input1['image'] = $custom_fields['saswp_article_image'];
|
210 |
+
}
|
211 |
+
if(isset($custom_fields['saswp_article_headline'])){
|
212 |
+
$input1['headline'] = $custom_fields['saswp_article_headline'];
|
213 |
+
}
|
214 |
+
|
215 |
+
if(isset($custom_fields['saswp_article_description'])){
|
216 |
+
$input1['description'] = $custom_fields['saswp_article_description'];
|
217 |
+
}
|
218 |
+
if(isset($custom_fields['saswp_article_date_published'])){
|
219 |
+
$input1['datePublished'] = $custom_fields['saswp_article_date_published'];
|
220 |
+
}
|
221 |
+
if(isset($custom_fields['saswp_article_date_modified'])){
|
222 |
+
$input1['dateModified'] = $custom_fields['saswp_article_date_modified'];
|
223 |
+
}
|
224 |
+
|
225 |
+
if(isset($custom_fields['saswp_article_author_name'])){
|
226 |
+
$input1['author']['name'] = $custom_fields['saswp_article_author_name'];
|
227 |
+
}
|
228 |
+
if(isset($custom_fields['saswp_article_organization_name'])){
|
229 |
+
$input1['Publisher']['name'] = $custom_fields['saswp_article_organization_name'];
|
230 |
+
}
|
231 |
+
if(isset($custom_fields['saswp_article_organization_logo'])){
|
232 |
+
$input1['Publisher']['logo']['url'] = $custom_fields['saswp_article_organization_logo'];
|
233 |
+
}
|
234 |
+
break;
|
235 |
+
|
236 |
+
case 'Recipe':
|
237 |
+
if(isset($custom_fields['saswp_recipe_url'])){
|
238 |
+
$input1['url'] = $custom_fields['saswp_recipe_url'];
|
239 |
+
}
|
240 |
+
if(isset($custom_fields['saswp_recipe_name'])){
|
241 |
+
$input1['name'] = $custom_fields['saswp_recipe_name'];
|
242 |
+
}
|
243 |
+
if(isset($custom_fields['saswp_recipe_date_published'])){
|
244 |
+
$input1['datePublished'] = $custom_fields['saswp_recipe_date_published'];
|
245 |
+
}
|
246 |
+
|
247 |
+
if(isset($custom_fields['saswp_recipe_date_modified'])){
|
248 |
+
$input1['dateModified'] = $custom_fields['saswp_recipe_date_modified'];
|
249 |
+
}
|
250 |
+
if(isset($custom_fields['saswp_recipe_description'])){
|
251 |
+
$input1['description'] = $custom_fields['saswp_recipe_description'];
|
252 |
+
}
|
253 |
+
if(isset($custom_fields['saswp_recipe_main_entity'])){
|
254 |
+
$input1['mainEntity']['@id'] = $custom_fields['saswp_recipe_main_entity'];
|
255 |
+
}
|
256 |
+
|
257 |
+
if(isset($custom_fields['saswp_recipe_author_name'])){
|
258 |
+
$input1['author']['name'] = $custom_fields['saswp_recipe_author_name'];
|
259 |
+
}
|
260 |
+
if(isset($custom_fields['saswp_recipe_author_image'])){
|
261 |
+
$input1['author']['Image']['url'] = $custom_fields['saswp_recipe_author_image'];
|
262 |
+
}
|
263 |
+
if(isset($custom_fields['saswp_recipe_organization_name'])){
|
264 |
+
$input1['mainEntity']['Publisher']['name'] = $custom_fields['saswp_recipe_organization_name'];
|
265 |
+
}
|
266 |
+
|
267 |
+
if(isset($custom_fields['saswp_recipe_organization_logo'])){
|
268 |
+
$input1['mainEntity']['Publisher']['logo']['url'] = $custom_fields['saswp_recipe_organization_logo'];
|
269 |
+
}
|
270 |
+
if(isset($custom_fields['saswp_recipe_preptime'])){
|
271 |
+
$input1['prepTime'] = $custom_fields['saswp_recipe_preptime'];
|
272 |
+
}
|
273 |
+
if(isset($custom_fields['saswp_recipe_cooktime'])){
|
274 |
+
$input1['cookTime'] = $custom_fields['saswp_recipe_cooktime'];
|
275 |
+
}
|
276 |
+
|
277 |
+
if(isset($custom_fields['saswp_recipe_totaltime'])){
|
278 |
+
$input1['totalTime'] = $custom_fields['saswp_recipe_totaltime'];
|
279 |
+
}
|
280 |
+
if(isset($custom_fields['saswp_recipe_keywords'])){
|
281 |
+
$input1['keywords'] = $custom_fields['saswp_recipe_keywords'];
|
282 |
+
}
|
283 |
+
if(isset($custom_fields['saswp_recipe_recipeyield'])){
|
284 |
+
$input1['recipeYield'] = $custom_fields['saswp_recipe_recipeyield'];
|
285 |
+
}
|
286 |
+
|
287 |
+
if(isset($custom_fields['saswp_recipe_category'])){
|
288 |
+
$input1['recipeCategory'] = $custom_fields['saswp_recipe_category'];
|
289 |
+
}
|
290 |
+
if(isset($custom_fields['saswp_recipe_cuisine'])){
|
291 |
+
$input1['recipeCuisine'] = $custom_fields['saswp_recipe_cuisine'];
|
292 |
+
}
|
293 |
+
if(isset($custom_fields['saswp_recipe_nutrition'])){
|
294 |
+
$input1['nutrition']['calories'] = $custom_fields['saswp_recipe_nutrition'];
|
295 |
+
}
|
296 |
+
|
297 |
+
if(isset($custom_fields['saswp_recipe_ingredient'])){
|
298 |
+
$input1['recipeIngredient'] = $custom_fields['saswp_recipe_ingredient'];
|
299 |
+
}
|
300 |
+
if(isset($custom_fields['saswp_recipe_instructions'])){
|
301 |
+
$input1['recipeInstructions'] = $custom_fields['saswp_recipe_instructions'];
|
302 |
+
}
|
303 |
+
if(isset($custom_fields['saswp_recipe_video_name'])){
|
304 |
+
$input1['video']['name'] = $custom_fields['saswp_recipe_video_name'];
|
305 |
+
}
|
306 |
+
|
307 |
+
if(isset($custom_fields['saswp_recipe_video_description'])){
|
308 |
+
$input1['video']['description'] = $custom_fields['saswp_recipe_video_description'];
|
309 |
+
}
|
310 |
+
if(isset($custom_fields['saswp_recipe_video_thumbnailurl'])){
|
311 |
+
$input1['video']['thumbnailUrl'] = $custom_fields['saswp_recipe_video_thumbnailurl'];
|
312 |
+
}
|
313 |
+
if(isset($custom_fields['saswp_recipe_video_contenturl'])){
|
314 |
+
$input1['video']['contentUrl'] = $custom_fields['saswp_recipe_video_contenturl'];
|
315 |
+
}
|
316 |
+
if(isset($custom_fields['saswp_recipe_video_embedurl'])){
|
317 |
+
$input1['video']['embedUrl'] = $custom_fields['saswp_recipe_video_embedurl'];
|
318 |
+
}
|
319 |
+
if(isset($custom_fields['saswp_recipe_video_upload_date'])){
|
320 |
+
$input1['video']['uploadDate'] = $custom_fields['saswp_recipe_video_upload_date'];
|
321 |
+
}
|
322 |
+
if(isset($custom_fields['saswp_recipe_video_duration'])){
|
323 |
+
$input1['video']['duration'] = $custom_fields['saswp_recipe_video_duration'];
|
324 |
+
}
|
325 |
+
break;
|
326 |
+
|
327 |
+
case 'Product':
|
328 |
+
if(isset($custom_fields['saswp_product_url'])){
|
329 |
+
$input1['url'] = $custom_fields['saswp_product_url'];
|
330 |
+
}
|
331 |
+
if(isset($custom_fields['saswp_product_name'])){
|
332 |
+
$input1['name'] = $custom_fields['saswp_product_name'];
|
333 |
+
}
|
334 |
+
|
335 |
+
if(isset($custom_fields['saswp_product_brand'])){
|
336 |
+
$input1['brand']['name'] = $custom_fields['saswp_product_brand'];
|
337 |
+
}
|
338 |
+
|
339 |
+
if(isset($custom_fields['saswp_product_isbn'])){
|
340 |
+
$input1['isbn'] = $custom_fields['saswp_product_isbn'];
|
341 |
+
}
|
342 |
+
if(isset($custom_fields['saswp_product_mpn'])){
|
343 |
+
$input1['mpn'] = $custom_fields['saswp_product_mpn'];
|
344 |
+
}
|
345 |
+
if(isset($custom_fields['saswp_product_gtin8'])){
|
346 |
+
$input1['gtin8'] = $custom_fields['saswp_product_gtin8'];
|
347 |
+
}
|
348 |
+
|
349 |
+
if(isset($custom_fields['saswp_product_description'])){
|
350 |
+
$input1['description'] = $custom_fields['saswp_product_description'];
|
351 |
+
}
|
352 |
+
if(isset($custom_fields['saswp_product_image'])){
|
353 |
+
$input1['image'] = $custom_fields['saswp_product_image'];
|
354 |
+
}
|
355 |
+
if(isset($custom_fields['saswp_product_availability'])){
|
356 |
+
$input1['offers']['availability'] = $custom_fields['saswp_product_availability'];
|
357 |
+
}
|
358 |
+
if(isset($custom_fields['saswp_product_price'])){
|
359 |
+
$input1['offers']['price'] = $custom_fields['saswp_product_price'];
|
360 |
+
}
|
361 |
+
if(isset($custom_fields['saswp_product_currency'])){
|
362 |
+
$input1['offers']['priceCurrency'] = $custom_fields['saswp_product_currency'];
|
363 |
+
}
|
364 |
+
if(isset($custom_fields['saswp_product_priceValidUntil'])){
|
365 |
+
$input1['offers']['priceValidUntil'] = $custom_fields['saswp_product_priceValidUntil'];
|
366 |
+
$input1['offers']['url'] = $custom_fields['saswp_product_priceValidUntil'];
|
367 |
+
}
|
368 |
+
break;
|
369 |
+
|
370 |
+
case 'Service':
|
371 |
+
if(isset($custom_fields['saswp_service_schema_name'])){
|
372 |
+
$input1['name'] = $custom_fields['saswp_service_schema_name'];
|
373 |
+
}
|
374 |
+
if(isset($custom_fields['saswp_service_schema_type'])){
|
375 |
+
$input1['serviceType'] = $custom_fields['saswp_service_schema_type'];
|
376 |
+
}
|
377 |
+
if(isset($custom_fields['saswp_service_schema_provider_name'])){
|
378 |
+
$input1['provider']['name'] = $custom_fields['saswp_service_schema_provider_name'];
|
379 |
+
}
|
380 |
+
if(isset($custom_fields['saswp_service_schema_image'])){
|
381 |
+
$input1['provider']['image'] = $custom_fields['saswp_service_schema_image'];
|
382 |
+
}
|
383 |
+
if(isset($custom_fields['saswp_service_schema_locality'])){
|
384 |
+
$input1['provider']['address']['addressLocality'] = $custom_fields['saswp_service_schema_locality'];
|
385 |
+
}
|
386 |
+
if(isset($custom_fields['saswp_service_schema_postal_code'])){
|
387 |
+
$input1['provider']['address']['postalCode'] = $custom_fields['saswp_service_schema_postal_code'];
|
388 |
+
}
|
389 |
+
if(isset($custom_fields['saswp_service_schema_telephone'])){
|
390 |
+
$input1['provider']['address']['telephone'] = $custom_fields['saswp_service_schema_telephone'];
|
391 |
+
}
|
392 |
+
if(isset($custom_fields['saswp_service_schema_price_range'])){
|
393 |
+
$input1['provider']['priceRange'] = $custom_fields['saswp_service_schema_price_range'];
|
394 |
+
}
|
395 |
+
if(isset($custom_fields['saswp_service_schema_description'])){
|
396 |
+
$input1['description'] = $custom_fields['saswp_service_schema_description'];
|
397 |
+
}
|
398 |
+
if(isset($custom_fields['saswp_service_schema_area_served'])){
|
399 |
+
$input1['areaServed'] = $custom_fields['saswp_service_schema_area_served'];
|
400 |
+
}
|
401 |
+
if(isset($custom_fields['saswp_service_schema_service_offer'])){
|
402 |
+
$input1['hasOfferCatalog'] = $custom_fields['saswp_service_schema_service_offer'];
|
403 |
+
}
|
404 |
+
|
405 |
+
break;
|
406 |
+
|
407 |
+
case 'Review':
|
408 |
+
if(isset($custom_fields['saswp_review_schema_item_type'])){
|
409 |
+
$input1['itemReviewed']['@type'] = $custom_fields['saswp_review_schema_item_type'];
|
410 |
+
}
|
411 |
+
if(isset($custom_fields['saswp_review_schema_name'])){
|
412 |
+
$input1['itemReviewed']['name'] = $custom_fields['saswp_review_schema_name'];
|
413 |
+
}
|
414 |
+
if(isset($custom_fields['saswp_review_schema_description'])){
|
415 |
+
$input1['description'] = $custom_fields['saswp_review_schema_description'];
|
416 |
+
}
|
417 |
+
|
418 |
+
if(isset($custom_fields['saswp_review_schema_date_published'])){
|
419 |
+
$input1['datePublished'] = $custom_fields['saswp_review_schema_date_published'];
|
420 |
+
}
|
421 |
+
if(isset($custom_fields['saswp_review_schema_date_modified'])){
|
422 |
+
$input1['dateModified'] = $custom_fields['saswp_review_schema_date_modified'];
|
423 |
+
}
|
424 |
+
if(isset($custom_fields['saswp_review_schema_image'])){
|
425 |
+
$input1['itemReviewed']['image'] = $custom_fields['saswp_review_schema_image'];
|
426 |
+
}
|
427 |
+
|
428 |
+
if(isset($custom_fields['saswp_review_schema_price_range'])){
|
429 |
+
$input1['itemReviewed']['priceRange'] = $custom_fields['saswp_review_schema_price_range'];
|
430 |
+
}
|
431 |
+
if(isset($custom_fields['saswp_review_schema_street_address'])){
|
432 |
+
$input1['itemReviewed']['address']['streetAddress'] = $custom_fields['saswp_review_schema_street_address'];
|
433 |
+
}
|
434 |
+
if(isset($custom_fields['saswp_review_schema_locality'])){
|
435 |
+
$input1['itemReviewed']['address']['addressLocality'] = $custom_fields['saswp_review_schema_locality'];
|
436 |
+
}
|
437 |
+
|
438 |
+
if(isset($custom_fields['saswp_review_schema_region'])){
|
439 |
+
$input1['itemReviewed']['address']['addressRegion'] = $custom_fields['saswp_review_schema_region'];
|
440 |
+
}
|
441 |
+
if(isset($custom_fields['saswp_review_schema_postal_code'])){
|
442 |
+
$input1['itemReviewed']['address']['postalCode'] = $custom_fields['saswp_review_schema_postal_code'];
|
443 |
+
}
|
444 |
+
if(isset($custom_fields['saswp_review_schema_country'])){
|
445 |
+
$input1['itemReviewed']['address']['addressCountry'] = $custom_fields['saswp_review_schema_country'];
|
446 |
+
}
|
447 |
+
if(isset($custom_fields['saswp_review_schema_telephone'])){
|
448 |
+
$input1['itemReviewed']['telephone'] = $custom_fields['saswp_review_schema_telephone'];
|
449 |
+
}
|
450 |
+
break;
|
451 |
+
|
452 |
+
case 'VideoObject':
|
453 |
+
|
454 |
+
if(isset($custom_fields['saswp_video_object_url'])){
|
455 |
+
$input1['url'] = $custom_fields['saswp_video_object_url'];
|
456 |
+
}
|
457 |
+
if(isset($custom_fields['saswp_video_object_headline'])){
|
458 |
+
$input1['headline'] = $custom_fields['saswp_video_object_headline'];
|
459 |
+
}
|
460 |
+
if(isset($custom_fields['saswp_video_object_date_published'])){
|
461 |
+
$input1['datePublished'] = $custom_fields['saswp_video_object_date_published'];
|
462 |
+
}
|
463 |
+
|
464 |
+
if(isset($custom_fields['saswp_video_object_date_modified'])){
|
465 |
+
$input1['dateModified'] = $custom_fields['saswp_video_object_date_modified'];
|
466 |
+
}
|
467 |
+
if(isset($custom_fields['saswp_video_object_description'])){
|
468 |
+
$input1['description'] = $custom_fields['saswp_video_object_description'];
|
469 |
+
}
|
470 |
+
if(isset($custom_fields['saswp_video_object_name'])){
|
471 |
+
$input1['name'] = $custom_fields['saswp_video_object_name'];
|
472 |
+
}
|
473 |
+
|
474 |
+
if(isset($custom_fields['saswp_video_object_upload_date'])){
|
475 |
+
$input1['uploadDate'] = $custom_fields['saswp_video_object_upload_date'];
|
476 |
+
}
|
477 |
+
if(isset($custom_fields['saswp_video_object_thumbnail_url'])){
|
478 |
+
$input1['thumbnailUrl'] = $custom_fields['saswp_video_object_thumbnail_url'];
|
479 |
+
}
|
480 |
+
if(isset($custom_fields['saswp_video_object_main_entity_id'])){
|
481 |
+
$input1['mainEntity']['@id'] = $custom_fields['saswp_video_object_main_entity_id'];
|
482 |
+
}
|
483 |
+
|
484 |
+
if(isset($custom_fields['saswp_video_object_author_name'])){
|
485 |
+
$input1['author']['name'] = $custom_fields['saswp_video_object_author_name'];
|
486 |
+
}
|
487 |
+
if(isset($custom_fields['saswp_video_object_author_image'])){
|
488 |
+
$input1['author']['Image']['url'] = $custom_fields['saswp_video_object_author_image'];
|
489 |
+
}
|
490 |
+
if(isset($custom_fields['saswp_video_object_organization_name'])){
|
491 |
+
$input1['Publisher']['name'] = $custom_fields['saswp_video_object_organization_name'];
|
492 |
+
}
|
493 |
+
if(isset($custom_fields['saswp_video_object_organization_logo'])){
|
494 |
+
$input1['Publisher']['logo']['url'] = $custom_fields['saswp_video_object_organization_logo'];
|
495 |
+
}
|
496 |
+
break;
|
497 |
+
|
498 |
+
case 'qanda':
|
499 |
+
|
500 |
+
if(isset($custom_fields['saswp_qa_question_title'])){
|
501 |
+
$input1['mainEntity']['name'] = $custom_fields['saswp_qa_question_title'];
|
502 |
+
}
|
503 |
+
if(isset($custom_fields['saswp_qa_question_description'])){
|
504 |
+
$input1['mainEntity']['text'] = $custom_fields['saswp_qa_question_description'];
|
505 |
+
}
|
506 |
+
if(isset($custom_fields['saswp_qa_upvote_count'])){
|
507 |
+
$input1['mainEntity']['upvoteCount'] = $custom_fields['saswp_qa_upvote_count'];
|
508 |
+
}
|
509 |
+
|
510 |
+
if(isset($custom_fields['saswp_qa_date_created'])){
|
511 |
+
$input1['mainEntity']['dateCreated'] = $custom_fields['saswp_qa_date_created'];
|
512 |
+
}
|
513 |
+
if(isset($custom_fields['saswp_qa_question_author_name'])){
|
514 |
+
$input1['mainEntity']['author']['name'] = $custom_fields['saswp_qa_question_author_name'];
|
515 |
+
}
|
516 |
+
if(isset($custom_fields['saswp_qa_accepted_answer_text'])){
|
517 |
+
$input1['mainEntity']['acceptedAnswer']['text'] = $custom_fields['saswp_qa_accepted_answer_text'];
|
518 |
+
}
|
519 |
+
|
520 |
+
if(isset($custom_fields['saswp_qa_accepted_answer_date_created'])){
|
521 |
+
$input1['mainEntity']['acceptedAnswer']['dateCreated'] = $custom_fields['saswp_qa_accepted_answer_date_created'];
|
522 |
+
}
|
523 |
+
if(isset($custom_fields['saswp_qa_accepted_answer_upvote_count'])){
|
524 |
+
$input1['mainEntity']['acceptedAnswer']['upvoteCount'] = $custom_fields['saswp_qa_accepted_answer_upvote_count'];
|
525 |
+
}
|
526 |
+
if(isset($custom_fields['saswp_qa_accepted_answer_url'])){
|
527 |
+
$input1['mainEntity']['acceptedAnswer']['url'] = $custom_fields['saswp_qa_accepted_answer_url'];
|
528 |
+
}
|
529 |
+
|
530 |
+
if(isset($custom_fields['saswp_qa_accepted_author_name'])){
|
531 |
+
$input1['mainEntity']['acceptedAnswer']['author']['name'] = $custom_fields['saswp_qa_accepted_author_name'];
|
532 |
+
}
|
533 |
+
if(isset($custom_fields['saswp_qa_suggested_answer_text'])){
|
534 |
+
$input1['mainEntity']['suggestedAnswer']['text'] = $custom_fields['saswp_qa_suggested_answer_text'];
|
535 |
+
}
|
536 |
+
if(isset($custom_fields['saswp_qa_suggested_answer_date_created'])){
|
537 |
+
$input1['mainEntity']['suggestedAnswer']['dateCreated'] = $custom_fields['saswp_qa_suggested_answer_date_created'];
|
538 |
+
}
|
539 |
+
|
540 |
+
if(isset($custom_fields['saswp_qa_suggested_answer_upvote_count'])){
|
541 |
+
$input1['mainEntity']['suggestedAnswer']['upvoteCount'] = $custom_fields['saswp_qa_suggested_answer_upvote_count'];
|
542 |
+
}
|
543 |
+
if(isset($custom_fields['saswp_qa_suggested_answer_url'])){
|
544 |
+
$input1['mainEntity']['suggestedAnswer']['url'] = $custom_fields['saswp_qa_suggested_answer_url'];
|
545 |
+
}
|
546 |
+
if(isset($custom_fields['saswp_qa_suggested_author_name'])){
|
547 |
+
$input1['mainEntity']['suggestedAnswer']['author']['name'] = $custom_fields['saswp_qa_suggested_author_name'];
|
548 |
+
}
|
549 |
+
|
550 |
+
break;
|
551 |
+
|
552 |
+
default:
|
553 |
+
break;
|
554 |
+
}
|
555 |
+
}
|
556 |
+
return $input1;
|
557 |
+
}
|
558 |
+
|
559 |
+
|
560 |
+
public function saswp_get_schema_type_fields(){
|
561 |
+
|
562 |
+
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
563 |
+
return;
|
564 |
+
}
|
565 |
+
if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
|
566 |
+
return;
|
567 |
+
}
|
568 |
+
|
569 |
+
$schema_type = isset( $_POST['schema_type'] ) ? sanitize_text_field( $_POST['schema_type'] ) : '';
|
570 |
+
$post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
|
571 |
+
$meta_fields = $this->saswp_get_all_schema_type_fields($schema_type);
|
572 |
+
|
573 |
+
wp_send_json( $meta_fields );
|
574 |
+
|
575 |
+
wp_die();
|
576 |
+
}
|
577 |
+
|
578 |
+
public function saswp_get_custom_meta_fields(){
|
579 |
+
|
580 |
+
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
581 |
+
return;
|
582 |
+
}
|
583 |
+
if ( !wp_verify_nonce( $_POST['saswp_security_nonce'], 'saswp_ajax_check_nonce' ) ){
|
584 |
+
return;
|
585 |
+
}
|
586 |
+
|
587 |
+
$search_string = isset( $_POST['q'] ) ? sanitize_text_field( $_POST['q'] ) : '';
|
588 |
+
$data = array();
|
589 |
+
$result = array();
|
590 |
+
|
591 |
+
global $wpdb;
|
592 |
+
$saswp_meta_array = $wpdb->get_results( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key LIKE '%{$search_string}%'", ARRAY_A ); // WPCS: unprepared SQL OK.
|
593 |
+
if ( isset( $saswp_meta_array ) && ! empty( $saswp_meta_array ) ) {
|
594 |
+
foreach ( $saswp_meta_array as $value ) {
|
595 |
+
// if ( ! in_array( $value['meta_key'], $schema_post_meta_fields ) ) {
|
596 |
+
$data[] = array(
|
597 |
+
'id' => $value['meta_key'],
|
598 |
+
'text' => preg_replace( '/^_/', '', esc_html( str_replace( '_', ' ', $value['meta_key'] ) ) ),
|
599 |
+
);
|
600 |
+
//}
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
if ( is_array( $data ) && ! empty( $data ) ) {
|
605 |
+
$result[] = array(
|
606 |
+
'children' => $data,
|
607 |
+
);
|
608 |
+
}
|
609 |
+
wp_send_json( $result );
|
610 |
+
|
611 |
+
wp_die();
|
612 |
+
}
|
613 |
+
public function saswp_woocommerce_product_details($post_id){
|
614 |
+
|
615 |
+
$product_details = array();
|
616 |
+
if (class_exists('WC_Product')) {
|
617 |
+
$product = new WC_Product($post_id);
|
618 |
+
if(is_object($product)){
|
619 |
+
$gtin = get_post_meta($post_id, $key='hwp_product_gtin', true);
|
620 |
+
if($gtin !=''){
|
621 |
+
$product_details['product_gtin8'] = $gtin;
|
622 |
+
}
|
623 |
+
$brand = get_post_meta($post_id, $key='hwp_product_brand', true);
|
624 |
+
if($brand !=''){
|
625 |
+
$product_details['product_brand'] = $brand;
|
626 |
+
}
|
627 |
+
$date_on_sale = $product->get_date_on_sale_to();
|
628 |
+
$product_details['product_name'] = $product->get_title();
|
629 |
+
$product_details['product_description'] = $product->get_description();
|
630 |
+
$product_details['product_image'] = $product->get_image();
|
631 |
+
$product_details['product_availability'] = $product->get_stock_status();
|
632 |
+
$product_details['product_price'] = $product->get_price();
|
633 |
+
$product_details['product_sku'] = $product->get_sku();
|
634 |
+
if(isset($date_on_sale)){
|
635 |
+
$product_details['product_priceValidUntil'] = $date_on_sale->date('Y-m-d G:i:s');
|
636 |
+
}
|
637 |
+
$product_details['product_currency'] = get_option( 'woocommerce_currency' );
|
638 |
+
|
639 |
+
$reviews_arr = array();
|
640 |
+
$reviews = get_approved_comments( $post_id );
|
641 |
+
if($reviews){
|
642 |
+
foreach($reviews as $review){
|
643 |
+
$reviews_arr[] = array(
|
644 |
+
'author' => $review->comment_author,
|
645 |
+
'datePublished' => $review->comment_date,
|
646 |
+
'description' => $review->comment_content,
|
647 |
+
'reviewRating' => get_comment_meta( $review->comment_ID, 'rating', true ),
|
648 |
+
);
|
649 |
+
}
|
650 |
+
}
|
651 |
+
$product_details['product_review_count'] = $product->get_review_count();
|
652 |
+
$product_details['product_average_rating'] = $product->get_average_rating();
|
653 |
+
$product_details['product_reviews'] = $reviews_arr;
|
654 |
+
}
|
655 |
+
}
|
656 |
+
return $product_details;
|
657 |
+
}
|
658 |
+
|
659 |
+
public function saswp_extra_theme_review_details($post_id){
|
660 |
+
global $sd_data;
|
661 |
+
|
662 |
+
$review_data = array();
|
663 |
+
$rating_value =0;
|
664 |
+
$post_review_title ='';
|
665 |
+
$post_review_desc ='';
|
666 |
+
|
667 |
+
$post_meta = esc_sql ( get_post_meta($post_id, $key='', true) );
|
668 |
+
|
669 |
+
if(isset($post_meta['_post_review_box_breakdowns_score'])){
|
670 |
+
$rating_value = bcdiv($post_meta['_post_review_box_breakdowns_score'][0], 20, 2);
|
671 |
+
}
|
672 |
+
if(isset($post_meta['_post_review_box_title'])){
|
673 |
+
$post_review_title = $post_meta['_post_review_box_title'][0];
|
674 |
+
}
|
675 |
+
if(isset($post_meta['_post_review_box_summary'])){
|
676 |
+
$post_review_desc = $post_meta['_post_review_box_summary'][0];
|
677 |
+
}
|
678 |
+
if($post_review_title && $rating_value>0 && (isset($sd_data['saswp-extra']) && $sd_data['saswp-extra'] ==1) && get_template()=='Extra'){
|
679 |
+
|
680 |
+
$review_data['aggregateRating'] = array(
|
681 |
+
'@type' => 'AggregateRating',
|
682 |
+
'ratingValue' => $rating_value,
|
683 |
+
'reviewCount' => 1,
|
684 |
+
);
|
685 |
+
|
686 |
+
$review_data['review'] = array(
|
687 |
+
'@type' => 'Review',
|
688 |
+
'author' => get_the_author(),
|
689 |
+
'datePublished' => get_the_date("Y-m-d\TH:i:s\Z"),
|
690 |
+
'name' => $post_review_title,
|
691 |
+
'reviewBody' => $post_review_desc,
|
692 |
+
'reviewRating' => array(
|
693 |
+
'@type' => 'Rating',
|
694 |
+
'ratingValue' => $rating_value,
|
695 |
+
),
|
696 |
+
|
697 |
+
);
|
698 |
+
|
699 |
+
}
|
700 |
+
return $review_data;
|
701 |
+
|
702 |
+
}
|
703 |
+
|
704 |
+
public function saswp_dw_question_answers_details($post_id){
|
705 |
+
global $sd_data;
|
706 |
+
$dw_qa = array();
|
707 |
+
$qa_page = array();
|
708 |
+
|
709 |
+
$post_type = get_post_type($post_id);
|
710 |
+
if($post_type =='dwqa-question' && isset($sd_data['saswp-dw-question-answer']) && $sd_data['saswp-dw-question-answer'] ==1 ){
|
711 |
+
|
712 |
+
$post_meta = get_post_meta($post_id, $key='', true);
|
713 |
+
$best_answer_id = $post_meta['_dwqa_best_answer'][0];
|
714 |
+
|
715 |
+
$userid = get_post_field( 'post_author', $post_id );
|
716 |
+
$userinfo = get_userdata($userid);
|
717 |
+
|
718 |
+
$dw_qa['@type'] = 'Question';
|
719 |
+
$dw_qa['name'] = get_the_title();
|
720 |
+
$dw_qa['upvoteCount'] = get_post_meta( $post_id, '_dwqa_votes', true );
|
721 |
+
$args = array(
|
722 |
+
'p' => $post_id, // ID of a page, post, or custom type
|
723 |
+
'post_type' => 'dwqa-question'
|
724 |
+
);
|
725 |
+
|
726 |
+
$my_posts = new WP_Query($args);
|
727 |
+
if ( $my_posts->have_posts() ) {
|
728 |
+
while ( $my_posts->have_posts() ) : $my_posts->the_post();
|
729 |
+
$dw_qa['text'] = get_the_content();
|
730 |
+
endwhile;
|
731 |
+
}
|
732 |
+
$dw_qa['dateCreated'] = get_the_date("Y-m-d\TH:i:s\Z");
|
733 |
+
$dw_qa['author'] = array('@type' => 'Person','name' =>$userinfo->data->user_nicename);
|
734 |
+
$dw_qa['answerCount'] = $post_meta['_dwqa_answers_count'][0];
|
735 |
+
|
736 |
+
$args = array(
|
737 |
+
'post_type' => 'dwqa-answer',
|
738 |
+
'post_parent' => $post_id,
|
739 |
+
'post_per_page' => '-1',
|
740 |
+
'post_status' => array('publish')
|
741 |
+
);
|
742 |
+
|
743 |
+
$answer_array = get_posts($args);
|
744 |
+
|
745 |
+
$accepted_answer = array();
|
746 |
+
$suggested_answer = array();
|
747 |
+
foreach($answer_array as $answer){
|
748 |
+
$authorinfo = get_userdata($answer->post_author);
|
749 |
+
if($answer->ID == $best_answer_id){
|
750 |
+
$accepted_answer['@type'] = 'Answer';
|
751 |
+
$accepted_answer['upvoteCount'] = get_post_meta( $answer->ID, '_dwqa_votes', true );
|
752 |
+
$accepted_answer['url'] = get_permalink($answer->ID);
|
753 |
+
$accepted_answer['text'] = $answer->post_content;
|
754 |
+
$accepted_answer['dateCreated'] = get_the_date("Y-m-d\TH:i:s\Z", $answer);
|
755 |
+
$accepted_answer['author'] = array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename);
|
756 |
+
}else{
|
757 |
+
$suggested_answer[] = array(
|
758 |
+
'@type' => 'Answer',
|
759 |
+
'upvoteCount' => get_post_meta( $answer->ID, '_dwqa_votes', true ),
|
760 |
+
'url' => get_permalink($answer->ID),
|
761 |
+
'text' => $answer->post_content,
|
762 |
+
'dateCreated' => get_the_date("Y-m-d\TH:i:s\Z", $answer),
|
763 |
+
'author' => array('@type' => 'Person', 'name' => $authorinfo->data->user_nicename),
|
764 |
+
);
|
765 |
+
}
|
766 |
+
}
|
767 |
+
$dw_qa['acceptedAnswer'] = $accepted_answer;
|
768 |
+
$dw_qa['suggestedAnswer'] = $suggested_answer;
|
769 |
+
|
770 |
+
$qa_page['@context'] = 'http://schema.org';
|
771 |
+
$qa_page['@type'] = 'QAPage';
|
772 |
+
$qa_page['mainEntity'] = $dw_qa;
|
773 |
+
|
774 |
+
}
|
775 |
+
return $qa_page;
|
776 |
+
}
|
777 |
+
|
778 |
+
public function saswp_get_all_schema_type_fields($schema_type, $id =null){
|
779 |
+
$meta_field = array();
|
780 |
+
if($schema_type ==''){
|
781 |
+
$schema_type = get_post_meta( $id, 'schema_type', true);
|
782 |
+
}
|
783 |
+
switch ($schema_type) {
|
784 |
+
|
785 |
+
case 'local_business':
|
786 |
+
|
787 |
+
$meta_field = array(
|
788 |
+
'saswp_business_type' => 'Business Type',
|
789 |
+
'saswp_business_name' => 'Sub Business Type',
|
790 |
+
'local_business_name' => 'Business Name',
|
791 |
+
'local_business_name_url' => 'URL',
|
792 |
+
'local_business_description' => 'Description',
|
793 |
+
'local_street_address' => 'Street Address',
|
794 |
+
'local_city' => 'City',
|
795 |
+
'local_state' => 'State',
|
796 |
+
'local_postal_code' => 'Postal Code',
|
797 |
+
'local_phone' => 'Phone',
|
798 |
+
'local_website' => 'Website',
|
799 |
+
'local_business_logo' => 'Image',
|
800 |
+
'saswp_dayofweek' => 'Operation Days',
|
801 |
+
'local_price_range' => 'Price Range',
|
802 |
+
);
|
803 |
+
break;
|
804 |
+
|
805 |
+
case 'Blogposting':
|
806 |
+
$meta_field = array(
|
807 |
+
'saswp_blogposting_main_entity_of_page' => 'Main Entity Of Page',
|
808 |
+
'saswp_blogposting_headline' => 'Headline',
|
809 |
+
'saswp_blogposting_description' => 'Description',
|
810 |
+
|
811 |
+
'saswp_blogposting_name' => 'Name',
|
812 |
+
'saswp_blogposting_url' => 'URL',
|
813 |
+
'saswp_blogposting_date_published' => 'Date Published',
|
814 |
+
|
815 |
+
'saswp_blogposting_date_modified' => 'Date Modified',
|
816 |
+
'saswp_blogposting_author_name' => 'Author Name',
|
817 |
+
'saswp_blogposting_organization_name' => 'Organization Name',
|
818 |
+
'saswp_blogposting_organization_logo' => 'Organization Logo',
|
819 |
+
|
820 |
+
);
|
821 |
+
|
822 |
+
break;
|
823 |
+
|
824 |
+
case 'NewsArticle':
|
825 |
+
$meta_field = array(
|
826 |
+
'saswp_newsarticle_main_entity_of_page' => 'Main Entity Of Page',
|
827 |
+
'saswp_newsarticle_URL' => 'URL',
|
828 |
+
'saswp_newsarticle_headline' => 'Headline',
|
829 |
+
|
830 |
+
'saswp_newsarticle_date_published' => 'Date Published',
|
831 |
+
'saswp_newsarticle_date_modified' => 'Date Modified',
|
832 |
+
'saswp_newsarticle_headline' => 'Headline',
|
833 |
+
|
834 |
+
'saswp_newsarticle_description' => 'Description',
|
835 |
+
'saswp_newsarticle_section' => 'Article Section',
|
836 |
+
'saswp_newsarticle_body' => 'Article Body',
|
837 |
+
|
838 |
+
'saswp_newsarticle_name' => 'Name',
|
839 |
+
'saswp_newsarticle_thumbnailurl' => 'Thumbnail URL',
|
840 |
+
'saswp_newsarticle_timerequired' => 'Time Required',
|
841 |
+
|
842 |
+
'saswp_newsarticle_main_entity_id' => 'Main Entity Id',
|
843 |
+
'saswp_newsarticle_author_name' => 'Author Name',
|
844 |
+
'saswp_newsarticle_author_image' => 'Author Image',
|
845 |
+
|
846 |
+
'saswp_newsarticle_organization_name' => 'Organization Name',
|
847 |
+
'saswp_newsarticle_organization_logo' => 'Organization Logo',
|
848 |
+
);
|
849 |
+
|
850 |
+
break;
|
851 |
+
|
852 |
+
case 'WebPage':
|
853 |
+
$meta_field = array(
|
854 |
+
'saswp_webpage_name' => 'Name',
|
855 |
+
'saswp_webpage_url' => 'URL',
|
856 |
+
'saswp_webpage_description' => 'Description',
|
857 |
+
|
858 |
+
'saswp_webpage_main_entity_of_page' => 'Main Entity Of Page',
|
859 |
+
'saswp_webpage_image' => 'Image',
|
860 |
+
'saswp_webpage_headline' => 'Headline',
|
861 |
+
|
862 |
+
'saswp_webpage_date_published' => 'Date Published',
|
863 |
+
'saswp_webpage_date_modified' => 'Date Modified',
|
864 |
+
'saswp_webpage_author_name' => 'Author Name',
|
865 |
+
|
866 |
+
'saswp_webpage_organization_name' => 'Organization Name',
|
867 |
+
'saswp_webpage_organization_logo' => 'Organization Logo',
|
868 |
+
);
|
869 |
+
|
870 |
+
break;
|
871 |
+
|
872 |
+
case 'Article':
|
873 |
+
$meta_field = array(
|
874 |
+
'saswp_article_main_entity_of_page' => 'Main Entity Of Page',
|
875 |
+
'saswp_article_image' => 'Image',
|
876 |
+
'saswp_article_headline' => 'Headline',
|
877 |
+
|
878 |
+
'saswp_article_description' => 'Description',
|
879 |
+
'saswp_article_date_published' => 'Date Published',
|
880 |
+
'saswp_article_date_modified' => 'Date Modified',
|
881 |
+
|
882 |
+
'saswp_article_author_name' => 'Author Name',
|
883 |
+
'saswp_article_organization_name' => 'Organization Name',
|
884 |
+
'saswp_article_organization_logo' => 'Organization Logo',
|
885 |
+
|
886 |
+
);
|
887 |
+
break;
|
888 |
+
|
889 |
+
case 'Recipe':
|
890 |
+
$meta_field = array(
|
891 |
+
'saswp_recipe_url' => 'URL',
|
892 |
+
'saswp_recipe_name' => 'Name',
|
893 |
+
'saswp_recipe_date_published' => 'Date Published',
|
894 |
+
|
895 |
+
'saswp_recipe_date_modified' => 'Date Modified',
|
896 |
+
'saswp_recipe_description' => 'Description',
|
897 |
+
'saswp_recipe_main_entity' => 'Main Entity Id',
|
898 |
+
|
899 |
+
'saswp_recipe_author_name' => 'Author Name',
|
900 |
+
'saswp_recipe_author_image' => 'Author Image',
|
901 |
+
'saswp_recipe_organization_name' => 'Organization Name',
|
902 |
+
|
903 |
+
'saswp_recipe_organization_logo' => 'Organization Logo',
|
904 |
+
'saswp_recipe_preptime' => 'Prepare Time',
|
905 |
+
'saswp_recipe_cooktime' => 'Cook Time',
|
906 |
+
|
907 |
+
'saswp_recipe_totaltime' => 'Total Time',
|
908 |
+
'saswp_recipe_keywords' => 'Keywords',
|
909 |
+
'saswp_recipe_recipeyield' => 'Recipe Yield',
|
910 |
+
|
911 |
+
'saswp_recipe_category' => 'Recipe Category',
|
912 |
+
'saswp_recipe_cuisine' => 'Recipe Cuisine',
|
913 |
+
'saswp_recipe_nutrition' => 'Nutrition',
|
914 |
+
|
915 |
+
'saswp_recipe_ingredient' => 'Recipe Ingredient',
|
916 |
+
'saswp_recipe_instructions' => 'Recipe Instructions',
|
917 |
+
'saswp_recipe_video_name' => 'Video Name',
|
918 |
+
|
919 |
+
'saswp_recipe_video_description' => 'Video Description',
|
920 |
+
'saswp_recipe_video_thumbnailurl' => 'Video ThumbnailUrl',
|
921 |
+
'saswp_recipe_video_contenturl' => 'Video ContentUrl',
|
922 |
+
|
923 |
+
'saswp_recipe_video_embedurl' => 'Video EmbedUrl',
|
924 |
+
'saswp_recipe_video_upload_date' => 'Video Upload Date',
|
925 |
+
'saswp_recipe_video_duration' => 'Video Duration',
|
926 |
+
);
|
927 |
+
|
928 |
+
break;
|
929 |
+
|
930 |
+
case 'Product':
|
931 |
+
|
932 |
+
$meta_field = array(
|
933 |
+
'saswp_product_url' => 'URL',
|
934 |
+
'saswp_product_name' => 'Name',
|
935 |
+
'saswp_product_description' => 'Description',
|
936 |
+
);
|
937 |
+
if(is_plugin_active('woocommerce/woocommerce.php')){
|
938 |
+
$meta_field['saswp_product_image'] = 'Image';
|
939 |
+
$meta_field['saswp_product_availability'] = 'Availability';
|
940 |
+
$meta_field['saswp_product_price'] = 'Price';
|
941 |
+
$meta_field['saswp_product_currency'] = 'Price Currency';
|
942 |
+
|
943 |
+
$meta_field['saswp_product_brand'] = 'Brand';
|
944 |
+
$meta_field['saswp_product_priceValidUntil'] = 'Price Valid Until';
|
945 |
+
$meta_field['saswp_product_isbn'] = 'ISBN';
|
946 |
+
$meta_field['saswp_product_mpn'] = 'MPN';
|
947 |
+
$meta_field['saswp_product_gtin8'] = 'GTIN 8';
|
948 |
+
}
|
949 |
+
break;
|
950 |
+
|
951 |
+
case 'Service':
|
952 |
+
|
953 |
+
$meta_field = array(
|
954 |
+
'saswp_service_schema_name' => 'Name',
|
955 |
+
'saswp_service_schema_type' => 'Service Type',
|
956 |
+
'saswp_service_schema_provider_name' => 'Provider Name',
|
957 |
+
'saswp_service_schema_image' => 'Image',
|
958 |
+
'saswp_service_schema_locality' => 'Locality',
|
959 |
+
'saswp_service_schema_postal_code' => 'Postal Code',
|
960 |
+
'saswp_service_schema_telephone' => 'Telephone',
|
961 |
+
'saswp_service_schema_price_range' => 'Price Range',
|
962 |
+
'saswp_service_schema_description' => 'Description',
|
963 |
+
'saswp_service_schema_area_served' => 'Area Served (City)',
|
964 |
+
'saswp_service_schema_service_offer' => 'Service Offer',
|
965 |
+
'saswp_review_schema_country' => 'Address Country',
|
966 |
+
'saswp_review_schema_telephone' => 'Telephone',
|
967 |
+
);
|
968 |
+
|
969 |
+
break;
|
970 |
+
|
971 |
+
case 'Review':
|
972 |
+
$meta_field = array(
|
973 |
+
|
974 |
+
'saswp_review_schema_item_type' => 'Item Reviewed Type',
|
975 |
+
'saswp_review_schema_name' => 'Name',
|
976 |
+
'saswp_review_schema_description' => 'Description',
|
977 |
+
'saswp_review_schema_date_published' => 'Date Published',
|
978 |
+
'saswp_review_schema_date_modified' => 'Date Modified',
|
979 |
+
'saswp_review_schema_image' => 'Image',
|
980 |
+
'saswp_review_schema_price_range' => 'Price Range',
|
981 |
+
'saswp_review_schema_street_address' => 'Street Address',
|
982 |
+
'saswp_review_schema_locality' => 'Address Locality',
|
983 |
+
'saswp_review_schema_region' => 'Address Region',
|
984 |
+
'saswp_review_schema_postal_code' => 'Postal Code',
|
985 |
+
'saswp_review_schema_country' => 'Address Country',
|
986 |
+
'saswp_review_schema_telephone' => 'Telephone',
|
987 |
+
);
|
988 |
+
break;
|
989 |
+
|
990 |
+
case 'VideoObject':
|
991 |
+
|
992 |
+
$meta_field = array(
|
993 |
+
|
994 |
+
'saswp_video_object_url' => 'URL',
|
995 |
+
'saswp_video_object_headline' => 'Headline',
|
996 |
+
'saswp_video_object_date_published' => 'Date Published',
|
997 |
+
'saswp_video_object_date_modified' => 'Date Modified',
|
998 |
+
'saswp_video_object_description' => 'Description',
|
999 |
+
'saswp_video_object_name' => 'Name',
|
1000 |
+
'saswp_video_object_upload_date' => 'Upload Date',
|
1001 |
+
'saswp_video_object_thumbnail_url' => 'Thumbnail Url',
|
1002 |
+
'saswp_video_object_main_entity_id' => 'Main Entity Id',
|
1003 |
+
'saswp_video_object_author_name' => 'Author Name',
|
1004 |
+
'saswp_video_object_author_image' => 'Author Image',
|
1005 |
+
'saswp_video_object_organization_name' => 'Organization Name',
|
1006 |
+
'saswp_video_object_organization_logo' => 'Organization Logo',
|
1007 |
+
);
|
1008 |
+
|
1009 |
+
break;
|
1010 |
+
|
1011 |
+
case 'qanda':
|
1012 |
+
$meta_field = array(
|
1013 |
+
|
1014 |
+
'saswp_qa_question_title' => 'Question Title',
|
1015 |
+
'saswp_qa_question_description' => 'Question Description',
|
1016 |
+
'saswp_qa_upvote_count' => 'Question Upvote Count',
|
1017 |
+
'saswp_qa_date_created' => 'Question Date Created',
|
1018 |
+
'saswp_qa_question_author_name' => 'Author Name',
|
1019 |
+
'saswp_qa_accepted_answer_text' => 'Accepted Answer Text',
|
1020 |
+
'saswp_qa_accepted_answer_date_created' => 'Accepted Answer Date Created',
|
1021 |
+
'saswp_qa_accepted_answer_upvote_count' => 'Accepted Answer Upvote Count',
|
1022 |
+
'saswp_qa_accepted_answer_url' => 'Accepted Answer Url',
|
1023 |
+
'saswp_qa_accepted_author_name' => 'Accepted Answer Author Name',
|
1024 |
+
'saswp_qa_suggested_answer_text' => 'Suggested Answer Text',
|
1025 |
+
'saswp_qa_suggested_answer_date_created' => 'Suggested Answer Date Created',
|
1026 |
+
'saswp_qa_suggested_answer_upvote_count' => 'Suggested Answer Upvote Count',
|
1027 |
+
'saswp_qa_suggested_answer_url' => 'Suggested Answer Url',
|
1028 |
+
'saswp_qa_suggested_author_name' => 'Suggested Answer Author Name',
|
1029 |
+
|
1030 |
+
);
|
1031 |
+
break;
|
1032 |
+
|
1033 |
+
default:
|
1034 |
+
break;
|
1035 |
+
}
|
1036 |
+
return $meta_field;
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
}
|
1040 |
+
if (class_exists('saswp_output_service')) {
|
1041 |
+
$object = new saswp_output_service();
|
1042 |
+
$object->saswp_service_hooks();
|
1043 |
+
};
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
=== Schema & Structured Data for WP & AMP ===
|
2 |
Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
|
3 |
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.9.8
|
6 |
-
Stable tag: 1.0.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -65,6 +65,20 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
|
|
65 |
|
66 |
== Changelog ==
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
= 1.0.5 (30 November 2018) =
|
69 |
|
70 |
* New Feature: Service schema type add to the schema type list
|
@@ -78,11 +92,6 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
|
|
78 |
* Bug Fixed: Load review css only when review is enable for that post. #67
|
79 |
* Menified review css in amp to put under amp css limitation.
|
80 |
|
81 |
-
= 1.0.5 (26 November 2018) =
|
82 |
-
* Major Feature: Post Specific Meta boxes to override the schemas on posts
|
83 |
-
* Major Feature: Rich Snippets for Reviews and Ratings
|
84 |
-
* Security and other bug fixed
|
85 |
-
|
86 |
= 1.0.4 (16 November 2018) =
|
87 |
* Major Feature: Post Specific Meta boxes to override the schemas on posts
|
88 |
* Major Feature: Rich Snippets for Reviews and Ratings
|
1 |
+
=== Schema & Structured Data for WP & AMP ===
|
2 |
Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
|
3 |
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.9.8
|
6 |
+
Stable tag: 1.0.6
|
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.6 (14 December 2018) =
|
69 |
+
|
70 |
+
* New Feature: Review schema type add to the schema type list
|
71 |
+
* New Feature: Compatibility with Extra theme by Elegant Themes ( https://www.elegantthemes.com ) , Now extra theme built in review and rating will be indexed in google after enabling option
|
72 |
+
* New Feature: Compatibility with WooCommerce ( https://wordpress.org/plugins/woocommerce ), Now the product schema with its WooCommerce product details will be indexed in google search
|
73 |
+
* New Feature: Q&A schema type add to the schema type list, Currently it is compatible with DW Question & Answer plugin ( https://wordpress.org/plugins/dw-question-answer )
|
74 |
+
* New Feature: Modify Schema output, custom fields can be selected for schema fields
|
75 |
+
* Improvement: Different opening and closing hours for different days of the week in local business schema type
|
76 |
+
* Improvement: Now post specific modify schema will support on page and custom post type
|
77 |
+
* Improvement: Added missing recipe fields in the post specific metabox #81
|
78 |
+
* Bug Fixed: Compatibility issue with the Blackbar plugin #83
|
79 |
+
* Bug Fixed: Restore schema button was not working on first load #81
|
80 |
+
|
81 |
+
|
82 |
= 1.0.5 (30 November 2018) =
|
83 |
|
84 |
* New Feature: Service schema type add to the schema type list
|
92 |
* Bug Fixed: Load review css only when review is enable for that post. #67
|
93 |
* Menified review css in amp to put under amp css limitation.
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
= 1.0.4 (16 November 2018) =
|
96 |
* Major Feature: Post Specific Meta boxes to override the schemas on posts
|
97 |
* Major Feature: Rich Snippets for Reviews and Ratings
|
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.
|
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.
|
16 |
define('SASWP_DIR_NAME_FILE', __FILE__ );
|
17 |
define('SASWP_DIR_NAME', dirname( __FILE__ ));
|
18 |
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
|
@@ -58,7 +58,8 @@ require_once SASWP_DIR_NAME.'/view/paywall.php';
|
|
58 |
require_once SASWP_DIR_NAME.'/admin_section/add-schema/add_new.php';
|
59 |
require_once SASWP_DIR_NAME.'/view/post_specific.php';
|
60 |
require_once SASWP_DIR_NAME.'/view/review.php';
|
61 |
-
require_once SASWP_DIR_NAME.'/output/review-output.php';
|
|
|
62 |
|
63 |
|
64 |
/**
|
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.6
|
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.6');
|
16 |
define('SASWP_DIR_NAME_FILE', __FILE__ );
|
17 |
define('SASWP_DIR_NAME', dirname( __FILE__ ));
|
18 |
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
|
58 |
require_once SASWP_DIR_NAME.'/admin_section/add-schema/add_new.php';
|
59 |
require_once SASWP_DIR_NAME.'/view/post_specific.php';
|
60 |
require_once SASWP_DIR_NAME.'/view/review.php';
|
61 |
+
require_once SASWP_DIR_NAME.'/output/review-output.php';
|
62 |
+
require_once SASWP_DIR_NAME.'/output/service.php';
|
63 |
|
64 |
|
65 |
/**
|
view/paywall.php
CHANGED
@@ -26,6 +26,7 @@
|
|
26 |
function saswp_schema_options_meta_box_callback( $post) {
|
27 |
wp_nonce_field( 'saswp_schema_options_nonce', 'saswp_schema_options_nonce' );
|
28 |
$schema_options = esc_sql ( get_post_meta($post->ID, 'schema_options', true) );
|
|
|
29 |
?>
|
30 |
<style type="text/css">
|
31 |
.option-table-class{width:100%;}
|
@@ -38,7 +39,7 @@
|
|
38 |
<table class="option-table-class">
|
39 |
<tbody>
|
40 |
<tr>
|
41 |
-
|
42 |
<td><input type="checkbox" id="notAccessibleForFree" name="notAccessibleForFree" value="1" <?php if(isset($schema_options['notAccessibleForFree']) && $schema_options['notAccessibleForFree']==1){echo 'checked'; }?>>
|
43 |
</td>
|
44 |
</tr>
|
@@ -58,9 +59,61 @@
|
|
58 |
<td><input type="text" id="paywall_class_name" name="paywall_class_name" value="<?php if( isset($schema_options['paywall_class_name']) ){echo esc_attr($schema_options['paywall_class_name']); }?>"></td>
|
59 |
</tr>
|
60 |
</tbody>
|
61 |
-
|
62 |
-
|
63 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
<?php
|
65 |
}
|
66 |
|
@@ -68,19 +121,31 @@
|
|
68 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
69 |
if ( ! isset( $_POST['saswp_schema_options_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_schema_options_nonce'], 'saswp_schema_options_nonce' ) ) return;
|
70 |
if ( ! current_user_can( 'edit_post', $post_id ) ) return;
|
71 |
-
|
72 |
$notAccessibleForFree ='';
|
73 |
$isAccessibleForFree ='';
|
74 |
$paywall_class_name ='';
|
|
|
|
|
75 |
if ( isset( $_POST['notAccessibleForFree'] ) )
|
76 |
-
$notAccessibleForFree = $_POST['notAccessibleForFree'];
|
77 |
if ( isset( $_POST['isAccessibleForFree'] ) )
|
78 |
-
$isAccessibleForFree = $_POST['isAccessibleForFree'];
|
79 |
if ( isset( $_POST['paywall_class_name'] ) )
|
80 |
-
$paywall_class_name = $_POST['paywall_class_name'];
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
$saswp_schema_options = array(
|
|
|
|
|
|
|
|
|
|
|
83 |
update_post_meta( $post_id, 'schema_options', $saswp_schema_options);
|
|
|
84 |
|
85 |
|
86 |
}
|
26 |
function saswp_schema_options_meta_box_callback( $post) {
|
27 |
wp_nonce_field( 'saswp_schema_options_nonce', 'saswp_schema_options_nonce' );
|
28 |
$schema_options = esc_sql ( get_post_meta($post->ID, 'schema_options', true) );
|
29 |
+
$custom_fields = esc_sql ( get_post_meta($post->ID, 'saswp_custom_fields', true) );
|
30 |
?>
|
31 |
<style type="text/css">
|
32 |
.option-table-class{width:100%;}
|
39 |
<table class="option-table-class">
|
40 |
<tbody>
|
41 |
<tr>
|
42 |
+
<td><label for="notAccessibleForFree"><strong><?php echo esc_html__( 'Paywall', 'schema-and-structured-data-for-wp' ) ?></strong></label></td>
|
43 |
<td><input type="checkbox" id="notAccessibleForFree" name="notAccessibleForFree" value="1" <?php if(isset($schema_options['notAccessibleForFree']) && $schema_options['notAccessibleForFree']==1){echo 'checked'; }?>>
|
44 |
</td>
|
45 |
</tr>
|
59 |
<td><input type="text" id="paywall_class_name" name="paywall_class_name" value="<?php if( isset($schema_options['paywall_class_name']) ){echo esc_attr($schema_options['paywall_class_name']); }?>"></td>
|
60 |
</tr>
|
61 |
</tbody>
|
62 |
+
</table>
|
63 |
+
|
64 |
</div>
|
65 |
+
<!-- custom fields for schema output starts here -->
|
66 |
+
|
67 |
+
<div class="misc-pub-section">
|
68 |
+
<table class="option-table-class">
|
69 |
+
<tr><td><label><strong><?php echo esc_html__( 'Modify Schema Output', 'schema-and-structured-data-for-wp' ) ?></strong></label></td><td><input type="checkbox" id="saswp_enable_custom_field" name="saswp_enable_custom_field" value="1" <?php if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field']==1){echo 'checked'; }?>></td></tr>
|
70 |
+
</table>
|
71 |
+
<div class="saswp-custom-fields-div" <?php if(!isset($schema_options['enable_custom_field']) || $schema_options['enable_custom_field'] ==0){echo 'style="display:none;"'; }?>>
|
72 |
+
<table class="option-table-class saswp-custom-fields-table">
|
73 |
+
|
74 |
+
<?php
|
75 |
+
if(!empty($custom_fields)){
|
76 |
+
$schema_type = esc_sql ( get_post_meta($post->ID, 'schema_type', true) );
|
77 |
+
$service = new saswp_output_service();
|
78 |
+
$meta_fields = $service->saswp_get_all_schema_type_fields($schema_type);
|
79 |
+
|
80 |
+
foreach($custom_fields as $fieldkey => $fieldval){
|
81 |
+
|
82 |
+
$option ='';
|
83 |
+
echo '<tr>';
|
84 |
+
echo '<td><select class="saswp-custom-fields-name">';
|
85 |
+
foreach ($meta_fields as $key =>$val){
|
86 |
+
if( $fieldkey == $key){
|
87 |
+
$option .='<option value="'.esc_attr($key).'" selected>'.esc_attr($val).'</option>';
|
88 |
+
}else{
|
89 |
+
$option .='<option value="'.esc_attr($key).'">'.esc_attr($val).'</option>';
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
echo $option;
|
94 |
+
echo '</select></td>';
|
95 |
+
|
96 |
+
echo '<td><select class="saswp-custom-fields-select2" name="saswp_custom_fields['.$fieldkey.']">';
|
97 |
+
echo '<option value="'.esc_attr($fieldval).'">'.preg_replace( '/^_/', '', esc_html( str_replace( '_', ' ', $fieldval ) ) ).'</option>';
|
98 |
+
echo '</select></td>';
|
99 |
+
|
100 |
+
echo '</tr>';
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
?>
|
106 |
+
|
107 |
+
|
108 |
+
</table>
|
109 |
+
<table class="option-table-class">
|
110 |
+
<tr><td></td><td><a style="float:right;" class="button button-primary saswp-add-custom-fields">Add Field</a></td></tr>
|
111 |
+
</table>
|
112 |
+
|
113 |
+
</div>
|
114 |
+
|
115 |
+
</div>
|
116 |
+
<!-- custom fields for schema output ends here -->
|
117 |
<?php
|
118 |
}
|
119 |
|
121 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
122 |
if ( ! isset( $_POST['saswp_schema_options_nonce'] ) || ! wp_verify_nonce( $_POST['saswp_schema_options_nonce'], 'saswp_schema_options_nonce' ) ) return;
|
123 |
if ( ! current_user_can( 'edit_post', $post_id ) ) return;
|
124 |
+
|
125 |
$notAccessibleForFree ='';
|
126 |
$isAccessibleForFree ='';
|
127 |
$paywall_class_name ='';
|
128 |
+
$enable_custom_field ='';
|
129 |
+
$custom_fields ='';
|
130 |
if ( isset( $_POST['notAccessibleForFree'] ) )
|
131 |
+
$notAccessibleForFree = sanitize_text_field($_POST['notAccessibleForFree']);
|
132 |
if ( isset( $_POST['isAccessibleForFree'] ) )
|
133 |
+
$isAccessibleForFree = sanitize_text_field($_POST['isAccessibleForFree']);
|
134 |
if ( isset( $_POST['paywall_class_name'] ) )
|
135 |
+
$paywall_class_name = sanitize_text_field($_POST['paywall_class_name']);
|
136 |
+
if ( isset( $_POST['saswp_enable_custom_field'] ) )
|
137 |
+
$enable_custom_field = sanitize_text_field($_POST['saswp_enable_custom_field']);
|
138 |
+
if ( isset( $_POST['saswp_custom_fields'] ) )
|
139 |
+
$custom_fields = array_map ('sanitize_text_field', $_POST['saswp_custom_fields']);
|
140 |
|
141 |
+
$saswp_schema_options = array(
|
142 |
+
'isAccessibleForFree'=>$isAccessibleForFree,
|
143 |
+
'notAccessibleForFree'=>$notAccessibleForFree,
|
144 |
+
'paywall_class_name'=>$paywall_class_name,
|
145 |
+
'enable_custom_field' => $enable_custom_field
|
146 |
+
);
|
147 |
update_post_meta( $post_id, 'schema_options', $saswp_schema_options);
|
148 |
+
update_post_meta( $post_id, 'saswp_custom_fields', $custom_fields);
|
149 |
|
150 |
|
151 |
}
|
view/post_specific.php
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
<?php
|
2 |
class saswp_post_specific {
|
3 |
-
private $screen = array(
|
4 |
-
'post',
|
5 |
-
'page'
|
6 |
-
);
|
7 |
private $meta_fields = array(
|
8 |
|
9 |
);
|
@@ -40,7 +37,17 @@ class saswp_post_specific {
|
|
40 |
}
|
41 |
|
42 |
public function saswp_post_specifc_add_meta_boxes($post) {
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
foreach ( $this->screen as $single_screen ) {
|
45 |
$post_title ='';
|
46 |
if(count($this->all_schema)==1){
|
@@ -61,10 +68,10 @@ class saswp_post_specific {
|
|
61 |
}
|
62 |
|
63 |
public function saswp_post_meta_box_fields($post){
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
foreach($this->all_schema as $key => $schema){
|
69 |
$response = $this->saswp_get_fields_by_schema_type($schema->ID);
|
70 |
$this->meta_fields = $response;
|
@@ -85,7 +92,7 @@ class saswp_post_specific {
|
|
85 |
}
|
86 |
|
87 |
echo '<div>';
|
88 |
-
echo '<div><a href="#" class="saswp-restore-post-schema button">Restore Default
|
89 |
echo '<div class="saswp-tab saswp-post-specific-tab-wrapper">';
|
90 |
echo '<ul class="saswp-tab-nav">';
|
91 |
echo $tabs;
|
@@ -107,7 +114,7 @@ class saswp_post_specific {
|
|
107 |
$this->meta_fields = $response;
|
108 |
$output = $this->saswp_saswp_post_specific( $post, $all_schema[0]->ID );
|
109 |
$tabs_fields .= '<div>';
|
110 |
-
$tabs_fields .= '<div><a href="#" class="saswp-restore-post-schema button">Restore Default
|
111 |
$tabs_fields .= '<div id="saswp_specific_'.esc_attr($all_schema[0]->ID).'" class="saswp-post-specific-wrapper">';
|
112 |
$tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
|
113 |
$tabs_fields .= '</div>';
|
@@ -144,13 +151,13 @@ class saswp_post_specific {
|
|
144 |
foreach($meta_field as $field){
|
145 |
$result = delete_post_meta($post_id, $field['id']);
|
146 |
}
|
147 |
-
}
|
148 |
-
|
|
|
149 |
echo json_encode(array('status'=> 't', 'msg'=>esc_html__( 'Schema has been restored', 'schema-and-structured-data-for-wp' )));
|
150 |
}else{
|
151 |
echo json_encode(array('status'=> 'f', 'msg'=>esc_html__( 'Schema has already been restored', 'schema-and-structured-data-for-wp' )));
|
152 |
-
}
|
153 |
-
|
154 |
wp_die();
|
155 |
}
|
156 |
|
@@ -194,11 +201,20 @@ class saswp_post_specific {
|
|
194 |
$this->meta_fields = array_filter($this->meta_fields);
|
195 |
foreach ( $this->meta_fields as $meta_field ) {
|
196 |
$input ='';
|
|
|
|
|
197 |
$label = '<label for="' . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
|
198 |
$meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
|
199 |
-
if ( empty( $meta_value ) ) {
|
|
|
200 |
$meta_value = $meta_field['default'];
|
201 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
switch ( $meta_field['type'] ) {
|
203 |
case 'media':
|
204 |
$media_value = array();
|
@@ -225,14 +241,29 @@ class saswp_post_specific {
|
|
225 |
$media_value['width'] = $business_details['local_business_logo']['width'];
|
226 |
$media_value['thumbnail'] = $business_details['local_business_logo']['url'];
|
227 |
}
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
$input = sprintf(
|
230 |
'<fieldset><input style="width: 80%%" id="%s" name="%s" type="text" value="%s">'
|
231 |
. '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
|
232 |
// . '<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']).'">'
|
233 |
-
. '<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($
|
234 |
-
. '<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($
|
235 |
-
. '<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($
|
236 |
.'</fieldset>',
|
237 |
$meta_field['id'],
|
238 |
$meta_field['id'],
|
@@ -313,11 +344,15 @@ class saswp_post_specific {
|
|
313 |
|
314 |
case 'textarea':
|
315 |
$input = sprintf(
|
316 |
-
'<textarea style="width: 100%%" id="%s" name="%s" rows="5">%s</textarea>',
|
|
|
317 |
$meta_field['id'],
|
318 |
$meta_field['id'],
|
319 |
$meta_value
|
320 |
);
|
|
|
|
|
|
|
321 |
break;
|
322 |
case 'text':
|
323 |
case 'number':
|
@@ -325,11 +360,13 @@ class saswp_post_specific {
|
|
325 |
if (strpos($meta_field['id'], 'closes_time') !== false || strpos($meta_field['id'], 'opens_time') !== false){
|
326 |
$class='saswp-local-schema-time-picker';
|
327 |
}
|
328 |
-
if (strpos($meta_field['id'], 'date_modified') !== false || strpos($meta_field['id'], 'date_published') !== false){
|
329 |
$class='saswp-local-schema-datepicker-picker';
|
330 |
}
|
|
|
331 |
$input = sprintf(
|
332 |
-
'<input class="%s" %s id="%s" name="%s" type="%s" value="%s">',
|
|
|
333 |
$class,
|
334 |
$meta_field['type'] !== 'color' ? 'style="width: 100%"' : '',
|
335 |
$meta_field['id'],
|
@@ -337,6 +374,9 @@ class saswp_post_specific {
|
|
337 |
$meta_field['type'],
|
338 |
$meta_value
|
339 |
);
|
|
|
|
|
|
|
340 |
break;
|
341 |
|
342 |
default:
|
@@ -368,7 +408,7 @@ class saswp_post_specific {
|
|
368 |
if ( isset( $_POST[ $meta_field['id'] ] ) ) {
|
369 |
switch ( $meta_field['type'] ) {
|
370 |
case 'media':
|
371 |
-
$media_key = $meta_field['id'].'
|
372 |
//$media_id = sanitize_text_field( $_POST[ $meta_field['id'].'_id' ] );
|
373 |
$media_height = sanitize_text_field( $_POST[ $meta_field['id'].'_height' ] );
|
374 |
$media_width = sanitize_text_field( $_POST[ $meta_field['id'].'_width' ] );
|
@@ -579,6 +619,7 @@ class saswp_post_specific {
|
|
579 |
$business_type = esc_sql ( get_post_meta($schema_id, 'saswp_business_type', true) );
|
580 |
$business_name = esc_sql ( get_post_meta($schema_id, 'saswp_business_name', true) );
|
581 |
$business_details = esc_sql ( get_post_meta($schema_id, 'saswp_local_business_details', true) );
|
|
|
582 |
$saswp_business_type_key = 'saswp_business_type_'.$schema_id;
|
583 |
$saved_business_type = get_post_meta( $post->ID, $saswp_business_type_key, true );
|
584 |
$saved_saswp_business_name = get_post_meta( $post->ID, 'saswp_business_name_'.$schema_id, true );
|
@@ -744,30 +785,9 @@ class saswp_post_specific {
|
|
744 |
array(
|
745 |
'label' => 'Operation Days',
|
746 |
'id' => 'saswp_dayofweek_'.$schema_id,
|
747 |
-
'type' => '
|
748 |
-
'
|
749 |
-
|
750 |
-
'tuesday' => 'Tuesday',
|
751 |
-
'wednesday' => 'Wednesday',
|
752 |
-
'thursday' => 'Thursday',
|
753 |
-
'friday' => 'Friday',
|
754 |
-
'staturday' => 'Staturday',
|
755 |
-
'sunday' => 'Sunday',
|
756 |
-
),
|
757 |
-
'default' => $business_details['saswp_dayofweek']
|
758 |
-
),
|
759 |
-
array(
|
760 |
-
'label' => 'Opens',
|
761 |
-
'id' => 'local_opens_time_'.$schema_id,
|
762 |
-
'type' => 'text',
|
763 |
-
'default' => $business_details['local_opens_time']
|
764 |
-
),
|
765 |
-
array(
|
766 |
-
'label' => 'Closes',
|
767 |
-
'id' => 'local_closes_time_'.$schema_id,
|
768 |
-
'type' => 'text',
|
769 |
-
'default' => $business_details['local_closes_time']
|
770 |
-
),
|
771 |
array(
|
772 |
'label' => 'Price Range',
|
773 |
'id' => 'local_price_range_'.$schema_id,
|
@@ -996,12 +1016,7 @@ class saswp_post_specific {
|
|
996 |
'type' => 'text',
|
997 |
'default' => get_the_title(),
|
998 |
),
|
999 |
-
|
1000 |
-
'label' => 'Description',
|
1001 |
-
'id' => 'saswp_webpage_description_'.$schema_id,
|
1002 |
-
'type' => 'textarea',
|
1003 |
-
'default' => $post->post_excerpt
|
1004 |
-
),
|
1005 |
array(
|
1006 |
'label' => 'Date Published',
|
1007 |
'id' => 'saswp_webpage_date_published_'.$schema_id,
|
@@ -1155,11 +1170,151 @@ class saswp_post_specific {
|
|
1155 |
'id' => 'saswp_recipe_organization_logo_'.$schema_id,
|
1156 |
'type' => 'media',
|
1157 |
'default' => $sd_data['sd_logo']['url']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1159 |
);
|
1160 |
break;
|
1161 |
|
1162 |
case 'Product':
|
|
|
|
|
|
|
|
|
1163 |
$meta_field = array(
|
1164 |
array(
|
1165 |
'label' => 'URL',
|
@@ -1180,6 +1335,72 @@ class saswp_post_specific {
|
|
1180 |
'default' => $post->post_excerpt
|
1181 |
),
|
1182 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1183 |
break;
|
1184 |
|
1185 |
case 'Service':
|
@@ -1240,16 +1461,109 @@ class saswp_post_specific {
|
|
1240 |
'default' => $service_schema_details['saswp_service_schema_description']
|
1241 |
),
|
1242 |
array(
|
1243 |
-
'label' => 'Area Served',
|
1244 |
'id' => 'saswp_service_schema_area_served_'.$schema_id,
|
1245 |
'type' => 'textarea',
|
1246 |
-
'default' => $service_schema_details['saswp_service_schema_area_served']
|
|
|
|
|
|
|
|
|
1247 |
),
|
1248 |
array(
|
1249 |
'label' => 'Service Offer',
|
1250 |
'id' => 'saswp_service_schema_service_offer_'.$schema_id,
|
1251 |
'type' => 'textarea',
|
1252 |
-
'default' => $service_schema_details['saswp_service_schema_service_offer']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1253 |
),
|
1254 |
);
|
1255 |
break;
|
@@ -1337,6 +1651,88 @@ class saswp_post_specific {
|
|
1337 |
);
|
1338 |
break;
|
1339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1340 |
default:
|
1341 |
break;
|
1342 |
}
|
1 |
<?php
|
2 |
class saswp_post_specific {
|
3 |
+
private $screen = array();
|
|
|
|
|
|
|
4 |
private $meta_fields = array(
|
5 |
|
6 |
);
|
37 |
}
|
38 |
|
39 |
public function saswp_post_specifc_add_meta_boxes($post) {
|
40 |
+
|
41 |
+
$post_specific_id = '';
|
42 |
+
if(is_object($post)){
|
43 |
+
$post_specific_id = $post->ID;
|
44 |
+
}
|
45 |
+
if(count($this->all_schema)>0 && get_post_status($post_specific_id)=='publish'){
|
46 |
+
|
47 |
+
$show_post_types = get_post_types();
|
48 |
+
unset($show_post_types['adsforwp'],$show_post_types['saswp'],$show_post_types['attachment'], $show_post_types['revision'], $show_post_types['nav_menu_item'], $show_post_types['user_request'], $show_post_types['custom_css']);
|
49 |
+
$this->screen = $show_post_types;
|
50 |
+
|
51 |
foreach ( $this->screen as $single_screen ) {
|
52 |
$post_title ='';
|
53 |
if(count($this->all_schema)==1){
|
68 |
}
|
69 |
|
70 |
public function saswp_post_meta_box_fields($post){
|
71 |
+
$tabs = '';
|
72 |
+
$tabs_fields = '';
|
73 |
+
$schema_ids = array();
|
74 |
+
if(count($this->all_schema)>1){
|
75 |
foreach($this->all_schema as $key => $schema){
|
76 |
$response = $this->saswp_get_fields_by_schema_type($schema->ID);
|
77 |
$this->meta_fields = $response;
|
92 |
}
|
93 |
|
94 |
echo '<div>';
|
95 |
+
echo '<div><a href="#" class="saswp-restore-post-schema button">'.esc_html__( 'Restore Default Schema', 'schema-and-structured-data-for-wp' ).'</a></div>';
|
96 |
echo '<div class="saswp-tab saswp-post-specific-tab-wrapper">';
|
97 |
echo '<ul class="saswp-tab-nav">';
|
98 |
echo $tabs;
|
114 |
$this->meta_fields = $response;
|
115 |
$output = $this->saswp_saswp_post_specific( $post, $all_schema[0]->ID );
|
116 |
$tabs_fields .= '<div>';
|
117 |
+
$tabs_fields .= '<div><a href="#" class="saswp-restore-post-schema button">'.esc_html__( 'Restore Default Schema', 'schema-and-structured-data-for-wp' ).'</a></div>';
|
118 |
$tabs_fields .= '<div id="saswp_specific_'.esc_attr($all_schema[0]->ID).'" class="saswp-post-specific-wrapper">';
|
119 |
$tabs_fields .= '<table class="form-table"><tbody>' . $output . '</tbody></table>';
|
120 |
$tabs_fields .= '</div>';
|
151 |
foreach($meta_field as $field){
|
152 |
$result = delete_post_meta($post_id, $field['id']);
|
153 |
}
|
154 |
+
}
|
155 |
+
update_option('modify_schema_post_enable_'.$post_id, 'disable');
|
156 |
+
if($result){
|
157 |
echo json_encode(array('status'=> 't', 'msg'=>esc_html__( 'Schema has been restored', 'schema-and-structured-data-for-wp' )));
|
158 |
}else{
|
159 |
echo json_encode(array('status'=> 'f', 'msg'=>esc_html__( 'Schema has already been restored', 'schema-and-structured-data-for-wp' )));
|
160 |
+
}
|
|
|
161 |
wp_die();
|
162 |
}
|
163 |
|
201 |
$this->meta_fields = array_filter($this->meta_fields);
|
202 |
foreach ( $this->meta_fields as $meta_field ) {
|
203 |
$input ='';
|
204 |
+
$attributes ='';
|
205 |
+
|
206 |
$label = '<label for="' . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
|
207 |
$meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
|
208 |
+
if ( empty( $meta_value ) && isset($meta_field['default'])) {
|
209 |
+
|
210 |
$meta_value = $meta_field['default'];
|
211 |
}
|
212 |
+
if(isset($meta_field['attributes'])){
|
213 |
+
foreach ($meta_field['attributes'] as $key => $attr ){
|
214 |
+
$attributes .=''.$key.'="'.$attr.'"';
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
switch ( $meta_field['type'] ) {
|
219 |
case 'media':
|
220 |
$media_value = array();
|
241 |
$media_value['width'] = $business_details['local_business_logo']['width'];
|
242 |
$media_value['thumbnail'] = $business_details['local_business_logo']['url'];
|
243 |
}
|
244 |
+
|
245 |
+
$media_height ='';
|
246 |
+
$media_width ='';
|
247 |
+
$media_thumbnail ='';
|
248 |
+
|
249 |
+
if(isset($media_value['thumbnail'])){
|
250 |
+
$media_thumbnail =$media_value['thumbnail'];
|
251 |
+
}
|
252 |
+
if(isset($media_value['height'])){
|
253 |
+
$media_height =$media_value['height'];
|
254 |
+
}
|
255 |
+
if(isset($media_value['width'])){
|
256 |
+
$media_width =$media_value['width'];
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
$input = sprintf(
|
261 |
'<fieldset><input style="width: 80%%" id="%s" name="%s" type="text" value="%s">'
|
262 |
. '<input data-id="media" style="width: 19%%" class="button" id="%s_button" name="%s_button" type="button" value="Upload" />'
|
263 |
// . '<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']).'">'
|
264 |
+
. '<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_height).'">'
|
265 |
+
. '<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_width).'">'
|
266 |
+
. '<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_thumbnail).'">'
|
267 |
.'</fieldset>',
|
268 |
$meta_field['id'],
|
269 |
$meta_field['id'],
|
344 |
|
345 |
case 'textarea':
|
346 |
$input = sprintf(
|
347 |
+
'<textarea %s style="width: 100%%" id="%s" name="%s" rows="5">%s</textarea>',
|
348 |
+
$attributes,
|
349 |
$meta_field['id'],
|
350 |
$meta_field['id'],
|
351 |
$meta_value
|
352 |
);
|
353 |
+
if(isset($meta_field['note'])){
|
354 |
+
$input .='<p>'.$meta_field['note'].'</p>';
|
355 |
+
}
|
356 |
break;
|
357 |
case 'text':
|
358 |
case 'number':
|
360 |
if (strpos($meta_field['id'], 'closes_time') !== false || strpos($meta_field['id'], 'opens_time') !== false){
|
361 |
$class='saswp-local-schema-time-picker';
|
362 |
}
|
363 |
+
if (strpos($meta_field['id'], 'date_modified') !== false || strpos($meta_field['id'], 'date_published') !== false || strpos($meta_field['id'], 'video_upload_date') !== false|| strpos($meta_field['id'], 'qa_date_created') !== false || strpos($meta_field['id'], 'accepted_answer_date_created') !== false || strpos($meta_field['id'], 'suggested_answer_date_created') !== false || strpos($meta_field['id'], 'priceValidUntil') !== false) {
|
364 |
$class='saswp-local-schema-datepicker-picker';
|
365 |
}
|
366 |
+
|
367 |
$input = sprintf(
|
368 |
+
'<input %s class="%s" %s id="%s" name="%s" type="%s" value="%s">',
|
369 |
+
$attributes,
|
370 |
$class,
|
371 |
$meta_field['type'] !== 'color' ? 'style="width: 100%"' : '',
|
372 |
$meta_field['id'],
|
374 |
$meta_field['type'],
|
375 |
$meta_value
|
376 |
);
|
377 |
+
if(isset($meta_field['note'])){
|
378 |
+
$input .='<p>'.$meta_field['note'].'</p>';
|
379 |
+
}
|
380 |
break;
|
381 |
|
382 |
default:
|
408 |
if ( isset( $_POST[ $meta_field['id'] ] ) ) {
|
409 |
switch ( $meta_field['type'] ) {
|
410 |
case 'media':
|
411 |
+
$media_key = $meta_field['id'].'_detail';
|
412 |
//$media_id = sanitize_text_field( $_POST[ $meta_field['id'].'_id' ] );
|
413 |
$media_height = sanitize_text_field( $_POST[ $meta_field['id'].'_height' ] );
|
414 |
$media_width = sanitize_text_field( $_POST[ $meta_field['id'].'_width' ] );
|
619 |
$business_type = esc_sql ( get_post_meta($schema_id, 'saswp_business_type', true) );
|
620 |
$business_name = esc_sql ( get_post_meta($schema_id, 'saswp_business_name', true) );
|
621 |
$business_details = esc_sql ( get_post_meta($schema_id, 'saswp_local_business_details', true) );
|
622 |
+
$dayoftheweek = get_post_meta ($schema_id, 'saswp_dayofweek', true);
|
623 |
$saswp_business_type_key = 'saswp_business_type_'.$schema_id;
|
624 |
$saved_business_type = get_post_meta( $post->ID, $saswp_business_type_key, true );
|
625 |
$saved_saswp_business_name = get_post_meta( $post->ID, 'saswp_business_name_'.$schema_id, true );
|
785 |
array(
|
786 |
'label' => 'Operation Days',
|
787 |
'id' => 'saswp_dayofweek_'.$schema_id,
|
788 |
+
'type' => 'textarea',
|
789 |
+
'default' => $dayoftheweek
|
790 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
array(
|
792 |
'label' => 'Price Range',
|
793 |
'id' => 'local_price_range_'.$schema_id,
|
1016 |
'type' => 'text',
|
1017 |
'default' => get_the_title(),
|
1018 |
),
|
1019 |
+
|
|
|
|
|
|
|
|
|
|
|
1020 |
array(
|
1021 |
'label' => 'Date Published',
|
1022 |
'id' => 'saswp_webpage_date_published_'.$schema_id,
|
1170 |
'id' => 'saswp_recipe_organization_logo_'.$schema_id,
|
1171 |
'type' => 'media',
|
1172 |
'default' => $sd_data['sd_logo']['url']
|
1173 |
+
),
|
1174 |
+
array(
|
1175 |
+
'label' => 'Prepare Time',
|
1176 |
+
'id' => 'saswp_recipe_preptime_'.$schema_id,
|
1177 |
+
'type' => 'text',
|
1178 |
+
'attributes' => array(
|
1179 |
+
'placeholder' => 'PT20M'
|
1180 |
+
),
|
1181 |
),
|
1182 |
+
array(
|
1183 |
+
'label' => 'Cook Time',
|
1184 |
+
'id' => 'saswp_recipe_cooktime_'.$schema_id,
|
1185 |
+
'type' => 'text',
|
1186 |
+
'attributes' => array(
|
1187 |
+
'placeholder' => 'PT30M'
|
1188 |
+
),
|
1189 |
+
),
|
1190 |
+
array(
|
1191 |
+
'label' => 'Total Time',
|
1192 |
+
'id' => 'saswp_recipe_totaltime_'.$schema_id,
|
1193 |
+
'type' => 'text',
|
1194 |
+
'attributes' => array(
|
1195 |
+
'placeholder' => 'PT50M'
|
1196 |
+
),
|
1197 |
+
),
|
1198 |
+
array(
|
1199 |
+
'label' => 'Keywords',
|
1200 |
+
'id' => 'saswp_recipe_keywords_'.$schema_id,
|
1201 |
+
'type' => 'text',
|
1202 |
+
'attributes' => array(
|
1203 |
+
'placeholder' => 'cake for a party, coffee'
|
1204 |
+
),
|
1205 |
+
),
|
1206 |
+
array(
|
1207 |
+
'label' => 'Recipe Yield',
|
1208 |
+
'id' => 'saswp_recipe_recipeyield_'.$schema_id,
|
1209 |
+
'type' => 'text',
|
1210 |
+
'attributes' => array(
|
1211 |
+
'placeholder' => '10 servings'
|
1212 |
+
),
|
1213 |
+
),
|
1214 |
+
array(
|
1215 |
+
'label' => 'Recipe Category',
|
1216 |
+
'id' => 'saswp_recipe_category_'.$schema_id,
|
1217 |
+
'type' => 'text',
|
1218 |
+
'attributes' => array(
|
1219 |
+
'placeholder' => 'Dessert'
|
1220 |
+
),
|
1221 |
+
),
|
1222 |
+
array(
|
1223 |
+
'label' => 'Recipe Cuisine',
|
1224 |
+
'id' => 'saswp_recipe_cuisine_'.$schema_id,
|
1225 |
+
'type' => 'text',
|
1226 |
+
'attributes' => array(
|
1227 |
+
'placeholder' => 'American'
|
1228 |
+
),
|
1229 |
+
),
|
1230 |
+
array(
|
1231 |
+
'label' => 'Nutrition',
|
1232 |
+
'id' => 'saswp_recipe_nutrition_'.$schema_id,
|
1233 |
+
'type' => 'text',
|
1234 |
+
'attributes' => array(
|
1235 |
+
'placeholder' => '270 calories'
|
1236 |
+
),
|
1237 |
+
),
|
1238 |
+
array(
|
1239 |
+
'label' => 'Recipe Ingredient',
|
1240 |
+
'id' => 'saswp_recipe_ingredient_'.$schema_id,
|
1241 |
+
'type' => 'textarea',
|
1242 |
+
'attributes' => array(
|
1243 |
+
'placeholder' => '2 cups of flour; 3/4 cup white sugar;'
|
1244 |
+
),
|
1245 |
+
'note' => 'Note: Separate Ingredient list by semicolon ( ; )'
|
1246 |
+
),
|
1247 |
+
array(
|
1248 |
+
'label' => 'Recipe Instructions',
|
1249 |
+
'id' => 'saswp_recipe_instructions_'.$schema_id,
|
1250 |
+
'type' => 'textarea',
|
1251 |
+
'attributes' => array(
|
1252 |
+
'placeholder' => 'Preheat the oven to 350 degrees F. Grease and flour a 9x9 inch pan; large bowl, combine flour, sugar, baking powder, and salt. pan.;'
|
1253 |
+
),
|
1254 |
+
'note' => 'Note: Separate Ingredient step by semicolon ( ; )'
|
1255 |
+
),
|
1256 |
+
array(
|
1257 |
+
'label' => 'Video Name',
|
1258 |
+
'id' => 'saswp_recipe_video_name_'.$schema_id,
|
1259 |
+
'type' => 'text',
|
1260 |
+
'attributes' => array(
|
1261 |
+
'placeholder' => 'Video Name'
|
1262 |
+
),
|
1263 |
+
),
|
1264 |
+
array(
|
1265 |
+
'label' => 'Video Description',
|
1266 |
+
'id' => 'saswp_recipe_video_description_'.$schema_id,
|
1267 |
+
'type' => 'text',
|
1268 |
+
'attributes' => array(
|
1269 |
+
'placeholder' => 'Video Description'
|
1270 |
+
),
|
1271 |
+
),
|
1272 |
+
array(
|
1273 |
+
'label' => 'Video ThumbnailUrl',
|
1274 |
+
'id' => 'saswp_recipe_video_thumbnailurl_'.$schema_id,
|
1275 |
+
'type' => 'media',
|
1276 |
+
|
1277 |
+
),
|
1278 |
+
array(
|
1279 |
+
'label' => 'Video ContentUrl',
|
1280 |
+
'id' => 'saswp_recipe_video_contenturl_'.$schema_id,
|
1281 |
+
'type' => 'text',
|
1282 |
+
'attributes' => array(
|
1283 |
+
'placeholder' => 'http://www.example.com/video123.mp4'
|
1284 |
+
),
|
1285 |
+
),
|
1286 |
+
array(
|
1287 |
+
'label' => 'Video EmbedUrl',
|
1288 |
+
'id' => 'saswp_recipe_video_embedurl_'.$schema_id,
|
1289 |
+
'type' => 'text',
|
1290 |
+
'attributes' => array(
|
1291 |
+
'placeholder' => 'http://www.example.com/videoplayer?video=123'
|
1292 |
+
),
|
1293 |
+
),
|
1294 |
+
array(
|
1295 |
+
'label' => 'Video Upload Date',
|
1296 |
+
'id' => 'saswp_recipe_video_upload_date_'.$schema_id,
|
1297 |
+
'type' => 'text',
|
1298 |
+
'attributes' => array(
|
1299 |
+
'placeholder' => '2018-12-18'
|
1300 |
+
),
|
1301 |
+
),
|
1302 |
+
array(
|
1303 |
+
'label' => 'Video Duration',
|
1304 |
+
'id' => 'saswp_recipe_video_duration_'.$schema_id,
|
1305 |
+
'type' => 'text',
|
1306 |
+
'attributes' => array(
|
1307 |
+
'placeholder' => 'PT1M33S'
|
1308 |
+
),
|
1309 |
+
),
|
1310 |
);
|
1311 |
break;
|
1312 |
|
1313 |
case 'Product':
|
1314 |
+
|
1315 |
+
|
1316 |
+
|
1317 |
+
|
1318 |
$meta_field = array(
|
1319 |
array(
|
1320 |
'label' => 'URL',
|
1335 |
'default' => $post->post_excerpt
|
1336 |
),
|
1337 |
);
|
1338 |
+
|
1339 |
+
if(get_post_type() == 'product'){
|
1340 |
+
|
1341 |
+
$meta_field[] = array(
|
1342 |
+
'label' => 'Image',
|
1343 |
+
'id' => 'saswp_product_image_'.$schema_id,
|
1344 |
+
'type' => 'media',
|
1345 |
+
'default' => ''
|
1346 |
+
);
|
1347 |
+
$meta_field[] = array(
|
1348 |
+
'label' => 'Availability',
|
1349 |
+
'id' => 'saswp_product_availability_'.$schema_id,
|
1350 |
+
'type' => 'text',
|
1351 |
+
'default' => ''
|
1352 |
+
);
|
1353 |
+
$meta_field[] = array(
|
1354 |
+
'label' => 'Price',
|
1355 |
+
'id' => 'saswp_product_price_'.$schema_id,
|
1356 |
+
'type' => 'text',
|
1357 |
+
'default' => ''
|
1358 |
+
);
|
1359 |
+
$meta_field[] = array(
|
1360 |
+
'label' => 'Price Currency',
|
1361 |
+
'id' => 'saswp_product_currency_'.$schema_id,
|
1362 |
+
'type' => 'text',
|
1363 |
+
'default' => ''
|
1364 |
+
);
|
1365 |
+
$meta_field[] = array(
|
1366 |
+
'label' => 'SKU',
|
1367 |
+
'id' => 'saswp_product_sku_'.$schema_id,
|
1368 |
+
'type' => 'text',
|
1369 |
+
'default' => ''
|
1370 |
+
);
|
1371 |
+
$meta_field[] = array(
|
1372 |
+
'label' => 'Brand',
|
1373 |
+
'id' => 'saswp_product_brand_'.$schema_id,
|
1374 |
+
'type' => 'text',
|
1375 |
+
'default' => ''
|
1376 |
+
);
|
1377 |
+
$meta_field[] = array(
|
1378 |
+
'label' => 'Price Valid Until',
|
1379 |
+
'id' => 'saswp_product_priceValidUntil_'.$schema_id,
|
1380 |
+
'type' => 'text',
|
1381 |
+
'default' => ''
|
1382 |
+
);
|
1383 |
+
$meta_field[] = array(
|
1384 |
+
'label' => 'MPN',
|
1385 |
+
'id' => 'saswp_product_mpn_'.$schema_id,
|
1386 |
+
'type' => 'text',
|
1387 |
+
'note' => 'OR',
|
1388 |
+
'default' => ''
|
1389 |
+
);
|
1390 |
+
$meta_field[] = array(
|
1391 |
+
'label' => 'ISBN',
|
1392 |
+
'id' => 'saswp_product_isbn_'.$schema_id,
|
1393 |
+
'type' => 'text',
|
1394 |
+
'note' => 'OR',
|
1395 |
+
'default' => ''
|
1396 |
+
);
|
1397 |
+
$meta_field[] = array(
|
1398 |
+
'label' => 'GTIN8',
|
1399 |
+
'id' => 'saswp_product_gtin8_'.$schema_id,
|
1400 |
+
'type' => 'text',
|
1401 |
+
'default' => ''
|
1402 |
+
);
|
1403 |
+
}
|
1404 |
break;
|
1405 |
|
1406 |
case 'Service':
|
1461 |
'default' => $service_schema_details['saswp_service_schema_description']
|
1462 |
),
|
1463 |
array(
|
1464 |
+
'label' => 'Area Served (City)',
|
1465 |
'id' => 'saswp_service_schema_area_served_'.$schema_id,
|
1466 |
'type' => 'textarea',
|
1467 |
+
'default' => $service_schema_details['saswp_service_schema_area_served'],
|
1468 |
+
'note' => 'Note: Enter all the City name in comma separated',
|
1469 |
+
'attributes' => array(
|
1470 |
+
'placeholder' => 'New York, Los Angeles'
|
1471 |
+
),
|
1472 |
),
|
1473 |
array(
|
1474 |
'label' => 'Service Offer',
|
1475 |
'id' => 'saswp_service_schema_service_offer_'.$schema_id,
|
1476 |
'type' => 'textarea',
|
1477 |
+
'default' => $service_schema_details['saswp_service_schema_service_offer'],
|
1478 |
+
'note' => 'Note: Enter all the service offer in comma separated',
|
1479 |
+
'attributes' => array(
|
1480 |
+
'placeholder' => 'Apartment light cleaning, carpet cleaning'
|
1481 |
+
),
|
1482 |
+
),
|
1483 |
+
);
|
1484 |
+
break;
|
1485 |
+
|
1486 |
+
case 'Review':
|
1487 |
+
$service_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_review_schema_details', true) );
|
1488 |
+
$meta_field = array(
|
1489 |
+
array(
|
1490 |
+
'label' => 'Item Reviewed Type',
|
1491 |
+
'id' => 'saswp_review_schema_item_type_'.$schema_id,
|
1492 |
+
'type' => 'text',
|
1493 |
+
'default' => $service_schema_details['saswp_review_schema_item_type']
|
1494 |
+
),
|
1495 |
+
array(
|
1496 |
+
'label' => 'Name',
|
1497 |
+
'id' => 'saswp_review_schema_name_'.$schema_id,
|
1498 |
+
'type' => 'text',
|
1499 |
+
'default' => $service_schema_details['saswp_review_schema_name']
|
1500 |
+
),
|
1501 |
+
array(
|
1502 |
+
'label' => 'Description',
|
1503 |
+
'id' => 'saswp_review_schema_description_'.$schema_id,
|
1504 |
+
'type' => 'textarea',
|
1505 |
+
'default' => $service_schema_details['saswp_review_schema_description']
|
1506 |
+
),
|
1507 |
+
array(
|
1508 |
+
'label' => 'Date Published',
|
1509 |
+
'id' => 'saswp_review_schema_date_published_'.$schema_id,
|
1510 |
+
'type' => 'text',
|
1511 |
+
'default' => get_the_date("Y-m-d")
|
1512 |
+
),
|
1513 |
+
array(
|
1514 |
+
'label' => 'Date Modified',
|
1515 |
+
'id' => 'saswp_review_schema_date_modified_'.$schema_id,
|
1516 |
+
'type' => 'text',
|
1517 |
+
'default' => get_the_modified_date("Y-m-d")
|
1518 |
+
),
|
1519 |
+
array(
|
1520 |
+
'label' => 'Image',
|
1521 |
+
'id' => 'saswp_review_schema_image_'.$schema_id,
|
1522 |
+
'type' => 'media',
|
1523 |
+
'default' => $service_schema_details['saswp_review_schema_image']['url']
|
1524 |
+
),
|
1525 |
+
array(
|
1526 |
+
'label' => 'Price Range',
|
1527 |
+
'id' => 'saswp_review_schema_price_range_'.$schema_id,
|
1528 |
+
'type' => 'text',
|
1529 |
+
'default' => $service_schema_details['saswp_review_schema_price_range']
|
1530 |
+
),
|
1531 |
+
array(
|
1532 |
+
'label' => 'Street Address',
|
1533 |
+
'id' => 'saswp_review_schema_street_address_'.$schema_id,
|
1534 |
+
'type' => 'text',
|
1535 |
+
'default' => $service_schema_details['saswp_review_schema_street_address']
|
1536 |
+
),
|
1537 |
+
array(
|
1538 |
+
'label' => 'Address Locality',
|
1539 |
+
'id' => 'saswp_review_schema_locality_'.$schema_id,
|
1540 |
+
'type' => 'text',
|
1541 |
+
'default' => $service_schema_details['saswp_review_schema_locality']
|
1542 |
+
),
|
1543 |
+
array(
|
1544 |
+
'label' => 'Address Region',
|
1545 |
+
'id' => 'saswp_review_schema_region_'.$schema_id,
|
1546 |
+
'type' => 'text',
|
1547 |
+
'default' => $service_schema_details['saswp_review_schema_region']
|
1548 |
+
),
|
1549 |
+
array(
|
1550 |
+
'label' => 'Postal Code',
|
1551 |
+
'id' => 'saswp_review_schema_postal_code_'.$schema_id,
|
1552 |
+
'type' => 'text',
|
1553 |
+
'default' => $service_schema_details['saswp_review_schema_postal_code']
|
1554 |
+
),
|
1555 |
+
array(
|
1556 |
+
'label' => 'Address Country',
|
1557 |
+
'id' => 'saswp_review_schema_country_'.$schema_id,
|
1558 |
+
'type' => 'text',
|
1559 |
+
'default' => $service_schema_details['saswp_review_schema_country'],
|
1560 |
+
),
|
1561 |
+
array(
|
1562 |
+
'label' => 'Telephone',
|
1563 |
+
'id' => 'saswp_review_schema_telephone_'.$schema_id,
|
1564 |
+
'type' => 'text',
|
1565 |
+
'default' => $service_schema_details['saswp_review_schema_telephone'],
|
1566 |
+
|
1567 |
),
|
1568 |
);
|
1569 |
break;
|
1651 |
);
|
1652 |
break;
|
1653 |
|
1654 |
+
case 'qanda':
|
1655 |
+
$meta_field = array(
|
1656 |
+
array(
|
1657 |
+
'label' => 'Question Title',
|
1658 |
+
'id' => 'saswp_qa_question_title_'.$schema_id,
|
1659 |
+
'type' => 'text',
|
1660 |
+
),
|
1661 |
+
array(
|
1662 |
+
'label' => 'Question Description',
|
1663 |
+
'id' => 'saswp_qa_question_description_'.$schema_id,
|
1664 |
+
'type' => 'text',
|
1665 |
+
),
|
1666 |
+
array(
|
1667 |
+
'label' => 'Question Upvote Count',
|
1668 |
+
'id' => 'saswp_qa_upvote_count_'.$schema_id,
|
1669 |
+
'type' => 'text',
|
1670 |
+
),
|
1671 |
+
array(
|
1672 |
+
'label' => 'Question Date Created',
|
1673 |
+
'id' => 'saswp_qa_date_created_'.$schema_id,
|
1674 |
+
'type' => 'text',
|
1675 |
+
),
|
1676 |
+
array(
|
1677 |
+
'label' => 'Author Name',
|
1678 |
+
'id' => 'saswp_qa_question_author_name_'.$schema_id,
|
1679 |
+
'type' => 'text',
|
1680 |
+
),
|
1681 |
+
array(
|
1682 |
+
'label' => 'Accepted Answer Text',
|
1683 |
+
'id' => 'saswp_qa_accepted_answer_text_'.$schema_id,
|
1684 |
+
'type' => 'text',
|
1685 |
+
),
|
1686 |
+
array(
|
1687 |
+
'label' => 'Accepted Answer Date Created',
|
1688 |
+
'id' => 'saswp_qa_accepted_answer_date_created_'.$schema_id,
|
1689 |
+
'type' => 'text',
|
1690 |
+
),
|
1691 |
+
array(
|
1692 |
+
'label' => 'Accepted Answer Upvote Count',
|
1693 |
+
'id' => 'saswp_qa_accepted_answer_upvote_count_'.$schema_id,
|
1694 |
+
'type' => 'text',
|
1695 |
+
),
|
1696 |
+
array(
|
1697 |
+
'label' => 'Accepted Answer Url',
|
1698 |
+
'id' => 'saswp_qa_accepted_answer_url_'.$schema_id,
|
1699 |
+
'type' => 'text',
|
1700 |
+
),
|
1701 |
+
array(
|
1702 |
+
'label' => 'Accepted Answer Author Name',
|
1703 |
+
'id' => 'saswp_qa_accepted_author_name_'.$schema_id,
|
1704 |
+
'type' => 'text',
|
1705 |
+
),
|
1706 |
+
|
1707 |
+
array(
|
1708 |
+
'label' => 'Suggested Answer Text',
|
1709 |
+
'id' => 'saswp_qa_suggested_answer_text_'.$schema_id,
|
1710 |
+
'type' => 'text',
|
1711 |
+
),
|
1712 |
+
array(
|
1713 |
+
'label' => 'Suggested Answer Date Created',
|
1714 |
+
'id' => 'saswp_qa_suggested_answer_date_created_'.$schema_id,
|
1715 |
+
'type' => 'text',
|
1716 |
+
),
|
1717 |
+
array(
|
1718 |
+
'label' => 'Suggested Answer Upvote Count',
|
1719 |
+
'id' => 'saswp_qa_suggested_answer_upvote_count_'.$schema_id,
|
1720 |
+
'type' => 'text',
|
1721 |
+
),
|
1722 |
+
array(
|
1723 |
+
'label' => 'Suggested Answer Url',
|
1724 |
+
'id' => 'saswp_qa_suggested_answer_url_'.$schema_id,
|
1725 |
+
'type' => 'text',
|
1726 |
+
),
|
1727 |
+
array(
|
1728 |
+
'label' => 'Suggested Answer Author Name',
|
1729 |
+
'id' => 'saswp_qa_suggested_author_name_'.$schema_id,
|
1730 |
+
'type' => 'text',
|
1731 |
+
),
|
1732 |
+
|
1733 |
+
);
|
1734 |
+
break;
|
1735 |
+
|
1736 |
default:
|
1737 |
break;
|
1738 |
}
|
view/review.php
CHANGED
@@ -1,5 +1,6 @@
|
|
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' ) );
|
@@ -7,15 +8,31 @@ class saswp_metaboxes_review {
|
|
7 |
}
|
8 |
function saswp_review_add_meta_box($post) {
|
9 |
global $sd_data;
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
'sasw-review',
|
13 |
esc_html__( 'Review', 'schema-and-structured-data-for-wp' ),
|
14 |
array( $this, 'saswp_meta_box_callback' ),
|
15 |
-
|
16 |
'advanced',
|
17 |
'default'
|
18 |
);
|
|
|
|
|
|
|
19 |
}
|
20 |
}
|
21 |
function saswp_review_get_meta( $value ) {
|
1 |
<?php
|
2 |
class saswp_metaboxes_review {
|
3 |
+
private $screen = array();
|
4 |
|
5 |
public function __construct() {
|
6 |
add_action( 'add_meta_boxes', array( $this, 'saswp_review_add_meta_box' ) );
|
8 |
}
|
9 |
function saswp_review_add_meta_box($post) {
|
10 |
global $sd_data;
|
11 |
+
|
12 |
+
$review_post_id = '';
|
13 |
+
if(is_object($post)){
|
14 |
+
$review_post_id = $post->ID;
|
15 |
+
}
|
16 |
+
|
17 |
+
if(get_post_status($review_post_id)=='publish' && $sd_data['saswp-review-module']==1){
|
18 |
+
|
19 |
+
$show_post_types = get_post_types();
|
20 |
+
unset($show_post_types['adsforwp'],$show_post_types['saswp'],$show_post_types['attachment'], $show_post_types['revision'], $show_post_types['nav_menu_item'], $show_post_types['user_request'], $show_post_types['custom_css']);
|
21 |
+
$this->screen = $show_post_types;
|
22 |
+
|
23 |
+
foreach ( $this->screen as $single_screen ) {
|
24 |
+
|
25 |
+
add_meta_box(
|
26 |
'sasw-review',
|
27 |
esc_html__( 'Review', 'schema-and-structured-data-for-wp' ),
|
28 |
array( $this, 'saswp_meta_box_callback' ),
|
29 |
+
$single_screen,
|
30 |
'advanced',
|
31 |
'default'
|
32 |
);
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
}
|
37 |
}
|
38 |
function saswp_review_get_meta( $value ) {
|
view/schema_type.php
CHANGED
@@ -28,6 +28,7 @@
|
|
28 |
$style_business_type ='';
|
29 |
$style_business_name ='';
|
30 |
$style_service_name ='';
|
|
|
31 |
$business_name ='';
|
32 |
$schema_type ='';
|
33 |
$business_type ='';
|
@@ -37,8 +38,9 @@
|
|
37 |
$business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
|
38 |
$business_name = esc_sql ( get_post_meta($post->ID, 'saswp_business_name', true) );
|
39 |
$business_details = esc_sql ( get_post_meta($post->ID, 'saswp_local_business_details', true) );
|
40 |
-
$service_details = esc_sql ( get_post_meta($post->ID, 'saswp_service_schema_details', true) );
|
41 |
-
|
|
|
42 |
$custom_logo_id = get_theme_mod( 'custom_logo' );
|
43 |
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
|
44 |
|
@@ -70,6 +72,8 @@
|
|
70 |
'Recipe' => 'Recipe',
|
71 |
'Product' => 'Product',
|
72 |
'Service' => 'Service',
|
|
|
|
|
73 |
'VideoObject' => 'VideoObject',
|
74 |
'local_business' => 'Local Business'
|
75 |
);
|
@@ -243,6 +247,12 @@
|
|
243 |
}
|
244 |
?>
|
245 |
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
</td>
|
247 |
</tr>
|
248 |
<tr class="saswp-business-type-tr" <?php echo $style_business_type; ?>>
|
@@ -496,34 +506,12 @@
|
|
496 |
</tr>
|
497 |
<tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
|
498 |
<td><?php echo esc_html__('Operation Days', 'schema-and-structured-data-for-wp' ); ?></td>
|
499 |
-
<td>
|
500 |
-
<
|
501 |
-
|
502 |
-
|
503 |
-
$selected_days = $business_details['saswp_dayofweek'];
|
504 |
-
foreach ($all_dayofweek_array as $key => $value) {
|
505 |
-
$sel = '';
|
506 |
-
if(isset($selected_days)){
|
507 |
-
if(in_array($key, $selected_days)){
|
508 |
-
$sel = 'selected';
|
509 |
-
}
|
510 |
-
echo "<option value='".esc_attr($key)."' ".esc_attr($sel).">".esc_html__($value, 'schema-and-structured-data-for-wp' )."</option>";
|
511 |
-
}else{
|
512 |
-
echo "<option value='".esc_attr($key)."'>".esc_html__($value, 'schema-and-structured-data-for-wp' )."</option>";
|
513 |
-
}
|
514 |
-
}
|
515 |
-
?>
|
516 |
-
</select>
|
517 |
</td>
|
518 |
</tr>
|
519 |
-
|
520 |
-
<td><?php echo esc_html__('Opens', 'schema-and-structured-data-for-wp' ); ?></td>
|
521 |
-
<td><input id="saswp-dayofweek-opens-time" value="<?php if(isset($business_details['local_opens_time'])){echo esc_attr($business_details['local_opens_time']); } ?>" type="text" name="local_opens_time" ></td>
|
522 |
-
</tr>
|
523 |
-
<tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
|
524 |
-
<td><?php echo esc_html__('Closes', 'schema-and-structured-data-for-wp' ); ?></td>
|
525 |
-
<td><input id="saswp-dayofweek-closes-time" value="<?php if(isset($business_details['local_closes_time'])){echo esc_attr($business_details['local_closes_time']); } ?>" type="text" name="local_closes_time" ></td>
|
526 |
-
</tr>
|
527 |
<tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
|
528 |
<td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
|
529 |
<td><input value="<?php if(isset($business_details['local_price_range'])){echo esc_attr($business_details['local_price_range']); } ?>" type="text" name="local_price_range" placeholder="<?php echo esc_html__('$10-$50 or $$$ ', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
@@ -581,6 +569,59 @@
|
|
581 |
</tr>
|
582 |
|
583 |
<!-- Service Schema type ends here -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
</table>
|
585 |
|
586 |
</div>
|
@@ -611,92 +652,128 @@
|
|
611 |
|
612 |
$local_business_details = array();
|
613 |
if ( isset( $_POST['local_business_name'] ) ){
|
614 |
-
$local_business_details['local_business_name'] = $_POST['local_business_name'];
|
615 |
}
|
616 |
if ( isset( $_POST['local_street_address'] ) ){
|
617 |
-
$local_business_details['local_street_address'] = $_POST['local_street_address'];
|
618 |
}
|
619 |
if ( isset( $_POST['local_city'] ) ){
|
620 |
-
$local_business_details['local_city'] = $_POST['local_city'];
|
621 |
}
|
622 |
if ( isset( $_POST['local_state'] ) ){
|
623 |
-
$local_business_details['local_state'] = $_POST['local_state'];
|
624 |
}
|
625 |
if ( isset( $_POST['local_postal_code'] ) ){
|
626 |
-
$local_business_details['local_postal_code'] = $_POST['local_postal_code'];
|
627 |
}
|
628 |
if ( isset( $_POST['local_phone'] ) ){
|
629 |
-
$local_business_details['local_phone'] = $_POST['local_phone'];
|
630 |
}
|
631 |
if ( isset( $_POST['local_website'] ) ){
|
632 |
-
$local_business_details['local_website'] = $_POST['local_website'];
|
633 |
}
|
634 |
if ( isset( $_POST['local_business_logo'] ) ){
|
635 |
|
636 |
-
$local_business_details['local_business_logo']['id'] = $_POST['local_business_logo']['id'];
|
637 |
-
$local_business_details['local_business_logo']['url'] = $_POST['local_business_logo']['url'];
|
638 |
-
$local_business_details['local_business_logo']['width'] = $_POST['local_business_logo']['width'];
|
639 |
-
$local_business_details['local_business_logo']['height'] = $_POST['local_business_logo']['height'];
|
640 |
-
}
|
641 |
-
if ( isset( $_POST['local_opens_time'] ) ){
|
642 |
-
$local_business_details['local_opens_time'] = $_POST['local_opens_time'];
|
643 |
-
}
|
644 |
-
if ( isset( $_POST['local_closes_time'] ) ){
|
645 |
-
$local_business_details['local_closes_time'] = $_POST['local_closes_time'];
|
646 |
}
|
|
|
647 |
if ( isset( $_POST['saswp_dayofweek'] ) ){
|
648 |
-
$
|
649 |
}
|
650 |
if ( isset( $_POST['local_price_range'] ) ){
|
651 |
-
$local_business_details['local_price_range'] = $_POST['local_price_range'];
|
652 |
}
|
653 |
|
654 |
update_post_meta( $post_id, 'saswp_local_business_details', $local_business_details );
|
655 |
|
656 |
//Service schema details starts here
|
657 |
$service_schema_details = array();
|
|
|
658 |
$schema_type = $_POST['schema_type'];
|
659 |
|
660 |
if($schema_type =='Service'){
|
661 |
if ( isset( $_POST['saswp_service_schema_name'] ) ){
|
662 |
-
$service_schema_details['saswp_service_schema_name'] = $_POST['saswp_service_schema_name'];
|
663 |
}
|
664 |
if ( isset( $_POST['saswp_service_schema_type'] ) ){
|
665 |
-
$service_schema_details['saswp_service_schema_type'] = $_POST['saswp_service_schema_type'];
|
666 |
}
|
667 |
if ( isset( $_POST['saswp_service_schema_provider_name'] ) ){
|
668 |
-
$service_schema_details['saswp_service_schema_provider_name'] = $_POST['saswp_service_schema_provider_name'];
|
669 |
}
|
670 |
if ( isset( $_POST['saswp_service_schema_image'] ) ){
|
671 |
-
$service_schema_details['saswp_service_schema_image']['id'] = $_POST['saswp_service_schema_image']['id'];
|
672 |
-
$service_schema_details['saswp_service_schema_image']['url'] = $_POST['saswp_service_schema_image']['url'];
|
673 |
-
$service_schema_details['saswp_service_schema_image']['width'] = $_POST['saswp_service_schema_image']['width'];
|
674 |
-
$service_schema_details['saswp_service_schema_image']['height'] = $_POST['saswp_service_schema_image']['height'];
|
675 |
}
|
676 |
if ( isset( $_POST['saswp_service_schema_locality'] ) ){
|
677 |
-
$service_schema_details['saswp_service_schema_locality'] = $_POST['saswp_service_schema_locality'];
|
678 |
}
|
679 |
if ( isset( $_POST['saswp_service_schema_postal_code'] ) ){
|
680 |
-
$service_schema_details['saswp_service_schema_postal_code'] = $_POST['saswp_service_schema_postal_code'];
|
681 |
}
|
682 |
if ( isset( $_POST['saswp_service_schema_telephone'] ) ){
|
683 |
-
$service_schema_details['saswp_service_schema_telephone'] = $_POST['saswp_service_schema_telephone'];
|
684 |
}
|
685 |
if ( isset( $_POST['saswp_service_schema_price_range'] ) ){
|
686 |
-
$service_schema_details['saswp_service_schema_price_range'] = $_POST['saswp_service_schema_price_range'];
|
687 |
}
|
688 |
if ( isset( $_POST['saswp_service_schema_description'] ) ){
|
689 |
-
$service_schema_details['saswp_service_schema_description'] = $_POST['saswp_service_schema_description'];
|
690 |
}
|
691 |
if ( isset( $_POST['saswp_service_schema_area_served'] ) ){
|
692 |
-
$service_schema_details['saswp_service_schema_area_served'] = $_POST['saswp_service_schema_area_served'];
|
693 |
}
|
694 |
if ( isset( $_POST['saswp_service_schema_service_offer'] ) ){
|
695 |
-
$service_schema_details['saswp_service_schema_service_offer'] = $_POST['saswp_service_schema_service_offer'];
|
696 |
}
|
697 |
update_post_meta( $post_id, 'saswp_service_schema_details', $service_schema_details );
|
698 |
}
|
699 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
700 |
//Service schema details ends here
|
701 |
|
702 |
|
28 |
$style_business_type ='';
|
29 |
$style_business_name ='';
|
30 |
$style_service_name ='';
|
31 |
+
$style_review_name ='';
|
32 |
$business_name ='';
|
33 |
$schema_type ='';
|
34 |
$business_type ='';
|
38 |
$business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
|
39 |
$business_name = esc_sql ( get_post_meta($post->ID, 'saswp_business_name', true) );
|
40 |
$business_details = esc_sql ( get_post_meta($post->ID, 'saswp_local_business_details', true) );
|
41 |
+
$service_details = esc_sql ( get_post_meta($post->ID, 'saswp_service_schema_details', true) );
|
42 |
+
$review_details = esc_sql ( get_post_meta($post->ID, 'saswp_review_schema_details', true) );
|
43 |
+
$dayoftheweek = get_post_meta($post->ID, 'saswp_dayofweek', true);
|
44 |
$custom_logo_id = get_theme_mod( 'custom_logo' );
|
45 |
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
|
46 |
|
72 |
'Recipe' => 'Recipe',
|
73 |
'Product' => 'Product',
|
74 |
'Service' => 'Service',
|
75 |
+
'Review' => 'Review',
|
76 |
+
'qanda' => 'Q&A',
|
77 |
'VideoObject' => 'VideoObject',
|
78 |
'local_business' => 'Local Business'
|
79 |
);
|
247 |
}
|
248 |
?>
|
249 |
</select>
|
250 |
+
<?php if($schema_type == 'qanda') { ?>
|
251 |
+
<span class="saswp-schem-type-note">Note: Currently supported with DW Question & Answer <a target="_blank" href="https://wordpress.org/plugins/dw-question-answer/">Link</a></span>
|
252 |
+
<?php }else{ ?>
|
253 |
+
<span class="saswp-schem-type-note saswp_hide">Note: Currently supported with DW Question & Answer <a target="_blank" href="https://wordpress.org/plugins/dw-question-answer/">Link</a></span>
|
254 |
+
<?php } ?>
|
255 |
+
|
256 |
</td>
|
257 |
</tr>
|
258 |
<tr class="saswp-business-type-tr" <?php echo $style_business_type; ?>>
|
506 |
</tr>
|
507 |
<tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
|
508 |
<td><?php echo esc_html__('Operation Days', 'schema-and-structured-data-for-wp' ); ?></td>
|
509 |
+
<td>
|
510 |
+
<textarea id="saswp_dayofweek" placeholder="Mo-Sa 11:00-14:30 <?="\n"?>Mo-Th 17:00-21:30 <?="\n"?>Fr-Sa 17:00-22:00" rows="5" cols="70" name="saswp_dayofweek"><?php if(isset($dayoftheweek)){echo $dayoftheweek; } ?></textarea>
|
511 |
+
<p>Note: Enter days and time in given format.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
</td>
|
513 |
</tr>
|
514 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
<tr class="saswp-business-text-field-tr" <?php echo $style_business_type; ?>>
|
516 |
<td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
|
517 |
<td><input value="<?php if(isset($business_details['local_price_range'])){echo esc_attr($business_details['local_price_range']); } ?>" type="text" name="local_price_range" placeholder="<?php echo esc_html__('$10-$50 or $$$ ', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
569 |
</tr>
|
570 |
|
571 |
<!-- Service Schema type ends here -->
|
572 |
+
|
573 |
+
<!-- Review Schema type starts here -->
|
574 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
575 |
+
<td><?php echo esc_html__('Item Reviewed Type', 'schema-and-structured-data-for-wp' ); ?></td>
|
576 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_item_type'])){echo esc_attr($review_details['saswp_review_schema_item_type']); } ?>" type="text" name="saswp_review_schema_item_type" placeholder="<?php echo esc_html__('Restaurant', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
577 |
+
</tr>
|
578 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
579 |
+
<td><?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?></td>
|
580 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_name'])){echo esc_attr($review_details['saswp_review_schema_name']); } ?>" type="text" name="saswp_review_schema_name" placeholder="<?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
581 |
+
</tr>
|
582 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
583 |
+
<td><?php echo esc_html__('Description', 'schema-and-structured-data-for-wp' ); ?></td>
|
584 |
+
<td><textarea placeholder="Description" rows="3" cols="70" name="saswp_review_schema_description"><?php if(isset($review_details['saswp_review_schema_description'])){echo esc_attr($review_details['saswp_review_schema_description']); } ?></textarea></td>
|
585 |
+
</tr>
|
586 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
587 |
+
<td><?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?></td>
|
588 |
+
<td style="display: flex; width: 97%">
|
589 |
+
<input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_url($review_details['saswp_review_schema_image']['url']);} else { echo esc_url($logo[0]); } ?>" id="saswp_review_schema_image" type="text" name="saswp_review_schema_image[url]" placeholder="<?php echo esc_html__('Image', 'schema-and-structured-data-for-wp' ); ?>" readonly="readonly" style="background: #FFF;">
|
590 |
+
<input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_attr($review_details['saswp_review_schema_image']['id']);} else { echo esc_attr($custom_logo_id); }?>" data-id="saswp_review_schema_image_id" type="hidden" name="saswp_review_schema_image[id]">
|
591 |
+
<input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_attr($review_details['saswp_review_schema_image']['width']);} else { echo esc_attr($logo[1]); } ?>" data-id="saswp_review_schema_image_width" type="hidden" name="saswp_review_schema_image[width]">
|
592 |
+
<input value="<?php if(isset($review_details['saswp_review_schema_image'])) { echo esc_attr($review_details['saswp_review_schema_image']['height']);} else { echo esc_attr($logo[2]); } ?>" data-id="saswp_review_schema_image_height" type="hidden" name="saswp_review_schema_image[height]">
|
593 |
+
<input data-id="media" class="button" id="saswp_review_schema_image_button" type="button" value="Upload"></td>
|
594 |
+
</tr>
|
595 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
596 |
+
<td><?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?></td>
|
597 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_price_range'])){echo esc_attr($review_details['saswp_review_schema_price_range']); } ?>" type="text" name="saswp_review_schema_price_range" placeholder="<?php echo esc_html__('Price Range', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
598 |
+
</tr>
|
599 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
600 |
+
<td><?php echo esc_html__('Street Address', 'schema-and-structured-data-for-wp' ); ?></td>
|
601 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_street_address'])){echo esc_attr($review_details['saswp_review_schema_street_address']); } ?>" type="text" name="saswp_review_schema_street_address" placeholder="<?php echo esc_html__('Street Address', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
602 |
+
</tr>
|
603 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
604 |
+
<td><?php echo esc_html__('Address Locality', 'schema-and-structured-data-for-wp' ); ?></td>
|
605 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_locality'])){echo esc_attr($review_details['saswp_review_schema_locality']); } ?>" type="text" name="saswp_review_schema_locality" placeholder="<?php echo esc_html__('Address Locality', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
606 |
+
</tr>
|
607 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
608 |
+
<td><?php echo esc_html__('Address Region', 'schema-and-structured-data-for-wp' ); ?></td>
|
609 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_region'])){echo esc_attr($review_details['saswp_review_schema_region']); } ?>" type="text" name="saswp_review_schema_region" placeholder="<?php echo esc_html__('Address Region', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
610 |
+
</tr>
|
611 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
612 |
+
<td><?php echo esc_html__('Postal Code', 'schema-and-structured-data-for-wp' ); ?></td>
|
613 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_postal_code'])){echo esc_attr($review_details['saswp_review_schema_postal_code']); } ?>" type="text" name="saswp_review_schema_postal_code" placeholder="<?php echo esc_html__('Postal Code', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
614 |
+
</tr>
|
615 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
616 |
+
<td><?php echo esc_html__('Address Country', 'schema-and-structured-data-for-wp' ); ?></td>
|
617 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_country'])){echo esc_attr($review_details['saswp_review_schema_country']); } ?>" type="text" name="saswp_review_schema_country" placeholder="<?php echo esc_html__('Address Country', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
618 |
+
</tr>
|
619 |
+
<tr class="saswp-review-text-field-tr" <?php echo $style_review_name; ?>>
|
620 |
+
<td><?php echo esc_html__('Telephone', 'schema-and-structured-data-for-wp' ); ?></td>
|
621 |
+
<td><input value="<?php if(isset($review_details['saswp_review_schema_telephone'])){echo esc_attr($review_details['saswp_review_schema_telephone']); } ?>" type="text" name="saswp_review_schema_telephone" placeholder="<?php echo esc_html__('Telephone', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
622 |
+
</tr>
|
623 |
+
|
624 |
+
<!-- Review Schema type ends here -->
|
625 |
</table>
|
626 |
|
627 |
</div>
|
652 |
|
653 |
$local_business_details = array();
|
654 |
if ( isset( $_POST['local_business_name'] ) ){
|
655 |
+
$local_business_details['local_business_name'] = sanitize_text_field($_POST['local_business_name']);
|
656 |
}
|
657 |
if ( isset( $_POST['local_street_address'] ) ){
|
658 |
+
$local_business_details['local_street_address'] = sanitize_text_field($_POST['local_street_address']);
|
659 |
}
|
660 |
if ( isset( $_POST['local_city'] ) ){
|
661 |
+
$local_business_details['local_city'] = sanitize_text_field($_POST['local_city']);
|
662 |
}
|
663 |
if ( isset( $_POST['local_state'] ) ){
|
664 |
+
$local_business_details['local_state'] = sanitize_text_field($_POST['local_state']);
|
665 |
}
|
666 |
if ( isset( $_POST['local_postal_code'] ) ){
|
667 |
+
$local_business_details['local_postal_code'] = sanitize_text_field($_POST['local_postal_code']);
|
668 |
}
|
669 |
if ( isset( $_POST['local_phone'] ) ){
|
670 |
+
$local_business_details['local_phone'] = sanitize_text_field($_POST['local_phone']);
|
671 |
}
|
672 |
if ( isset( $_POST['local_website'] ) ){
|
673 |
+
$local_business_details['local_website'] = esc_url_raw($_POST['local_website']);
|
674 |
}
|
675 |
if ( isset( $_POST['local_business_logo'] ) ){
|
676 |
|
677 |
+
$local_business_details['local_business_logo']['id'] = sanitize_text_field($_POST['local_business_logo']['id']);
|
678 |
+
$local_business_details['local_business_logo']['url'] = sanitize_text_field($_POST['local_business_logo']['url']);
|
679 |
+
$local_business_details['local_business_logo']['width'] = sanitize_text_field($_POST['local_business_logo']['width']);
|
680 |
+
$local_business_details['local_business_logo']['height'] = sanitize_text_field($_POST['local_business_logo']['height']);
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
}
|
682 |
+
|
683 |
if ( isset( $_POST['saswp_dayofweek'] ) ){
|
684 |
+
update_post_meta( $post_id, 'saswp_dayofweek', esc_textarea( stripslashes($_POST['saswp_dayofweek'])) );
|
685 |
}
|
686 |
if ( isset( $_POST['local_price_range'] ) ){
|
687 |
+
$local_business_details['local_price_range'] = sanitize_text_field($_POST['local_price_range']);
|
688 |
}
|
689 |
|
690 |
update_post_meta( $post_id, 'saswp_local_business_details', $local_business_details );
|
691 |
|
692 |
//Service schema details starts here
|
693 |
$service_schema_details = array();
|
694 |
+
$review_schema_details = array();
|
695 |
$schema_type = $_POST['schema_type'];
|
696 |
|
697 |
if($schema_type =='Service'){
|
698 |
if ( isset( $_POST['saswp_service_schema_name'] ) ){
|
699 |
+
$service_schema_details['saswp_service_schema_name'] = sanitize_text_field($_POST['saswp_service_schema_name']);
|
700 |
}
|
701 |
if ( isset( $_POST['saswp_service_schema_type'] ) ){
|
702 |
+
$service_schema_details['saswp_service_schema_type'] = sanitize_text_field($_POST['saswp_service_schema_type']);
|
703 |
}
|
704 |
if ( isset( $_POST['saswp_service_schema_provider_name'] ) ){
|
705 |
+
$service_schema_details['saswp_service_schema_provider_name'] = sanitize_text_field($_POST['saswp_service_schema_provider_name']);
|
706 |
}
|
707 |
if ( isset( $_POST['saswp_service_schema_image'] ) ){
|
708 |
+
$service_schema_details['saswp_service_schema_image']['id'] = sanitize_text_field($_POST['saswp_service_schema_image']['id']);
|
709 |
+
$service_schema_details['saswp_service_schema_image']['url'] = esc_url_raw($_POST['saswp_service_schema_image']['url']);
|
710 |
+
$service_schema_details['saswp_service_schema_image']['width'] = sanitize_text_field($_POST['saswp_service_schema_image']['width']);
|
711 |
+
$service_schema_details['saswp_service_schema_image']['height'] = sanitize_text_field($_POST['saswp_service_schema_image']['height']);
|
712 |
}
|
713 |
if ( isset( $_POST['saswp_service_schema_locality'] ) ){
|
714 |
+
$service_schema_details['saswp_service_schema_locality'] = sanitize_text_field($_POST['saswp_service_schema_locality']);
|
715 |
}
|
716 |
if ( isset( $_POST['saswp_service_schema_postal_code'] ) ){
|
717 |
+
$service_schema_details['saswp_service_schema_postal_code'] = sanitize_text_field($_POST['saswp_service_schema_postal_code']);
|
718 |
}
|
719 |
if ( isset( $_POST['saswp_service_schema_telephone'] ) ){
|
720 |
+
$service_schema_details['saswp_service_schema_telephone'] = sanitize_text_field($_POST['saswp_service_schema_telephone']);
|
721 |
}
|
722 |
if ( isset( $_POST['saswp_service_schema_price_range'] ) ){
|
723 |
+
$service_schema_details['saswp_service_schema_price_range'] = sanitize_text_field($_POST['saswp_service_schema_price_range']);
|
724 |
}
|
725 |
if ( isset( $_POST['saswp_service_schema_description'] ) ){
|
726 |
+
$service_schema_details['saswp_service_schema_description'] = sanitize_textarea_field($_POST['saswp_service_schema_description']);
|
727 |
}
|
728 |
if ( isset( $_POST['saswp_service_schema_area_served'] ) ){
|
729 |
+
$service_schema_details['saswp_service_schema_area_served'] = sanitize_textarea_field($_POST['saswp_service_schema_area_served']);
|
730 |
}
|
731 |
if ( isset( $_POST['saswp_service_schema_service_offer'] ) ){
|
732 |
+
$service_schema_details['saswp_service_schema_service_offer'] = sanitize_textarea_field($_POST['saswp_service_schema_service_offer']);
|
733 |
}
|
734 |
update_post_meta( $post_id, 'saswp_service_schema_details', $service_schema_details );
|
735 |
}
|
736 |
|
737 |
+
|
738 |
+
if($schema_type =='Review'){
|
739 |
+
if ( isset( $_POST['saswp_review_schema_item_type'] ) ){
|
740 |
+
$review_schema_details['saswp_review_schema_item_type'] = sanitize_text_field($_POST['saswp_review_schema_item_type']);
|
741 |
+
}
|
742 |
+
if ( isset( $_POST['saswp_review_schema_name'] ) ){
|
743 |
+
$review_schema_details['saswp_review_schema_name'] = sanitize_text_field($_POST['saswp_review_schema_name']);
|
744 |
+
}
|
745 |
+
if ( isset( $_POST['saswp_review_schema_description'] ) ){
|
746 |
+
$review_schema_details['saswp_review_schema_description'] = sanitize_textarea_field($_POST['saswp_review_schema_description']);
|
747 |
+
}
|
748 |
+
if ( isset( $_POST['saswp_review_schema_image'] ) ){
|
749 |
+
$review_schema_details['saswp_review_schema_image']['id'] = sanitize_text_field($_POST['saswp_review_schema_image']['id']);
|
750 |
+
$review_schema_details['saswp_review_schema_image']['url'] = esc_url_raw($_POST['saswp_review_schema_image']['url']);
|
751 |
+
$review_schema_details['saswp_review_schema_image']['width'] = sanitize_text_field($_POST['saswp_review_schema_image']['width']);
|
752 |
+
$review_schema_details['saswp_review_schema_image']['height'] = sanitize_text_field($_POST['saswp_review_schema_image']['height']);
|
753 |
+
}
|
754 |
+
if ( isset( $_POST['saswp_review_schema_price_range'] ) ){
|
755 |
+
$review_schema_details['saswp_review_schema_price_range'] = sanitize_text_field($_POST['saswp_review_schema_price_range']);
|
756 |
+
}
|
757 |
+
if ( isset( $_POST['saswp_review_schema_street_address'] ) ){
|
758 |
+
$review_schema_details['saswp_review_schema_street_address'] = sanitize_text_field($_POST['saswp_review_schema_street_address']);
|
759 |
+
}
|
760 |
+
if ( isset( $_POST['saswp_review_schema_locality'] ) ){
|
761 |
+
$review_schema_details['saswp_review_schema_locality'] = sanitize_text_field($_POST['saswp_review_schema_locality']);
|
762 |
+
}
|
763 |
+
if ( isset( $_POST['saswp_review_schema_region'] ) ){
|
764 |
+
$review_schema_details['saswp_review_schema_region'] = sanitize_text_field($_POST['saswp_review_schema_region']);
|
765 |
+
}
|
766 |
+
if ( isset( $_POST['saswp_review_schema_postal_code'] ) ){
|
767 |
+
$review_schema_details['saswp_review_schema_postal_code'] = sanitize_text_field($_POST['saswp_review_schema_postal_code']);
|
768 |
+
}
|
769 |
+
if ( isset( $_POST['saswp_review_schema_country'] ) ){
|
770 |
+
$review_schema_details['saswp_review_schema_country'] = sanitize_text_field($_POST['saswp_review_schema_country']);
|
771 |
+
}
|
772 |
+
if ( isset( $_POST['saswp_review_schema_telephone'] ) ){
|
773 |
+
$review_schema_details['saswp_review_schema_telephone'] = sanitize_text_field($_POST['saswp_review_schema_telephone']);
|
774 |
+
}
|
775 |
+
update_post_meta( $post_id, 'saswp_review_schema_details', $review_schema_details );
|
776 |
+
}
|
777 |
//Service schema details ends here
|
778 |
|
779 |
|