Version Description
(22 February 2019) =
- New Feature: Software Application and Course schema type added to the schema type list #115
- Bug Fixed: Modify Schema Output is not getting, Selected post meta fields value in schema markup #155
- Bug Fixed: Author name field value is not being filled in the Review schema markup #154
- Bug Fixed: Notice cluttering in error logs #152
Download this release
Release Info
Developer | ampforwp |
Plugin | Schema & Structured Data for WP & AMP |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.2
- admin_section/css/main-style.css +1 -0
- admin_section/js/main-script.js +16 -0
- admin_section/js/saswp-add-new.js +6 -0
- admin_section/settings.php +24 -1
- admin_section/structure_admin.php +40 -9
- output/function.php +238 -0
- output/output.php +329 -367
- output/service.php +205 -25
- readme.txt +8 -1
- structured-data-for-wp.php +2 -2
- view/post_specific.php +133 -7
- view/schema_type.php +116 -19
admin_section/css/main-style.css
CHANGED
@@ -540,6 +540,7 @@ input:checked + .saswp-slider:before {
|
|
540 |
display: flex;
|
541 |
flex-grow: 1;
|
542 |
background: transparent;
|
|
|
543 |
}
|
544 |
.saswp-single-post-restore .saswp-switch{
|
545 |
height: 28px;
|
540 |
display: flex;
|
541 |
flex-grow: 1;
|
542 |
background: transparent;
|
543 |
+
width: 113px;
|
544 |
}
|
545 |
.saswp-single-post-restore .saswp-switch{
|
546 |
height: 28px;
|
admin_section/js/main-script.js
CHANGED
@@ -56,6 +56,9 @@ jQuery(document).ready(function($){
|
|
56 |
}
|
57 |
if(schematype == 'AudioObject'){
|
58 |
$(".saswp-audio-text-field-tr").show();
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
$(".saswp-schem-type-note").addClass('saswp_hide');
|
@@ -100,6 +103,10 @@ jQuery(document).ready(function($){
|
|
100 |
if(schematype == 'AudioObject'){
|
101 |
$(".saswp-audio-text-field-tr").show();
|
102 |
}
|
|
|
|
|
|
|
|
|
103 |
if(schematype == 'Review'){
|
104 |
$(".saswp-review-text-field-tr").show();
|
105 |
$(".saswp-review-text-field-tr").find('select').attr('disabled', false);
|
@@ -347,6 +354,15 @@ jQuery(document).ready(function($){
|
|
347 |
}
|
348 |
break;
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
default:
|
352 |
break;
|
56 |
}
|
57 |
if(schematype == 'AudioObject'){
|
58 |
$(".saswp-audio-text-field-tr").show();
|
59 |
+
}
|
60 |
+
if(schematype == 'SoftwareApplication'){
|
61 |
+
$(".saswp-softwareapplication-text-field-tr").show();
|
62 |
}
|
63 |
|
64 |
$(".saswp-schem-type-note").addClass('saswp_hide');
|
103 |
if(schematype == 'AudioObject'){
|
104 |
$(".saswp-audio-text-field-tr").show();
|
105 |
}
|
106 |
+
if(schematype == 'SoftwareApplication'){
|
107 |
+
$(".saswp-softwareapplication-text-field-tr").show();
|
108 |
+
}
|
109 |
+
|
110 |
if(schematype == 'Review'){
|
111 |
$(".saswp-review-text-field-tr").show();
|
112 |
$(".saswp-review-text-field-tr").find('select').attr('disabled', false);
|
354 |
}
|
355 |
break;
|
356 |
|
357 |
+
case 'saswp-tagyeem-checkbox':
|
358 |
+
|
359 |
+
if ($(this).is(':checked')) {
|
360 |
+
$("#saswp-tagyeem").val(1);
|
361 |
+
}else{
|
362 |
+
$("#saswp-tagyeem").val(0);
|
363 |
+
}
|
364 |
+
break;
|
365 |
+
|
366 |
|
367 |
default:
|
368 |
break;
|
admin_section/js/saswp-add-new.js
CHANGED
@@ -277,6 +277,9 @@ jQuery(document).ready(function($) {
|
|
277 |
if(schematype == 'AudioObject'){
|
278 |
$(".saswp-audio-text-field-tr").show();
|
279 |
}
|
|
|
|
|
|
|
280 |
if(schematype == 'Review'){
|
281 |
$(".saswp-review-text-field-tr").show();
|
282 |
$(".saswp-option-table-class tr").find('select').attr('disabled', false);
|
@@ -322,6 +325,9 @@ jQuery(document).ready(function($) {
|
|
322 |
if(schematype == 'AudioObject'){
|
323 |
$(".saswp-audio-text-field-tr").show();
|
324 |
}
|
|
|
|
|
|
|
325 |
if(schematype == 'Review'){
|
326 |
$(".saswp-review-text-field-tr").show();
|
327 |
$(".saswp-review-text-field-tr").find('select').attr('disabled', false);
|
277 |
if(schematype == 'AudioObject'){
|
278 |
$(".saswp-audio-text-field-tr").show();
|
279 |
}
|
280 |
+
if(schematype == 'SoftwareApplication'){
|
281 |
+
$(".saswp-softwareapplication-text-field-tr").show();
|
282 |
+
}
|
283 |
if(schematype == 'Review'){
|
284 |
$(".saswp-review-text-field-tr").show();
|
285 |
$(".saswp-option-table-class tr").find('select').attr('disabled', false);
|
325 |
if(schematype == 'AudioObject'){
|
326 |
$(".saswp-audio-text-field-tr").show();
|
327 |
}
|
328 |
+
if(schematype == 'SoftwareApplication'){
|
329 |
+
$(".saswp-softwareapplication-text-field-tr").show();
|
330 |
+
}
|
331 |
if(schematype == 'Review'){
|
332 |
$(".saswp-review-text-field-tr").show();
|
333 |
$(".saswp-review-text-field-tr").find('select').attr('disabled', false);
|
admin_section/settings.php
CHANGED
@@ -923,6 +923,19 @@ function saswp_review_page_callback(){
|
|
923 |
function saswp_compatibility_page_callback(){
|
924 |
|
925 |
$settings = saswp_defaultSettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
926 |
$kk_star = array(
|
927 |
'label' => 'kk Star Ratings',
|
928 |
'id' => 'saswp-kk-star-raring-checkbox',
|
@@ -992,6 +1005,16 @@ function saswp_compatibility_page_callback(){
|
|
992 |
)
|
993 |
);
|
994 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
995 |
if(!is_plugin_active('wordpress-seo/wp-seo.php') && !is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')){
|
996 |
$yoast['attributes'] = array(
|
997 |
'disabled' => 'disabled'
|
@@ -1054,7 +1077,7 @@ function saswp_compatibility_page_callback(){
|
|
1054 |
$extratheme,
|
1055 |
$dwquestiton,
|
1056 |
$wpjobmanager,
|
1057 |
-
$yoast
|
1058 |
|
1059 |
);
|
1060 |
|
923 |
function saswp_compatibility_page_callback(){
|
924 |
|
925 |
$settings = saswp_defaultSettings();
|
926 |
+
|
927 |
+
$tagyeem = array(
|
928 |
+
'label' => 'Tagyeem Review',
|
929 |
+
'id' => 'saswp-tagyeem-checkbox',
|
930 |
+
'name' => 'saswp-tagyeem-checkbox',
|
931 |
+
'type' => 'checkbox',
|
932 |
+
'class' => 'checkbox saswp-checkbox',
|
933 |
+
'hidden' => array(
|
934 |
+
'id' => 'saswp-tagyeem',
|
935 |
+
'name' => 'sd_data[saswp-tagyeem]',
|
936 |
+
)
|
937 |
+
);
|
938 |
+
|
939 |
$kk_star = array(
|
940 |
'label' => 'kk Star Ratings',
|
941 |
'id' => 'saswp-kk-star-raring-checkbox',
|
1005 |
)
|
1006 |
);
|
1007 |
|
1008 |
+
|
1009 |
+
if(!is_plugin_active('taqyeem/taqyeem.php')){
|
1010 |
+
$tagyeem['attributes'] = array(
|
1011 |
+
'disabled' => 'disabled'
|
1012 |
+
);
|
1013 |
+
$tagyeem['note'] = esc_html__('Plugin is not activated','schema-and-structured-data-for-wp');
|
1014 |
+
$settings['saswp-taqyeem'] = 0;
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
|
1018 |
if(!is_plugin_active('wordpress-seo/wp-seo.php') && !is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')){
|
1019 |
$yoast['attributes'] = array(
|
1020 |
'disabled' => 'disabled'
|
1077 |
$extratheme,
|
1078 |
$dwquestiton,
|
1079 |
$wpjobmanager,
|
1080 |
+
$yoast,
|
1081 |
|
1082 |
);
|
1083 |
|
admin_section/structure_admin.php
CHANGED
@@ -220,6 +220,7 @@ function saswp_generate_field_data( $post_id ){
|
|
220 |
function saswp_comparison_logic_checker($input){
|
221 |
|
222 |
global $post;
|
|
|
223 |
$type = $input['key_1'];
|
224 |
$comparison = $input['key_2'];
|
225 |
$data = $input['key_3'];
|
@@ -311,13 +312,18 @@ function saswp_comparison_logic_checker($input){
|
|
311 |
case 'post_category':
|
312 |
|
313 |
$current_category = '';
|
314 |
-
|
315 |
-
if(
|
316 |
-
|
317 |
-
|
318 |
-
|
|
|
|
|
|
|
|
|
|
|
319 |
}
|
320 |
-
|
321 |
if ( $comparison == 'equal') {
|
322 |
if ( $data == $current_category ) {
|
323 |
$result = true;
|
@@ -331,7 +337,15 @@ function saswp_comparison_logic_checker($input){
|
|
331 |
break;
|
332 |
// Post Format
|
333 |
case 'post_format':
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
if ( $current_post_format === false ) {
|
336 |
$current_post_format = 'standard';
|
337 |
}
|
@@ -374,7 +388,15 @@ function saswp_comparison_logic_checker($input){
|
|
374 |
|
375 |
// Page Template
|
376 |
case 'page_template':
|
377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
if ( $current_page_template == false ) {
|
379 |
$current_page_template = 'default';
|
380 |
}
|
@@ -417,15 +439,24 @@ function saswp_comparison_logic_checker($input){
|
|
417 |
}
|
418 |
}
|
419 |
if($result==true && isset( $input['key_4'] ) && $input['key_4'] !='all'){
|
|
|
420 |
$term_data = $input['key_4'];
|
421 |
-
$terms
|
|
|
422 |
if(count($terms)>0){
|
|
|
423 |
$termChoices = array();
|
|
|
424 |
foreach ($terms as $key => $termvalue) {
|
|
|
425 |
$termChoices[] = $termvalue->slug;
|
|
|
426 |
}
|
|
|
427 |
}
|
|
|
428 |
$result = false;
|
|
|
429 |
if(in_array($term_data, $termChoices)){
|
430 |
$result = true;
|
431 |
}
|
220 |
function saswp_comparison_logic_checker($input){
|
221 |
|
222 |
global $post;
|
223 |
+
|
224 |
$type = $input['key_1'];
|
225 |
$comparison = $input['key_2'];
|
226 |
$data = $input['key_3'];
|
312 |
case 'post_category':
|
313 |
|
314 |
$current_category = '';
|
315 |
+
|
316 |
+
if(is_object($post)){
|
317 |
+
|
318 |
+
$postcat = get_the_category( $post->ID );
|
319 |
+
if(!empty($postcat)){
|
320 |
+
if(is_object($postcat[0])){
|
321 |
+
$current_category = $postcat[0]->cat_ID;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
}
|
326 |
+
|
327 |
if ( $comparison == 'equal') {
|
328 |
if ( $data == $current_category ) {
|
329 |
$result = true;
|
337 |
break;
|
338 |
// Post Format
|
339 |
case 'post_format':
|
340 |
+
|
341 |
+
$current_post_format = '';
|
342 |
+
|
343 |
+
if(is_object($post)){
|
344 |
+
|
345 |
+
$current_post_format = get_post_format( $post->ID );
|
346 |
+
|
347 |
+
}
|
348 |
+
|
349 |
if ( $current_post_format === false ) {
|
350 |
$current_post_format = 'standard';
|
351 |
}
|
388 |
|
389 |
// Page Template
|
390 |
case 'page_template':
|
391 |
+
|
392 |
+
$current_page_template = '';
|
393 |
+
|
394 |
+
if(is_object($post)){
|
395 |
+
|
396 |
+
$current_page_template = get_page_template_slug( $post->ID );
|
397 |
+
|
398 |
+
}
|
399 |
+
|
400 |
if ( $current_page_template == false ) {
|
401 |
$current_page_template = 'default';
|
402 |
}
|
439 |
}
|
440 |
}
|
441 |
if($result==true && isset( $input['key_4'] ) && $input['key_4'] !='all'){
|
442 |
+
|
443 |
$term_data = $input['key_4'];
|
444 |
+
$terms = wp_get_post_terms( $post->ID ,$data);
|
445 |
+
|
446 |
if(count($terms)>0){
|
447 |
+
|
448 |
$termChoices = array();
|
449 |
+
|
450 |
foreach ($terms as $key => $termvalue) {
|
451 |
+
|
452 |
$termChoices[] = $termvalue->slug;
|
453 |
+
|
454 |
}
|
455 |
+
|
456 |
}
|
457 |
+
|
458 |
$result = false;
|
459 |
+
|
460 |
if(in_array($term_data, $termChoices)){
|
461 |
$result = true;
|
462 |
}
|
output/function.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
function saswp_remove_amp_default_structure_data($metadata){
|
3 |
return '';
|
4 |
}
|
|
|
5 |
add_filter( 'amp_init', 'saswp_structured_data' );
|
6 |
function saswp_structured_data()
|
7 |
{
|
@@ -214,3 +215,240 @@ function saswp_memberpress_form_update($form){
|
|
214 |
return $form;
|
215 |
}
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
function saswp_remove_amp_default_structure_data($metadata){
|
3 |
return '';
|
4 |
}
|
5 |
+
|
6 |
add_filter( 'amp_init', 'saswp_structured_data' );
|
7 |
function saswp_structured_data()
|
8 |
{
|
215 |
return $form;
|
216 |
}
|
217 |
|
218 |
+
function saswp_remove_warnings($data, $index, $type){
|
219 |
+
|
220 |
+
if($type == 'saswp_array'){
|
221 |
+
|
222 |
+
if(isset($data[$index])){
|
223 |
+
return $data[$index][0];
|
224 |
+
}else{
|
225 |
+
return '';
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
if($type == 'saswp_string'){
|
230 |
+
|
231 |
+
if(isset($data[$index])){
|
232 |
+
return $data[$index];
|
233 |
+
}else{
|
234 |
+
return '';
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Gets the total word count and expected time to read the article
|
242 |
+
* @return type array
|
243 |
+
*/
|
244 |
+
function saswp_reading_time_and_word_count() {
|
245 |
+
|
246 |
+
// Predefined words-per-minute rate.
|
247 |
+
$words_per_minute = 225;
|
248 |
+
$words_per_second = $words_per_minute / 60;
|
249 |
+
|
250 |
+
// Count the words in the content.
|
251 |
+
$word_count = 0;
|
252 |
+
$text = trim( strip_tags( get_the_content() ) );
|
253 |
+
$word_count = substr_count( "$text ", ' ' );
|
254 |
+
|
255 |
+
// How many seconds (total)?
|
256 |
+
$seconds = floor( $word_count / $words_per_second );
|
257 |
+
|
258 |
+
return array('word_count' => $word_count, 'timerequired' => $seconds);
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Extracting the value of star ratings plugins on current post
|
263 |
+
* @global type $sd_data
|
264 |
+
* @param type $id
|
265 |
+
* @return type array
|
266 |
+
*/
|
267 |
+
function saswp_extract_kk_star_ratings($id){
|
268 |
+
|
269 |
+
global $sd_data;
|
270 |
+
|
271 |
+
if(isset($sd_data['saswp-kk-star-raring']) && $sd_data['saswp-kk-star-raring'] == 1){
|
272 |
+
|
273 |
+
$best = get_option('kksr_stars');
|
274 |
+
$score = get_post_meta($id, '_kksr_ratings', true) ? ((int) get_post_meta($id, '_kksr_ratings', true)) : 0;
|
275 |
+
$votes = get_post_meta($id, '_kksr_casts', true) ? ((int) get_post_meta($id, '_kksr_casts', true)) : 0;
|
276 |
+
$avg = $score && $votes ? round((float)(($score/$votes)*($best/5)), 1) : 0;
|
277 |
+
$per = $score && $votes ? round((float)((($score/$votes)/5)*100), 2) : 0;
|
278 |
+
|
279 |
+
if($votes>0){
|
280 |
+
|
281 |
+
return compact('best', 'score', 'votes', 'avg', 'per');
|
282 |
+
|
283 |
+
}else{
|
284 |
+
|
285 |
+
return array();
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
}else{
|
290 |
+
|
291 |
+
return array();
|
292 |
+
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Gets all the comments of current post
|
298 |
+
* @param type $post_id
|
299 |
+
* @return type array
|
300 |
+
*/
|
301 |
+
function saswp_get_comments($post_id){
|
302 |
+
|
303 |
+
$comment_count = get_comments_number( $post_id );
|
304 |
+
|
305 |
+
if ( $comment_count < 1 ) {
|
306 |
+
return array();
|
307 |
+
}
|
308 |
+
$comments = array();
|
309 |
+
|
310 |
+
$count = apply_filters( 'saswp_do_comments', '10'); // default = 10
|
311 |
+
|
312 |
+
$post_comments = get_comments( array(
|
313 |
+
'post_id' => $post_id,
|
314 |
+
'number' => $count,
|
315 |
+
'status' => 'approve',
|
316 |
+
'type' => 'comment'
|
317 |
+
)
|
318 |
+
);
|
319 |
+
|
320 |
+
if ( count( $post_comments ) ) {
|
321 |
+
|
322 |
+
foreach ( $post_comments as $comment ) {
|
323 |
+
|
324 |
+
$comments[] = array (
|
325 |
+
'@type' => 'Comment',
|
326 |
+
'dateCreated' => $comment->comment_date,
|
327 |
+
'description' => $comment->comment_content,
|
328 |
+
'author' => array (
|
329 |
+
'@type' => 'Person',
|
330 |
+
'name' => $comment->comment_author,
|
331 |
+
'url' => $comment->comment_author_url,
|
332 |
+
),
|
333 |
+
);
|
334 |
+
}
|
335 |
+
|
336 |
+
return apply_filters( 'saswp_filter_comments', $comments );
|
337 |
+
}
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
function saswp_structure_data_access_scripts($data){
|
342 |
+
|
343 |
+
if ( empty( $data['amp_component_scripts']['amp-access'] ) ) {
|
344 |
+
$data['amp_component_scripts']['amp-access'] = 'https://cdn.ampproject.org/v0/amp-access-0.1.js';
|
345 |
+
}
|
346 |
+
if ( empty( $data['amp_component_scripts']['amp-analytics'] ) ) {
|
347 |
+
$data['amp_component_scripts']['amp-analytics'] = "https://cdn.ampproject.org/v0/amp-analytics-0.1.js";
|
348 |
+
}
|
349 |
+
if ( empty( $data['amp_component_scripts']['amp-mustache'] ) ) {
|
350 |
+
$data['amp_component_scripts']['amp-mustache'] = "https://cdn.ampproject.org/v0/amp-mustache-0.1.js";
|
351 |
+
}
|
352 |
+
return $data;
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
function sd_is_blog() {
|
357 |
+
|
358 |
+
return ( is_author() || is_category() || is_tag() || is_date() || is_home() || is_single() ) && 'post' == get_post_type();
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
function saswp_get_schema_data($schema_id, $schema_key){
|
363 |
+
|
364 |
+
$details = array();
|
365 |
+
|
366 |
+
if($schema_id && $schema_key){
|
367 |
+
|
368 |
+
$details = esc_sql ( get_post_meta($schema_id, $schema_key, true));
|
369 |
+
|
370 |
+
}
|
371 |
+
|
372 |
+
return $details;
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Function generates list items for the breadcrumbs schema markup
|
377 |
+
* @global type $sd_data
|
378 |
+
* @return array
|
379 |
+
*/
|
380 |
+
function saswp_list_items_generator(){
|
381 |
+
|
382 |
+
global $sd_data;
|
383 |
+
$bc_titles = array();
|
384 |
+
$bc_links = array();
|
385 |
+
|
386 |
+
if(isset($sd_data['titles'])){
|
387 |
+
$bc_titles = $sd_data['titles'];
|
388 |
+
}
|
389 |
+
if(isset($sd_data['links'])){
|
390 |
+
$bc_links = $sd_data['links'];
|
391 |
+
}
|
392 |
+
|
393 |
+
$j = 1;
|
394 |
+
$i = 0;
|
395 |
+
$breadcrumbslist = array();
|
396 |
+
|
397 |
+
if(is_single()){
|
398 |
+
|
399 |
+
if(isset($bc_titles)){
|
400 |
+
|
401 |
+
for($i=0;$i<sizeof($bc_titles);$i++){
|
402 |
+
|
403 |
+
$breadcrumbslist[] = array(
|
404 |
+
'@type' => 'ListItem',
|
405 |
+
'position' => $j,
|
406 |
+
'item' => array(
|
407 |
+
'@id' => $bc_links[$i],
|
408 |
+
'name' => $bc_titles[$i],
|
409 |
+
),
|
410 |
+
);
|
411 |
+
|
412 |
+
$j++;
|
413 |
+
}
|
414 |
+
|
415 |
+
}
|
416 |
+
|
417 |
+
}
|
418 |
+
if(is_page()){
|
419 |
+
|
420 |
+
for($i=0;$i<sizeof($bc_titles);$i++){
|
421 |
+
|
422 |
+
$breadcrumbslist[] = array(
|
423 |
+
'@type' => 'ListItem',
|
424 |
+
'position' => $j,
|
425 |
+
'item' => array(
|
426 |
+
'@id' => $bc_links[$i],
|
427 |
+
'name' => $bc_titles[$i],
|
428 |
+
),
|
429 |
+
);
|
430 |
+
|
431 |
+
$j++;
|
432 |
+
|
433 |
+
}
|
434 |
+
|
435 |
+
}
|
436 |
+
if(is_archive()){
|
437 |
+
|
438 |
+
for($i=0;$i<sizeof($bc_titles);$i++){
|
439 |
+
|
440 |
+
$breadcrumbslist[] = array(
|
441 |
+
'@type' => 'ListItem',
|
442 |
+
'position' => $j,
|
443 |
+
'item' => array(
|
444 |
+
'@id' => $bc_links[$i],
|
445 |
+
'name' => $bc_titles[$i],
|
446 |
+
),
|
447 |
+
);
|
448 |
+
$j++;
|
449 |
+
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
return $breadcrumbslist;
|
454 |
+
}
|
output/output.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
if (! defined('ABSPATH') ) exit;
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
function saswp_kb_schema_output() {
|
5 |
|
6 |
global $sd_data;
|
@@ -176,12 +180,11 @@ function saswp_kb_schema_output() {
|
|
176 |
return json_encode($input);
|
177 |
}
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
function saswp_schema_output() {
|
186 |
|
187 |
global $sd_data;
|
@@ -199,14 +202,16 @@ function saswp_schema_output() {
|
|
199 |
$schema_options = saswp_remove_warnings($schemaConditionals, 'schema_options', 'saswp_string');
|
200 |
$schema_type = saswp_remove_warnings($schemaConditionals, 'schema_type', 'saswp_string');
|
201 |
$schema_post_id = saswp_remove_warnings($schemaConditionals, 'post_id', 'saswp_string');
|
202 |
-
|
203 |
-
|
204 |
-
$
|
205 |
-
$
|
206 |
-
$
|
|
|
207 |
|
208 |
$service_object = new saswp_output_service();
|
209 |
$default_logo = $service_object->saswp_get_publisher(true);
|
|
|
210 |
|
211 |
if(!empty($default_logo)){
|
212 |
|
@@ -225,11 +230,11 @@ function saswp_schema_output() {
|
|
225 |
$site_name = get_bloginfo();
|
226 |
|
227 |
}
|
228 |
-
|
229 |
// Generate author id
|
230 |
$author_id = get_the_author_meta('ID');
|
231 |
|
232 |
-
|
233 |
$image_id = get_post_thumbnail_id();
|
234 |
$image_details = wp_get_attachment_image_src($image_id, 'full');
|
235 |
$author_details = get_avatar_data($author_id);
|
@@ -290,10 +295,52 @@ function saswp_schema_output() {
|
|
290 |
);
|
291 |
|
292 |
}
|
293 |
-
|
294 |
$service_object = new saswp_output_service();
|
|
|
|
|
295 |
$extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
if( 'Blogposting' === $schema_type){
|
298 |
|
299 |
$input1 = array(
|
@@ -308,19 +355,16 @@ function saswp_schema_output() {
|
|
308 |
'datePublished' => $date,
|
309 |
'dateModified' => $modified_date,
|
310 |
'author' => array(
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
'@type' => 'Organization',
|
315 |
-
'logo' => array(
|
316 |
-
'@type' => 'ImageObject',
|
317 |
-
'url' => $logo,
|
318 |
-
'width' => $width,
|
319 |
-
'height' => $height,
|
320 |
-
),
|
321 |
-
'name' => $site_name,
|
322 |
-
),
|
323 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
325 |
$service = new saswp_output_service();
|
326 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
@@ -357,18 +401,68 @@ function saswp_schema_output() {
|
|
357 |
'author' => array(
|
358 |
'@type' => 'Person',
|
359 |
'name' => $aurthor_name
|
360 |
-
),
|
361 |
-
'Publisher' => array(
|
362 |
-
'@type' => 'Organization',
|
363 |
-
'logo' => array(
|
364 |
-
'@type' => 'ImageObject',
|
365 |
-
'url' => $logo,
|
366 |
-
'width' => $width,
|
367 |
-
'height' => $height,
|
368 |
-
),
|
369 |
-
'name' => $site_name,
|
370 |
-
),
|
371 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
373 |
$service = new saswp_output_service();
|
374 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
@@ -470,22 +564,18 @@ function saswp_schema_output() {
|
|
470 |
'height' => saswp_remove_warnings($author_details, 'height', 'saswp_string'),
|
471 |
'width' => saswp_remove_warnings($author_details, 'width', 'saswp_string')
|
472 |
),
|
473 |
-
),
|
474 |
-
'Publisher' => array(
|
475 |
-
'@type' => 'Organization',
|
476 |
-
'logo' => array(
|
477 |
-
'@type' => 'ImageObject',
|
478 |
-
'url' => $logo,
|
479 |
-
'width' => $width,
|
480 |
-
'height' => $height,
|
481 |
-
),
|
482 |
-
'name' => $site_name,
|
483 |
-
),
|
484 |
|
485 |
|
486 |
),
|
487 |
|
488 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
490 |
$service = new saswp_output_service();
|
491 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
@@ -513,19 +603,7 @@ function saswp_schema_output() {
|
|
513 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
514 |
}
|
515 |
}
|
516 |
-
|
517 |
-
// if( 'JobPosting' === $schema_type){
|
518 |
-
// global $post;
|
519 |
-
// $service_object = new saswp_output_service();
|
520 |
-
// $input1 = $service_object->saswp_wp_job_manager_details($post);
|
521 |
-
//
|
522 |
-
// if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
523 |
-
// $service = new saswp_output_service();
|
524 |
-
// $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
525 |
-
// }
|
526 |
-
// }
|
527 |
-
|
528 |
-
|
529 |
if( 'Product' === $schema_type){
|
530 |
|
531 |
$service = new saswp_output_service();
|
@@ -696,19 +774,14 @@ function saswp_schema_output() {
|
|
696 |
'url' => saswp_remove_warnings($author_details, 'url', 'saswp_string'),
|
697 |
'height' => saswp_remove_warnings($author_details, 'height', 'saswp_string'),
|
698 |
'width' => saswp_remove_warnings($author_details, 'width', 'saswp_string')
|
699 |
-
)
|
700 |
-
)
|
701 |
-
'Publisher' => array(
|
702 |
-
'@type' => 'Organization',
|
703 |
-
'logo' => array(
|
704 |
-
'@type' => 'ImageObject',
|
705 |
-
'url' => $logo,
|
706 |
-
'width' => $width,
|
707 |
-
'height' => $height,
|
708 |
-
),
|
709 |
-
'name' => $site_name,
|
710 |
-
),
|
711 |
);
|
|
|
|
|
|
|
|
|
|
|
712 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
713 |
$service = new saswp_output_service();
|
714 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
@@ -824,7 +897,7 @@ function saswp_schema_output() {
|
|
824 |
if(isset($schema_data['saswp_review_schema_item_type'])){
|
825 |
|
826 |
|
827 |
-
$review_author =
|
828 |
|
829 |
if(isset($schema_data['saswp_review_schema_author'])){
|
830 |
|
@@ -851,17 +924,12 @@ function saswp_schema_output() {
|
|
851 |
|
852 |
}
|
853 |
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
$input1['Publisher']['logo']['width'] = $width;
|
861 |
-
$input1['Publisher']['logo']['height'] = $height;
|
862 |
-
|
863 |
-
}
|
864 |
-
|
865 |
if(isset($schema_data['saswp_review_schema_description'])){
|
866 |
|
867 |
$input1['reviewBody'] = $schema_data['saswp_review_schema_description'];
|
@@ -1076,19 +1144,13 @@ function saswp_schema_output() {
|
|
1076 |
'height' => saswp_remove_warnings($author_details, 'height', 'saswp_string'),
|
1077 |
'width' => saswp_remove_warnings($author_details, 'width', 'saswp_string')
|
1078 |
),
|
1079 |
-
)
|
1080 |
-
'Publisher' => array(
|
1081 |
-
'@type' => 'Organization',
|
1082 |
-
'logo' => array(
|
1083 |
-
'@type' => 'ImageObject',
|
1084 |
-
'url' => $logo,
|
1085 |
-
'width' => $width,
|
1086 |
-
'height' => $height,
|
1087 |
-
),
|
1088 |
-
'name' => $site_name,
|
1089 |
-
),
|
1090 |
-
|
1091 |
);
|
|
|
|
|
|
|
|
|
|
|
1092 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
1093 |
$service = new saswp_output_service();
|
1094 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
@@ -1194,6 +1256,17 @@ function saswp_schema_output() {
|
|
1194 |
$input1['hasMenu'] = $business_details['local_menu'];
|
1195 |
}
|
1196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1197 |
|
1198 |
//Check for Featured Image
|
1199 |
|
@@ -1243,6 +1316,12 @@ function saswp_schema_output() {
|
|
1243 |
return $all_schema_output;
|
1244 |
}
|
1245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1246 |
function saswp_post_specific_schema_output() {
|
1247 |
|
1248 |
global $post;
|
@@ -1284,7 +1363,8 @@ function saswp_post_specific_schema_output() {
|
|
1284 |
$schema_enable = get_post_meta($post->ID, 'saswp_enable_disable_schema', true);
|
1285 |
|
1286 |
if($all_schemas){
|
1287 |
-
|
|
|
1288 |
|
1289 |
$schema_id = $schema;
|
1290 |
$schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
|
@@ -1381,6 +1461,41 @@ function saswp_post_specific_schema_output() {
|
|
1381 |
}
|
1382 |
}
|
1383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
if( 'Blogposting' === $schema_type){
|
1385 |
|
1386 |
$slogo = get_post_meta( get_the_ID(), 'saswp_blogposting_organization_logo_'.$schema_id.'_detail',true);
|
@@ -1449,6 +1564,44 @@ function saswp_post_specific_schema_output() {
|
|
1449 |
$input1 = array_merge($input1, $extra_theme_review);
|
1450 |
}
|
1451 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1452 |
|
1453 |
if( 'WebPage' === $schema_type){
|
1454 |
|
@@ -2247,97 +2400,12 @@ function saswp_post_specific_schema_output() {
|
|
2247 |
return $all_schema_output;
|
2248 |
}
|
2249 |
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
$data['amp_component_scripts']['amp-analytics'] = "https://cdn.ampproject.org/v0/amp-analytics-0.1.js";
|
2257 |
-
}
|
2258 |
-
if ( empty( $data['amp_component_scripts']['amp-mustache'] ) ) {
|
2259 |
-
$data['amp_component_scripts']['amp-mustache'] = "https://cdn.ampproject.org/v0/amp-mustache-0.1.js";
|
2260 |
-
}
|
2261 |
-
return $data;
|
2262 |
-
|
2263 |
-
}
|
2264 |
-
|
2265 |
-
function saswp_list_items_generator(){
|
2266 |
-
|
2267 |
-
global $sd_data;
|
2268 |
-
$bc_titles = array();
|
2269 |
-
$bc_links = array();
|
2270 |
-
|
2271 |
-
if(isset($sd_data['titles'])){
|
2272 |
-
$bc_titles = $sd_data['titles'];
|
2273 |
-
}
|
2274 |
-
if(isset($sd_data['links'])){
|
2275 |
-
$bc_links = $sd_data['links'];
|
2276 |
-
}
|
2277 |
-
|
2278 |
-
$j = 1;
|
2279 |
-
$i = 0;
|
2280 |
-
$breadcrumbslist = array();
|
2281 |
-
|
2282 |
-
if(is_single()){
|
2283 |
-
|
2284 |
-
if(isset($bc_titles)){
|
2285 |
-
|
2286 |
-
for($i=0;$i<sizeof($bc_titles);$i++){
|
2287 |
-
|
2288 |
-
$breadcrumbslist[] = array(
|
2289 |
-
'@type' => 'ListItem',
|
2290 |
-
'position' => $j,
|
2291 |
-
'item' => array(
|
2292 |
-
'@id' => $bc_links[$i],
|
2293 |
-
'name' => $bc_titles[$i],
|
2294 |
-
),
|
2295 |
-
);
|
2296 |
-
|
2297 |
-
$j++;
|
2298 |
-
}
|
2299 |
-
|
2300 |
-
}
|
2301 |
-
|
2302 |
-
}
|
2303 |
-
if(is_page()){
|
2304 |
-
|
2305 |
-
for($i=0;$i<sizeof($bc_titles);$i++){
|
2306 |
-
|
2307 |
-
$breadcrumbslist[] = array(
|
2308 |
-
'@type' => 'ListItem',
|
2309 |
-
'position' => $j,
|
2310 |
-
'item' => array(
|
2311 |
-
'@id' => $bc_links[$i],
|
2312 |
-
'name' => $bc_titles[$i],
|
2313 |
-
),
|
2314 |
-
);
|
2315 |
-
|
2316 |
-
$j++;
|
2317 |
-
|
2318 |
-
}
|
2319 |
-
|
2320 |
-
}
|
2321 |
-
if(is_archive()){
|
2322 |
-
|
2323 |
-
for($i=0;$i<sizeof($bc_titles);$i++){
|
2324 |
-
|
2325 |
-
$breadcrumbslist[] = array(
|
2326 |
-
'@type' => 'ListItem',
|
2327 |
-
'position' => $j,
|
2328 |
-
'item' => array(
|
2329 |
-
'@id' => $bc_links[$i],
|
2330 |
-
'name' => $bc_titles[$i],
|
2331 |
-
),
|
2332 |
-
);
|
2333 |
-
$j++;
|
2334 |
-
|
2335 |
-
}
|
2336 |
-
}
|
2337 |
-
|
2338 |
-
return $breadcrumbslist;
|
2339 |
-
}
|
2340 |
-
|
2341 |
function saswp_schema_breadcrumb_output($sd_data){
|
2342 |
|
2343 |
global $sd_data;
|
@@ -2350,7 +2418,7 @@ function saswp_schema_breadcrumb_output($sd_data){
|
|
2350 |
|
2351 |
if(!empty($bread_crumb_list)){
|
2352 |
|
2353 |
-
|
2354 |
'@context' => 'http://schema.org',
|
2355 |
'@type' => 'BreadcrumbList' ,
|
2356 |
'itemListElement' => $bread_crumb_list,
|
@@ -2365,6 +2433,10 @@ function saswp_schema_breadcrumb_output($sd_data){
|
|
2365 |
}
|
2366 |
}
|
2367 |
|
|
|
|
|
|
|
|
|
2368 |
function saswp_kb_website_output(){
|
2369 |
|
2370 |
$input = array();
|
@@ -2390,7 +2462,13 @@ function saswp_kb_website_output(){
|
|
2390 |
|
2391 |
return json_encode($input);
|
2392 |
}
|
2393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2394 |
function saswp_archive_output(){
|
2395 |
|
2396 |
global $query_string, $sd_data;
|
@@ -2494,13 +2572,13 @@ function saswp_archive_output(){
|
|
2494 |
}
|
2495 |
|
2496 |
/**
|
2497 |
-
*
|
2498 |
* @global type $post
|
2499 |
* @global type $sd_data
|
2500 |
-
* @return type
|
2501 |
*/
|
2502 |
-
function saswp_author_output()
|
2503 |
-
|
2504 |
global $post, $sd_data;
|
2505 |
$post_id ='';
|
2506 |
|
@@ -2556,12 +2634,12 @@ function saswp_author_output()
|
|
2556 |
}
|
2557 |
|
2558 |
/**
|
2559 |
-
*
|
2560 |
* @global type $sd_data
|
2561 |
-
* @return type
|
2562 |
*/
|
2563 |
-
function saswp_about_page_output()
|
2564 |
-
|
2565 |
global $sd_data;
|
2566 |
$feature_image = array();
|
2567 |
$publisher = array();
|
@@ -2598,10 +2676,58 @@ function saswp_about_page_output()
|
|
2598 |
}
|
2599 |
|
2600 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2601 |
/**
|
2602 |
* SiteNavigation Schema Markup
|
2603 |
* @global type $sd_data
|
2604 |
-
* @return type
|
2605 |
*/
|
2606 |
function saswp_site_navigation_output(){
|
2607 |
|
@@ -2672,168 +2798,4 @@ function saswp_site_navigation_output(){
|
|
2672 |
}
|
2673 |
|
2674 |
return $input;
|
2675 |
-
}
|
2676 |
-
// For Contact Page
|
2677 |
-
function saswp_contact_page_output()
|
2678 |
-
{
|
2679 |
-
global $sd_data;
|
2680 |
-
$feature_image = array();
|
2681 |
-
$publisher = array();
|
2682 |
-
|
2683 |
-
if(isset($sd_data['sd_contact_page']) && $sd_data['sd_contact_page'] == get_the_ID()){
|
2684 |
-
|
2685 |
-
$service_object = new saswp_output_service();
|
2686 |
-
$feature_image = $service_object->saswp_get_fetaure_image();
|
2687 |
-
$publisher = $service_object->saswp_get_publisher();
|
2688 |
-
|
2689 |
-
$input = array(
|
2690 |
-
|
2691 |
-
"@context" => "http://schema.org",
|
2692 |
-
"@type" => "ContactPage",
|
2693 |
-
"mainEntityOfPage" => array(
|
2694 |
-
"@type" => "WebPage",
|
2695 |
-
"@id" => get_permalink(),
|
2696 |
-
),
|
2697 |
-
"url" => get_permalink(),
|
2698 |
-
"headline" => get_the_title(),
|
2699 |
-
'description' => strip_tags(get_the_excerpt()),
|
2700 |
-
);
|
2701 |
-
|
2702 |
-
if(!empty($feature_image)){
|
2703 |
-
|
2704 |
-
$input = array_merge($input, $feature_image);
|
2705 |
-
|
2706 |
-
}
|
2707 |
-
|
2708 |
-
if(!empty($publisher)){
|
2709 |
-
|
2710 |
-
$input = array_merge($input, $publisher);
|
2711 |
-
|
2712 |
-
}
|
2713 |
-
return json_encode($input);
|
2714 |
-
|
2715 |
-
}
|
2716 |
-
|
2717 |
-
}
|
2718 |
-
|
2719 |
-
|
2720 |
-
function saswp_get_comments($post_id){
|
2721 |
-
|
2722 |
-
$comment_count = get_comments_number( $post_id );
|
2723 |
-
|
2724 |
-
if ( $comment_count < 1 ) {
|
2725 |
-
return array();
|
2726 |
-
}
|
2727 |
-
$comments = array();
|
2728 |
-
|
2729 |
-
$count = apply_filters( 'saswp_do_comments', '10'); // default = 10
|
2730 |
-
|
2731 |
-
$post_comments = get_comments( array(
|
2732 |
-
'post_id' => $post_id,
|
2733 |
-
'number' => $count,
|
2734 |
-
'status' => 'approve',
|
2735 |
-
'type' => 'comment'
|
2736 |
-
)
|
2737 |
-
);
|
2738 |
-
|
2739 |
-
if ( count( $post_comments ) ) {
|
2740 |
-
|
2741 |
-
foreach ( $post_comments as $comment ) {
|
2742 |
-
|
2743 |
-
$comments[] = array (
|
2744 |
-
'@type' => 'Comment',
|
2745 |
-
'dateCreated' => $comment->comment_date,
|
2746 |
-
'description' => $comment->comment_content,
|
2747 |
-
'author' => array (
|
2748 |
-
'@type' => 'Person',
|
2749 |
-
'name' => $comment->comment_author,
|
2750 |
-
'url' => $comment->comment_author_url,
|
2751 |
-
),
|
2752 |
-
);
|
2753 |
-
}
|
2754 |
-
|
2755 |
-
return apply_filters( 'saswp_filter_comments', $comments );
|
2756 |
-
}
|
2757 |
-
|
2758 |
-
}
|
2759 |
-
|
2760 |
-
function saswp_get_schema_data($schema_id, $schema_key){
|
2761 |
-
|
2762 |
-
$details = array();
|
2763 |
-
|
2764 |
-
if($schema_id && $schema_key){
|
2765 |
-
|
2766 |
-
$details = esc_sql ( get_post_meta($schema_id, $schema_key, true));
|
2767 |
-
|
2768 |
-
}
|
2769 |
-
|
2770 |
-
return $details;
|
2771 |
-
}
|
2772 |
-
|
2773 |
-
function saswp_extract_kk_star_ratings($id){
|
2774 |
-
|
2775 |
-
global $sd_data;
|
2776 |
-
|
2777 |
-
if(isset($sd_data['saswp-kk-star-raring']) && $sd_data['saswp-kk-star-raring'] == 1){
|
2778 |
-
|
2779 |
-
$best = get_option('kksr_stars');
|
2780 |
-
$score = get_post_meta($id, '_kksr_ratings', true) ? ((int) get_post_meta($id, '_kksr_ratings', true)) : 0;
|
2781 |
-
$votes = get_post_meta($id, '_kksr_casts', true) ? ((int) get_post_meta($id, '_kksr_casts', true)) : 0;
|
2782 |
-
$avg = $score && $votes ? round((float)(($score/$votes)*($best/5)), 1) : 0;
|
2783 |
-
$per = $score && $votes ? round((float)((($score/$votes)/5)*100), 2) : 0;
|
2784 |
-
|
2785 |
-
if($votes>0){
|
2786 |
-
|
2787 |
-
return compact('best', 'score', 'votes', 'avg', 'per');
|
2788 |
-
|
2789 |
-
}else{
|
2790 |
-
|
2791 |
-
return array();
|
2792 |
-
|
2793 |
-
}
|
2794 |
-
|
2795 |
-
}else{
|
2796 |
-
|
2797 |
-
return array();
|
2798 |
-
|
2799 |
-
}
|
2800 |
-
}
|
2801 |
-
|
2802 |
-
function saswp_reading_time_and_word_count() {
|
2803 |
-
|
2804 |
-
// Predefined words-per-minute rate.
|
2805 |
-
$words_per_minute = 225;
|
2806 |
-
$words_per_second = $words_per_minute / 60;
|
2807 |
-
|
2808 |
-
// Count the words in the content.
|
2809 |
-
$word_count = 0;
|
2810 |
-
$text = trim( strip_tags( get_the_content() ) );
|
2811 |
-
$word_count = substr_count( "$text ", ' ' );
|
2812 |
-
|
2813 |
-
// How many seconds (total)?
|
2814 |
-
$seconds = floor( $word_count / $words_per_second );
|
2815 |
-
|
2816 |
-
return array('word_count' => $word_count, 'timerequired' => $seconds);
|
2817 |
-
}
|
2818 |
-
|
2819 |
-
|
2820 |
-
function saswp_remove_warnings($data, $index, $type){
|
2821 |
-
|
2822 |
-
if($type == 'saswp_array'){
|
2823 |
-
|
2824 |
-
if(isset($data[$index])){
|
2825 |
-
return $data[$index][0];
|
2826 |
-
}else{
|
2827 |
-
return '';
|
2828 |
-
}
|
2829 |
-
}
|
2830 |
-
|
2831 |
-
if($type == 'saswp_string'){
|
2832 |
-
|
2833 |
-
if(isset($data[$index])){
|
2834 |
-
return $data[$index];
|
2835 |
-
}else{
|
2836 |
-
return '';
|
2837 |
-
}
|
2838 |
-
}
|
2839 |
-
}
|
1 |
<?php
|
2 |
if (! defined('ABSPATH') ) exit;
|
3 |
+
/**
|
4 |
+
* Function generates knowledge graph schema
|
5 |
+
* @global type $sd_data
|
6 |
+
* @return type json
|
7 |
+
*/
|
8 |
function saswp_kb_schema_output() {
|
9 |
|
10 |
global $sd_data;
|
180 |
return json_encode($input);
|
181 |
}
|
182 |
|
183 |
+
/**
|
184 |
+
* Function generates json markup for the all added schema type in the list
|
185 |
+
* @global type $sd_data
|
186 |
+
* @return type json
|
187 |
+
*/
|
|
|
188 |
function saswp_schema_output() {
|
189 |
|
190 |
global $sd_data;
|
202 |
$schema_options = saswp_remove_warnings($schemaConditionals, 'schema_options', 'saswp_string');
|
203 |
$schema_type = saswp_remove_warnings($schemaConditionals, 'schema_type', 'saswp_string');
|
204 |
$schema_post_id = saswp_remove_warnings($schemaConditionals, 'post_id', 'saswp_string');
|
205 |
+
|
206 |
+
|
207 |
+
$logo = '';
|
208 |
+
$height = '';
|
209 |
+
$width = '';
|
210 |
+
$site_name = '';
|
211 |
|
212 |
$service_object = new saswp_output_service();
|
213 |
$default_logo = $service_object->saswp_get_publisher(true);
|
214 |
+
$publisher = $service_object->saswp_get_publisher();
|
215 |
|
216 |
if(!empty($default_logo)){
|
217 |
|
230 |
$site_name = get_bloginfo();
|
231 |
|
232 |
}
|
233 |
+
|
234 |
// Generate author id
|
235 |
$author_id = get_the_author_meta('ID');
|
236 |
|
237 |
+
|
238 |
$image_id = get_post_thumbnail_id();
|
239 |
$image_details = wp_get_attachment_image_src($image_id, 'full');
|
240 |
$author_details = get_avatar_data($author_id);
|
295 |
);
|
296 |
|
297 |
}
|
298 |
+
|
299 |
$service_object = new saswp_output_service();
|
300 |
+
|
301 |
+
$extra_theme_review = array();
|
302 |
$extra_theme_review = $service_object->saswp_extra_theme_review_details(get_the_ID());
|
303 |
+
|
304 |
+
// $tagyeem_review = array();
|
305 |
+
// $tagyeem_review = $service_object->saswp_tagyeem_review_details(get_the_ID());
|
306 |
+
|
307 |
+
|
308 |
+
if( 'Course' === $schema_type){
|
309 |
+
|
310 |
+
$input1 = array(
|
311 |
+
'@context' => 'http://schema.org',
|
312 |
+
'@type' => $schema_type ,
|
313 |
+
'name' => get_the_title(),
|
314 |
+
'description' => strip_tags(get_the_excerpt()),
|
315 |
+
'url' => get_permalink(),
|
316 |
+
'datePublished' => $date,
|
317 |
+
'dateModified' => $modified_date,
|
318 |
+
'provider' => array(
|
319 |
+
'@type' => 'Organization',
|
320 |
+
'name' => get_bloginfo(),
|
321 |
+
'sameAs' => get_home_url()
|
322 |
+
)
|
323 |
+
);
|
324 |
+
|
325 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
326 |
+
$service = new saswp_output_service();
|
327 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
328 |
+
}
|
329 |
+
if(!empty($aggregateRating)){
|
330 |
+
$input1['aggregateRating'] = $aggregateRating;
|
331 |
+
}
|
332 |
+
if(!empty($kkstar_aggregateRating)){
|
333 |
+
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
334 |
+
}
|
335 |
+
if(!empty($extra_theme_review)){
|
336 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
337 |
+
}
|
338 |
+
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
339 |
+
$input1['comment'] = saswp_get_comments(get_the_ID());
|
340 |
+
}
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
if( 'Blogposting' === $schema_type){
|
345 |
|
346 |
$input1 = array(
|
355 |
'datePublished' => $date,
|
356 |
'dateModified' => $modified_date,
|
357 |
'author' => array(
|
358 |
+
'@type' => 'Person',
|
359 |
+
'name' => $aurthor_name
|
360 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
);
|
362 |
+
if(!empty($publisher)){
|
363 |
+
|
364 |
+
$input1 = array_merge($input1, $publisher);
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
369 |
$service = new saswp_output_service();
|
370 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
401 |
'author' => array(
|
402 |
'@type' => 'Person',
|
403 |
'name' => $aurthor_name
|
404 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
);
|
406 |
+
if(!empty($publisher)){
|
407 |
+
|
408 |
+
$input1 = array_merge($input1, $publisher);
|
409 |
+
|
410 |
+
}
|
411 |
+
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
412 |
+
$service = new saswp_output_service();
|
413 |
+
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
414 |
+
}
|
415 |
+
if(!empty($aggregateRating)){
|
416 |
+
$input1['aggregateRating'] = $aggregateRating;
|
417 |
+
}
|
418 |
+
if(!empty($kkstar_aggregateRating)){
|
419 |
+
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
420 |
+
}
|
421 |
+
if(!empty($extra_theme_review)){
|
422 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
423 |
+
}
|
424 |
+
if(isset($sd_data['saswp_comments_schema']) && $sd_data['saswp_comments_schema'] ==1){
|
425 |
+
$input1['comment'] = saswp_get_comments(get_the_ID());
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
if( 'SoftwareApplication' === $schema_type){
|
430 |
+
|
431 |
+
$schema_data = saswp_get_schema_data($schema_post_id, 'saswp_software_schema_details');
|
432 |
+
|
433 |
+
$input1 = array(
|
434 |
+
'@context' => 'http://schema.org',
|
435 |
+
'@type' => $schema_type ,
|
436 |
+
'name' => saswp_remove_warnings($schema_data, 'saswp_software_schema_name', 'saswp_string'),
|
437 |
+
'description' => saswp_remove_warnings($schema_data, 'saswp_software_schema_description', 'saswp_string'),
|
438 |
+
'operatingSystem' => saswp_remove_warnings($schema_data, 'saswp_software_schema_operating_system', 'saswp_string'),
|
439 |
+
'applicationCategory' => saswp_remove_warnings($schema_data, 'saswp_software_schema_application_category', 'saswp_string'),
|
440 |
+
'offers' => array(
|
441 |
+
'@type' => 'Offer',
|
442 |
+
'price' => saswp_remove_warnings($schema_data, 'saswp_software_schema_price', 'saswp_string'),
|
443 |
+
'priceCurrency' => saswp_remove_warnings($schema_data, 'saswp_software_schema_price_currency', 'saswp_string'),
|
444 |
+
),
|
445 |
+
'datePublished' => $date,
|
446 |
+
'dateModified' => $modified_date,
|
447 |
+
'author' => array(
|
448 |
+
'@type' => 'Person',
|
449 |
+
'name' => $aurthor_name
|
450 |
+
),
|
451 |
+
);
|
452 |
+
|
453 |
+
if(isset($schema_data['saswp_software_schema_rating']) && $schema_data['saswp_software_schema_rating'] >0 && isset($schema_data['saswp_software_schema_rating_count']) && $schema_data['saswp_software_schema_rating_count'] >0 && $schema_data['saswp_software_schema_enable_rating'] == 1){
|
454 |
+
$input1['aggregateRating'] = array(
|
455 |
+
'@type' => 'AggregateRating',
|
456 |
+
'ratingValue' => $schema_data['saswp_software_schema_rating'],
|
457 |
+
'ratingCount' => (int)$schema_data['saswp_software_schema_rating_count'],
|
458 |
+
);
|
459 |
+
}
|
460 |
+
|
461 |
+
if(!empty($publisher)){
|
462 |
+
|
463 |
+
$input1 = array_merge($input1, $publisher);
|
464 |
+
|
465 |
+
}
|
466 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
467 |
$service = new saswp_output_service();
|
468 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
564 |
'height' => saswp_remove_warnings($author_details, 'height', 'saswp_string'),
|
565 |
'width' => saswp_remove_warnings($author_details, 'width', 'saswp_string')
|
566 |
),
|
567 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
|
569 |
|
570 |
),
|
571 |
|
572 |
);
|
573 |
+
|
574 |
+
if(!empty($publisher)){
|
575 |
+
|
576 |
+
$input1['mainEntity'] = array_merge($input1['mainEntity'], $publisher);
|
577 |
+
|
578 |
+
}
|
579 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
580 |
$service = new saswp_output_service();
|
581 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
603 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
604 |
}
|
605 |
}
|
606 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
if( 'Product' === $schema_type){
|
608 |
|
609 |
$service = new saswp_output_service();
|
774 |
'url' => saswp_remove_warnings($author_details, 'url', 'saswp_string'),
|
775 |
'height' => saswp_remove_warnings($author_details, 'height', 'saswp_string'),
|
776 |
'width' => saswp_remove_warnings($author_details, 'width', 'saswp_string')
|
777 |
+
)
|
778 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
779 |
);
|
780 |
+
if(!empty($publisher)){
|
781 |
+
|
782 |
+
$input1 = array_merge($input1, $publisher);
|
783 |
+
|
784 |
+
}
|
785 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
786 |
$service = new saswp_output_service();
|
787 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
897 |
if(isset($schema_data['saswp_review_schema_item_type'])){
|
898 |
|
899 |
|
900 |
+
$review_author = $aurthor_name;
|
901 |
|
902 |
if(isset($schema_data['saswp_review_schema_author'])){
|
903 |
|
924 |
|
925 |
}
|
926 |
|
927 |
+
if(!empty($publisher)){
|
928 |
+
|
929 |
+
$input1 = array_merge($input1, $publisher);
|
930 |
+
|
931 |
+
}
|
932 |
+
|
|
|
|
|
|
|
|
|
|
|
933 |
if(isset($schema_data['saswp_review_schema_description'])){
|
934 |
|
935 |
$input1['reviewBody'] = $schema_data['saswp_review_schema_description'];
|
1144 |
'height' => saswp_remove_warnings($author_details, 'height', 'saswp_string'),
|
1145 |
'width' => saswp_remove_warnings($author_details, 'width', 'saswp_string')
|
1146 |
),
|
1147 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1148 |
);
|
1149 |
+
if(!empty($publisher)){
|
1150 |
+
|
1151 |
+
$input1 = array_merge($input1, $publisher);
|
1152 |
+
|
1153 |
+
}
|
1154 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
1155 |
$service = new saswp_output_service();
|
1156 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
1256 |
$input1['hasMenu'] = $business_details['local_menu'];
|
1257 |
}
|
1258 |
}
|
1259 |
+
|
1260 |
+
// if( 'JobPosting' === $schema_type){
|
1261 |
+
// global $post;
|
1262 |
+
// $service_object = new saswp_output_service();
|
1263 |
+
// $input1 = $service_object->saswp_wp_job_manager_details($post);
|
1264 |
+
//
|
1265 |
+
// if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
1266 |
+
// $service = new saswp_output_service();
|
1267 |
+
// $input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
1268 |
+
// }
|
1269 |
+
// }
|
1270 |
|
1271 |
//Check for Featured Image
|
1272 |
|
1316 |
return $all_schema_output;
|
1317 |
}
|
1318 |
|
1319 |
+
/**
|
1320 |
+
* Function generates json markup for the all added schema type in the current post metabox
|
1321 |
+
* @global type $post
|
1322 |
+
* @global type $sd_data
|
1323 |
+
* @return type json
|
1324 |
+
*/
|
1325 |
function saswp_post_specific_schema_output() {
|
1326 |
|
1327 |
global $post;
|
1363 |
$schema_enable = get_post_meta($post->ID, 'saswp_enable_disable_schema', true);
|
1364 |
|
1365 |
if($all_schemas){
|
1366 |
+
|
1367 |
+
foreach($all_schemas as $schema){
|
1368 |
|
1369 |
$schema_id = $schema;
|
1370 |
$schema_type = esc_sql ( get_post_meta($schema_id, 'schema_type', true) );
|
1461 |
}
|
1462 |
}
|
1463 |
|
1464 |
+
if( 'Course' === $schema_type){
|
1465 |
+
|
1466 |
+
$input1 = array(
|
1467 |
+
'@context' => 'http://schema.org',
|
1468 |
+
'@type' => $schema_type ,
|
1469 |
+
'name' => saswp_remove_warnings($all_post_meta, 'saswp_course_name_'.$schema_id, 'saswp_array'),
|
1470 |
+
'description' => saswp_remove_warnings($all_post_meta, 'saswp_course_description_'.$schema_id, 'saswp_array'),
|
1471 |
+
'url' => saswp_remove_warnings($all_post_meta, 'saswp_course_url_'.$schema_id, 'saswp_array'),
|
1472 |
+
'datePublished' => saswp_remove_warnings($all_post_meta, 'saswp_course_date_published_'.$schema_id, 'saswp_array'),
|
1473 |
+
'dateModified' => saswp_remove_warnings($all_post_meta, 'saswp_course_date_modified_'.$schema_id, 'saswp_array'),
|
1474 |
+
'provider' => array(
|
1475 |
+
'@type' => 'Organization',
|
1476 |
+
'name' => saswp_remove_warnings($all_post_meta, 'saswp_course_provider_name_'.$schema_id, 'saswp_array'),
|
1477 |
+
'sameAs' => saswp_remove_warnings($all_post_meta, 'saswp_course_sameas_'.$schema_id, 'saswp_array')
|
1478 |
+
)
|
1479 |
+
);
|
1480 |
+
|
1481 |
+
if(!empty($aggregateRating)){
|
1482 |
+
|
1483 |
+
$input1['mainEntity']['aggregateRating'] = $aggregateRating;
|
1484 |
+
|
1485 |
+
}
|
1486 |
+
if(!empty($kkstar_aggregateRating)){
|
1487 |
+
|
1488 |
+
$input1['mainEntity']['aggregateRating'] = $kkstar_aggregateRating;
|
1489 |
+
|
1490 |
+
}
|
1491 |
+
if(!empty($extra_theme_review)){
|
1492 |
+
|
1493 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1494 |
+
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
}
|
1498 |
+
|
1499 |
if( 'Blogposting' === $schema_type){
|
1500 |
|
1501 |
$slogo = get_post_meta( get_the_ID(), 'saswp_blogposting_organization_logo_'.$schema_id.'_detail',true);
|
1564 |
$input1 = array_merge($input1, $extra_theme_review);
|
1565 |
}
|
1566 |
}
|
1567 |
+
if( 'SoftwareApplication' === $schema_type){
|
1568 |
+
|
1569 |
+
$input1 = array(
|
1570 |
+
'@context' => 'http://schema.org',
|
1571 |
+
'@type' => $schema_type,
|
1572 |
+
'name' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_name_'.$schema_id, 'saswp_array'),
|
1573 |
+
'description' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_description_'.$schema_id, 'saswp_array'),
|
1574 |
+
'operatingSystem' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_operating_system_'.$schema_id, 'saswp_array'),
|
1575 |
+
'applicationCategory' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_application_category_'.$schema_id, 'saswp_array'),
|
1576 |
+
'offers' => array(
|
1577 |
+
'@type' => 'Offer',
|
1578 |
+
'price' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_price_'.$schema_id, 'saswp_array'),
|
1579 |
+
'priceCurrency' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_price_currency_'.$schema_id, 'saswp_array'),
|
1580 |
+
),
|
1581 |
+
'datePublished' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_date_published_'.$schema_id, 'saswp_array'),
|
1582 |
+
'dateModified' => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_date_modified_'.$schema_id, 'saswp_array'),
|
1583 |
+
|
1584 |
+
);
|
1585 |
+
|
1586 |
+
if(saswp_remove_warnings($all_post_meta, 'saswp_software_schema_enable_rating_'.$schema_id, 'saswp_array') == 1){
|
1587 |
+
|
1588 |
+
$input1['aggregateRating'] = array(
|
1589 |
+
"@type"=> "AggregateRating",
|
1590 |
+
"ratingValue" => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_rating_'.$schema_id, 'saswp_array'),
|
1591 |
+
"reviewCount" => saswp_remove_warnings($all_post_meta, 'saswp_software_schema_rating_count_'.$schema_id, 'saswp_array')
|
1592 |
+
);
|
1593 |
+
}
|
1594 |
+
|
1595 |
+
if(!empty($aggregateRating)){
|
1596 |
+
$input1['aggregateRating'] = $aggregateRating;
|
1597 |
+
}
|
1598 |
+
if(!empty($kkstar_aggregateRating)){
|
1599 |
+
$input1['aggregateRating'] = $kkstar_aggregateRating;
|
1600 |
+
}
|
1601 |
+
if(!empty($extra_theme_review)){
|
1602 |
+
$input1 = array_merge($input1, $extra_theme_review);
|
1603 |
+
}
|
1604 |
+
}
|
1605 |
|
1606 |
if( 'WebPage' === $schema_type){
|
1607 |
|
2400 |
return $all_schema_output;
|
2401 |
}
|
2402 |
|
2403 |
+
/**
|
2404 |
+
* Function generates breadcrumbs schema markup
|
2405 |
+
* @global type $sd_data
|
2406 |
+
* @param type $sd_data
|
2407 |
+
* @return type
|
2408 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2409 |
function saswp_schema_breadcrumb_output($sd_data){
|
2410 |
|
2411 |
global $sd_data;
|
2418 |
|
2419 |
if(!empty($bread_crumb_list)){
|
2420 |
|
2421 |
+
$input = array(
|
2422 |
'@context' => 'http://schema.org',
|
2423 |
'@type' => 'BreadcrumbList' ,
|
2424 |
'itemListElement' => $bread_crumb_list,
|
2433 |
}
|
2434 |
}
|
2435 |
|
2436 |
+
/**
|
2437 |
+
* Function generates website schema markup
|
2438 |
+
* @return type json
|
2439 |
+
*/
|
2440 |
function saswp_kb_website_output(){
|
2441 |
|
2442 |
$input = array();
|
2462 |
|
2463 |
return json_encode($input);
|
2464 |
}
|
2465 |
+
|
2466 |
+
/**
|
2467 |
+
* Function generates archive page schema markup in the form of CollectionPage schema type
|
2468 |
+
* @global type $query_string
|
2469 |
+
* @global type $sd_data
|
2470 |
+
* @return type json
|
2471 |
+
*/
|
2472 |
function saswp_archive_output(){
|
2473 |
|
2474 |
global $query_string, $sd_data;
|
2572 |
}
|
2573 |
|
2574 |
/**
|
2575 |
+
* Function generates author schema markup
|
2576 |
* @global type $post
|
2577 |
* @global type $sd_data
|
2578 |
+
* @return type json
|
2579 |
*/
|
2580 |
+
function saswp_author_output(){
|
2581 |
+
|
2582 |
global $post, $sd_data;
|
2583 |
$post_id ='';
|
2584 |
|
2634 |
}
|
2635 |
|
2636 |
/**
|
2637 |
+
* Function generates about page schema markup
|
2638 |
* @global type $sd_data
|
2639 |
+
* @return type json
|
2640 |
*/
|
2641 |
+
function saswp_about_page_output(){
|
2642 |
+
|
2643 |
global $sd_data;
|
2644 |
$feature_image = array();
|
2645 |
$publisher = array();
|
2676 |
}
|
2677 |
|
2678 |
}
|
2679 |
+
|
2680 |
+
/**
|
2681 |
+
* Function generates contact page schema markup
|
2682 |
+
* @global type $sd_data
|
2683 |
+
* @return type json
|
2684 |
+
*/
|
2685 |
+
function saswp_contact_page_output(){
|
2686 |
+
|
2687 |
+
global $sd_data;
|
2688 |
+
$feature_image = array();
|
2689 |
+
$publisher = array();
|
2690 |
+
|
2691 |
+
if(isset($sd_data['sd_contact_page']) && $sd_data['sd_contact_page'] == get_the_ID()){
|
2692 |
+
|
2693 |
+
$service_object = new saswp_output_service();
|
2694 |
+
$feature_image = $service_object->saswp_get_fetaure_image();
|
2695 |
+
$publisher = $service_object->saswp_get_publisher();
|
2696 |
+
|
2697 |
+
$input = array(
|
2698 |
+
|
2699 |
+
"@context" => "http://schema.org",
|
2700 |
+
"@type" => "ContactPage",
|
2701 |
+
"mainEntityOfPage" => array(
|
2702 |
+
"@type" => "WebPage",
|
2703 |
+
"@id" => get_permalink(),
|
2704 |
+
),
|
2705 |
+
"url" => get_permalink(),
|
2706 |
+
"headline" => get_the_title(),
|
2707 |
+
'description' => strip_tags(get_the_excerpt()),
|
2708 |
+
);
|
2709 |
+
|
2710 |
+
if(!empty($feature_image)){
|
2711 |
+
|
2712 |
+
$input = array_merge($input, $feature_image);
|
2713 |
+
|
2714 |
+
}
|
2715 |
+
|
2716 |
+
if(!empty($publisher)){
|
2717 |
+
|
2718 |
+
$input = array_merge($input, $publisher);
|
2719 |
+
|
2720 |
+
}
|
2721 |
+
return json_encode($input);
|
2722 |
+
|
2723 |
+
}
|
2724 |
+
|
2725 |
+
}
|
2726 |
+
|
2727 |
/**
|
2728 |
* SiteNavigation Schema Markup
|
2729 |
* @global type $sd_data
|
2730 |
+
* @return type array
|
2731 |
*/
|
2732 |
function saswp_site_navigation_output(){
|
2733 |
|
2798 |
}
|
2799 |
|
2800 |
return $input;
|
2801 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output/service.php
CHANGED
@@ -4,25 +4,40 @@ Class saswp_output_service{
|
|
4 |
public function __construct() {
|
5 |
|
6 |
}
|
|
|
|
|
|
|
7 |
public function saswp_service_hooks(){
|
8 |
|
9 |
add_action( 'wp_ajax_saswp_get_custom_meta_fields', array($this, 'saswp_get_custom_meta_fields'));
|
10 |
add_action( 'wp_ajax_saswp_get_schema_type_fields', array($this, 'saswp_get_schema_type_fields'));
|
11 |
|
12 |
}
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
|
15 |
|
16 |
-
|
17 |
|
|
|
|
|
18 |
if(!empty($custom_fields)){
|
19 |
|
20 |
$schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
|
21 |
|
22 |
foreach ($custom_fields as $key => $field){
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
switch ($schema_type) {
|
@@ -139,7 +154,36 @@ Class saswp_output_service{
|
|
139 |
$input1['author']['name'] = $custom_fields['saswp_audio_author_name'];
|
140 |
}
|
141 |
|
142 |
-
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
case 'NewsArticle':
|
145 |
|
@@ -299,7 +343,34 @@ Class saswp_output_service{
|
|
299 |
if(isset($custom_fields['saswp_tech_article_organization_logo'])){
|
300 |
$input1['Publisher']['logo']['url'] = $custom_fields['saswp_tech_article_organization_logo'];
|
301 |
}
|
302 |
-
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
case 'Recipe':
|
305 |
if(isset($custom_fields['saswp_recipe_url'])){
|
@@ -620,11 +691,15 @@ Class saswp_output_service{
|
|
620 |
default:
|
621 |
break;
|
622 |
}
|
623 |
-
}
|
624 |
-
|
|
|
625 |
}
|
626 |
|
627 |
-
|
|
|
|
|
|
|
628 |
public function saswp_get_schema_type_fields(){
|
629 |
|
630 |
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
@@ -635,7 +710,7 @@ Class saswp_output_service{
|
|
635 |
}
|
636 |
|
637 |
$schema_type = isset( $_POST['schema_type'] ) ? sanitize_text_field( $_POST['schema_type'] ) : '';
|
638 |
-
$post_id
|
639 |
$meta_fields = $this->saswp_get_all_schema_type_fields($schema_type);
|
640 |
|
641 |
wp_send_json( $meta_fields );
|
@@ -643,6 +718,11 @@ Class saswp_output_service{
|
|
643 |
wp_die();
|
644 |
}
|
645 |
|
|
|
|
|
|
|
|
|
|
|
646 |
public function saswp_get_custom_meta_fields(){
|
647 |
|
648 |
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
@@ -678,6 +758,13 @@ Class saswp_output_service{
|
|
678 |
|
679 |
wp_die();
|
680 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
public function saswp_woocommerce_product_details($post_id){
|
682 |
|
683 |
$product_details = array();
|
@@ -771,6 +858,24 @@ Class saswp_output_service{
|
|
771 |
return $product_details;
|
772 |
}
|
773 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
774 |
public function saswp_extra_theme_review_details($post_id){
|
775 |
|
776 |
global $sd_data;
|
@@ -794,20 +899,20 @@ Class saswp_output_service{
|
|
794 |
if($post_review_title && $rating_value>0 && (isset($sd_data['saswp-extra']) && $sd_data['saswp-extra'] ==1) && get_template()=='Extra'){
|
795 |
|
796 |
$review_data['aggregateRating'] = array(
|
797 |
-
'@type'
|
798 |
-
'ratingValue'
|
799 |
-
'reviewCount'
|
800 |
);
|
801 |
|
802 |
$review_data['review'] = array(
|
803 |
-
'@type'
|
804 |
-
'author'
|
805 |
'datePublished' => get_the_date("Y-m-d\TH:i:s\Z"),
|
806 |
-
'name'
|
807 |
-
'reviewBody'
|
808 |
'reviewRating' => array(
|
809 |
-
|
810 |
-
|
811 |
),
|
812 |
|
813 |
);
|
@@ -877,7 +982,14 @@ Class saswp_output_service{
|
|
877 |
//
|
878 |
// }
|
879 |
|
880 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
881 |
public function saswp_dw_question_answers_details($post_id){
|
882 |
|
883 |
global $sd_data;
|
@@ -968,6 +1080,12 @@ Class saswp_output_service{
|
|
968 |
return $qa_page;
|
969 |
}
|
970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
public function saswp_get_all_schema_type_fields($schema_type, $id =null){
|
972 |
|
973 |
$meta_field = array();
|
@@ -1091,6 +1209,18 @@ Class saswp_output_service{
|
|
1091 |
'saswp_tech_article_organization_logo' => 'Organization Logo',
|
1092 |
);
|
1093 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1094 |
|
1095 |
case 'Recipe':
|
1096 |
|
@@ -1226,6 +1356,22 @@ Class saswp_output_service{
|
|
1226 |
|
1227 |
break;
|
1228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1229 |
case 'qanda':
|
1230 |
$meta_field = array(
|
1231 |
|
@@ -1253,11 +1399,18 @@ Class saswp_output_service{
|
|
1253 |
}
|
1254 |
return $meta_field;
|
1255 |
}
|
1256 |
-
|
1257 |
-
|
|
|
|
|
|
|
|
|
|
|
1258 |
public function saswp_schema_markup_generator($schema_type){
|
1259 |
|
1260 |
-
|
|
|
|
|
1261 |
$logo = '';
|
1262 |
$height = '';
|
1263 |
$width = '';
|
@@ -1291,7 +1444,14 @@ Class saswp_output_service{
|
|
1291 |
$author_details = get_avatar_data($author_id);
|
1292 |
$date = get_the_date("Y-m-d\TH:i:s\Z");
|
1293 |
$modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
|
1294 |
-
$aurthor_name =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1295 |
|
1296 |
switch ($schema_type) {
|
1297 |
|
@@ -1398,10 +1558,25 @@ Class saswp_output_service{
|
|
1398 |
break;
|
1399 |
}
|
1400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1401 |
return $input1;
|
1402 |
|
1403 |
}
|
1404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1405 |
public function saswp_get_fetaure_image(){
|
1406 |
|
1407 |
global $sd_data;
|
@@ -1445,7 +1620,12 @@ Class saswp_output_service{
|
|
1445 |
|
1446 |
return $input2;
|
1447 |
}
|
1448 |
-
|
|
|
|
|
|
|
|
|
|
|
1449 |
public function saswp_get_publisher($d_logo = null){
|
1450 |
|
1451 |
global $sd_data;
|
4 |
public function __construct() {
|
5 |
|
6 |
}
|
7 |
+
/**
|
8 |
+
* List of hooks used in current class
|
9 |
+
*/
|
10 |
public function saswp_service_hooks(){
|
11 |
|
12 |
add_action( 'wp_ajax_saswp_get_custom_meta_fields', array($this, 'saswp_get_custom_meta_fields'));
|
13 |
add_action( 'wp_ajax_saswp_get_schema_type_fields', array($this, 'saswp_get_schema_type_fields'));
|
14 |
|
15 |
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* This function replaces the value of schema's fields with the selected custom meta field
|
19 |
+
* @param type $input1
|
20 |
+
* @param type $schema_post_id
|
21 |
+
* @return type array
|
22 |
+
*/
|
23 |
public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
|
24 |
|
25 |
+
global $post;
|
26 |
|
27 |
+
$custom_fields = esc_sql ( get_post_meta($schema_post_id, 'saswp_custom_fields', true) );
|
28 |
+
|
29 |
if(!empty($custom_fields)){
|
30 |
|
31 |
$schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
|
32 |
|
33 |
foreach ($custom_fields as $key => $field){
|
34 |
|
35 |
+
if(is_object($post)){
|
36 |
+
|
37 |
+
$custom_fields[$key] = get_post_meta($post->ID, $field, true);
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
}
|
42 |
|
43 |
switch ($schema_type) {
|
154 |
$input1['author']['name'] = $custom_fields['saswp_audio_author_name'];
|
155 |
}
|
156 |
|
157 |
+
break;
|
158 |
+
|
159 |
+
case 'SoftwareApplication':
|
160 |
+
|
161 |
+
if(isset($custom_fields['saswp_software_schema_name'])){
|
162 |
+
$input1['name'] = $custom_fields['saswp_software_schema_name'];
|
163 |
+
}
|
164 |
+
if(isset($custom_fields['saswp_software_schema_description'])){
|
165 |
+
$input1['description'] = $custom_fields['saswp_software_schema_description'];
|
166 |
+
}
|
167 |
+
if(isset($custom_fields['saswp_software_schema_operating_system'])){
|
168 |
+
$input1['operatingSystem'] = $custom_fields['saswp_software_schema_operating_system'];
|
169 |
+
}
|
170 |
+
if(isset($custom_fields['saswp_software_schema_application_category'])){
|
171 |
+
$input1['applicationCategory'] = $custom_fields['saswp_software_schema_application_category'];
|
172 |
+
}
|
173 |
+
if(isset($custom_fields['saswp_software_schema_price'])){
|
174 |
+
$input1['offers']['price'] = $custom_fields['saswp_software_schema_price'];
|
175 |
+
}
|
176 |
+
if(isset($custom_fields['saswp_software_schema_price_currency'])){
|
177 |
+
$input1['offers']['priceCurrency'] = $custom_fields['saswp_software_schema_price_currency'];
|
178 |
+
}
|
179 |
+
if(isset($custom_fields['saswp_software_schema_date_published'])){
|
180 |
+
$input1['datePublished'] = $custom_fields['saswp_software_schema_date_published'];
|
181 |
+
}
|
182 |
+
if(isset($custom_fields['saswp_software_schema_date_modified'])){
|
183 |
+
$input1['dateModified'] = $custom_fields['saswp_software_schema_date_modified'];
|
184 |
+
}
|
185 |
+
|
186 |
+
break;
|
187 |
|
188 |
case 'NewsArticle':
|
189 |
|
343 |
if(isset($custom_fields['saswp_tech_article_organization_logo'])){
|
344 |
$input1['Publisher']['logo']['url'] = $custom_fields['saswp_tech_article_organization_logo'];
|
345 |
}
|
346 |
+
break;
|
347 |
+
|
348 |
+
case 'Course':
|
349 |
+
|
350 |
+
if(isset($custom_fields['saswp_course_name'])){
|
351 |
+
$input1['name'] = $custom_fields['saswp_course_name'];
|
352 |
+
}
|
353 |
+
if(isset($custom_fields['saswp_course_description'])){
|
354 |
+
$input1['description'] = $custom_fields['saswp_course_description'];
|
355 |
+
}
|
356 |
+
if(isset($custom_fields['saswp_course_url'])){
|
357 |
+
$input1['url'] = $custom_fields['saswp_course_url'];
|
358 |
+
}
|
359 |
+
if(isset($custom_fields['saswp_course_date_published'])){
|
360 |
+
$input1['datePublished'] = $custom_fields['saswp_course_date_published'];
|
361 |
+
}
|
362 |
+
if(isset($custom_fields['saswp_course_date_modified'])){
|
363 |
+
$input1['dateModified'] = $custom_fields['saswp_course_date_modified'];
|
364 |
+
}
|
365 |
+
if(isset($custom_fields['saswp_course_provider_name'])){
|
366 |
+
$input1['provider']['name'] = $custom_fields['saswp_course_provider_name'];
|
367 |
+
}
|
368 |
+
|
369 |
+
if(isset($custom_fields['saswp_course_sameas'])){
|
370 |
+
$input1['provider']['sameAs'] = $custom_fields['saswp_course_sameas'];
|
371 |
+
}
|
372 |
+
|
373 |
+
break;
|
374 |
|
375 |
case 'Recipe':
|
376 |
if(isset($custom_fields['saswp_recipe_url'])){
|
691 |
default:
|
692 |
break;
|
693 |
}
|
694 |
+
}
|
695 |
+
|
696 |
+
return $input1;
|
697 |
}
|
698 |
|
699 |
+
/**
|
700 |
+
* This is a ajax handler to get all the schema type keys
|
701 |
+
* @return type json
|
702 |
+
*/
|
703 |
public function saswp_get_schema_type_fields(){
|
704 |
|
705 |
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
710 |
}
|
711 |
|
712 |
$schema_type = isset( $_POST['schema_type'] ) ? sanitize_text_field( $_POST['schema_type'] ) : '';
|
713 |
+
$post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
|
714 |
$meta_fields = $this->saswp_get_all_schema_type_fields($schema_type);
|
715 |
|
716 |
wp_send_json( $meta_fields );
|
718 |
wp_die();
|
719 |
}
|
720 |
|
721 |
+
/**
|
722 |
+
* This function gets all the custom meta fields from the wordpress meta fields table
|
723 |
+
* @global type $wpdb
|
724 |
+
* @return type json
|
725 |
+
*/
|
726 |
public function saswp_get_custom_meta_fields(){
|
727 |
|
728 |
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
758 |
|
759 |
wp_die();
|
760 |
}
|
761 |
+
|
762 |
+
/**
|
763 |
+
* This function gets the product details in schema markup from the current product type post create by
|
764 |
+
* WooCommerce ( https://wordpress.org/plugins/woocommerce/ )
|
765 |
+
* @param type $post_id
|
766 |
+
* @return type array
|
767 |
+
*/
|
768 |
public function saswp_woocommerce_product_details($post_id){
|
769 |
|
770 |
$product_details = array();
|
858 |
return $product_details;
|
859 |
}
|
860 |
|
861 |
+
// public function saswp_tagyeem_review_details($post_id){
|
862 |
+
//
|
863 |
+
// global $sd_data;
|
864 |
+
//
|
865 |
+
// if(isset($sd_data['saswp-tagyeem']) && $sd_data['saswp-tagyeem'] == 1){
|
866 |
+
//
|
867 |
+
//
|
868 |
+
//
|
869 |
+
// }
|
870 |
+
//
|
871 |
+
// }
|
872 |
+
/**
|
873 |
+
* This function gets the review details in schema markup from the current post which has extra theme enabled
|
874 |
+
* Extra Theme ( https://www.elegantthemes.com/preview/Extra/ )
|
875 |
+
* @global type $sd_data
|
876 |
+
* @param type $post_id
|
877 |
+
* @return type array
|
878 |
+
*/
|
879 |
public function saswp_extra_theme_review_details($post_id){
|
880 |
|
881 |
global $sd_data;
|
899 |
if($post_review_title && $rating_value>0 && (isset($sd_data['saswp-extra']) && $sd_data['saswp-extra'] ==1) && get_template()=='Extra'){
|
900 |
|
901 |
$review_data['aggregateRating'] = array(
|
902 |
+
'@type' => 'AggregateRating',
|
903 |
+
'ratingValue' => $rating_value,
|
904 |
+
'reviewCount' => 1,
|
905 |
);
|
906 |
|
907 |
$review_data['review'] = array(
|
908 |
+
'@type' => 'Review',
|
909 |
+
'author' => get_the_author(),
|
910 |
'datePublished' => get_the_date("Y-m-d\TH:i:s\Z"),
|
911 |
+
'name' => $post_review_title,
|
912 |
+
'reviewBody' => $post_review_desc,
|
913 |
'reviewRating' => array(
|
914 |
+
'@type' => 'Rating',
|
915 |
+
'ratingValue' => $rating_value,
|
916 |
),
|
917 |
|
918 |
);
|
982 |
//
|
983 |
// }
|
984 |
|
985 |
+
|
986 |
+
/**
|
987 |
+
* This function gets all the question and answers in schema markup from the current question type post create by
|
988 |
+
* DW Question & Answer ( https://wordpress.org/plugins/dw-question-answer/ )
|
989 |
+
* @global type $sd_data
|
990 |
+
* @param type $post_id
|
991 |
+
* @return type array
|
992 |
+
*/
|
993 |
public function saswp_dw_question_answers_details($post_id){
|
994 |
|
995 |
global $sd_data;
|
1080 |
return $qa_page;
|
1081 |
}
|
1082 |
|
1083 |
+
/**
|
1084 |
+
* This function returns all the schema field's key by schema type or id
|
1085 |
+
* @param type $schema_type
|
1086 |
+
* @param type $id
|
1087 |
+
* @return string
|
1088 |
+
*/
|
1089 |
public function saswp_get_all_schema_type_fields($schema_type, $id =null){
|
1090 |
|
1091 |
$meta_field = array();
|
1209 |
'saswp_tech_article_organization_logo' => 'Organization Logo',
|
1210 |
);
|
1211 |
break;
|
1212 |
+
case 'Course':
|
1213 |
+
|
1214 |
+
$meta_field = array(
|
1215 |
+
'saswp_course_name' => 'Name',
|
1216 |
+
'saswp_course_description' => 'Description',
|
1217 |
+
'saswp_course_url' => 'URL',
|
1218 |
+
'saswp_course_date_published' => 'Date Published',
|
1219 |
+
'saswp_course_date_modified' => 'Date Modified',
|
1220 |
+
'saswp_course_provider_name' => 'Provider Name',
|
1221 |
+
'saswp_course_sameas' => 'Provider SameAs',
|
1222 |
+
);
|
1223 |
+
break;
|
1224 |
|
1225 |
case 'Recipe':
|
1226 |
|
1356 |
|
1357 |
break;
|
1358 |
|
1359 |
+
case 'SoftwareApplication':
|
1360 |
+
|
1361 |
+
$meta_field = array(
|
1362 |
+
|
1363 |
+
'saswp_software_schema_name' => 'Name',
|
1364 |
+
'saswp_software_schema_description' => 'Description',
|
1365 |
+
'saswp_software_schema_operating_system' => 'Description',
|
1366 |
+
'saswp_software_schema_application_category' => 'Description',
|
1367 |
+
'saswp_software_schema_price' => 'Description',
|
1368 |
+
'saswp_software_schema_price_currency' => 'Description',
|
1369 |
+
'saswp_software_schema_date_published' => 'Date Published',
|
1370 |
+
'saswp_software_schema_date_modified' => 'Date Modified',
|
1371 |
+
);
|
1372 |
+
|
1373 |
+
break;
|
1374 |
+
|
1375 |
case 'qanda':
|
1376 |
$meta_field = array(
|
1377 |
|
1399 |
}
|
1400 |
return $meta_field;
|
1401 |
}
|
1402 |
+
|
1403 |
+
/**
|
1404 |
+
* This function generate the schema markup by passed schema type
|
1405 |
+
* @global type $sd_data
|
1406 |
+
* @param type $schema_type
|
1407 |
+
* @return array
|
1408 |
+
*/
|
1409 |
public function saswp_schema_markup_generator($schema_type){
|
1410 |
|
1411 |
+
global $post;
|
1412 |
+
|
1413 |
+
global $sd_data;
|
1414 |
$logo = '';
|
1415 |
$height = '';
|
1416 |
$width = '';
|
1444 |
$author_details = get_avatar_data($author_id);
|
1445 |
$date = get_the_date("Y-m-d\TH:i:s\Z");
|
1446 |
$modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
|
1447 |
+
$aurthor_name = '';
|
1448 |
+
|
1449 |
+
if(!$aurthor_name && is_object($post)){
|
1450 |
+
|
1451 |
+
$author_id = get_post_field ('post_author', $post->ID);
|
1452 |
+
$aurthor_name = get_the_author_meta( 'display_name' , $author_id );
|
1453 |
+
}
|
1454 |
+
|
1455 |
|
1456 |
switch ($schema_type) {
|
1457 |
|
1558 |
break;
|
1559 |
}
|
1560 |
|
1561 |
+
if( !empty($input1) && !isset($input1['image'])){
|
1562 |
+
|
1563 |
+
$input2 = $this->saswp_get_fetaure_image();
|
1564 |
+
if(!empty($input2)){
|
1565 |
+
|
1566 |
+
$input1 = array_merge($input1,$input2);
|
1567 |
+
}
|
1568 |
+
}
|
1569 |
+
|
1570 |
return $input1;
|
1571 |
|
1572 |
}
|
1573 |
|
1574 |
+
/**
|
1575 |
+
* This function returns the featured image for the current post.
|
1576 |
+
* If featured image is not set than it gets default schema image from MISC settings tab
|
1577 |
+
* @global type $sd_data
|
1578 |
+
* @return type array
|
1579 |
+
*/
|
1580 |
public function saswp_get_fetaure_image(){
|
1581 |
|
1582 |
global $sd_data;
|
1620 |
|
1621 |
return $input2;
|
1622 |
}
|
1623 |
+
/**
|
1624 |
+
* This function gets the publisher from schema settings panel
|
1625 |
+
* @global type $sd_data
|
1626 |
+
* @param type $d_logo
|
1627 |
+
* @return type array
|
1628 |
+
*/
|
1629 |
public function saswp_get_publisher($d_logo = null){
|
1630 |
|
1631 |
global $sd_data;
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
|
|
3 |
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.0.2
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -65,6 +65,13 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
|
|
65 |
|
66 |
== Changelog ==
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
= 1.1 (15 February 2019) =
|
69 |
|
70 |
* New Feature: TechArticle schema type add to the schema type list #115
|
3 |
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.0.2
|
6 |
+
Stable tag: 1.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
65 |
|
66 |
== Changelog ==
|
67 |
|
68 |
+
= 1.2 (22 February 2019) =
|
69 |
+
|
70 |
+
* New Feature: Software Application and Course schema type added to the schema type list #115
|
71 |
+
* Bug Fixed: Modify Schema Output is not getting, Selected post meta fields value in schema markup #155
|
72 |
+
* Bug Fixed: Author name field value is not being filled in the Review schema markup #154
|
73 |
+
* Bug Fixed: Notice cluttering in error logs #152
|
74 |
+
|
75 |
= 1.1 (15 February 2019) =
|
76 |
|
77 |
* New Feature: TechArticle schema type add to the schema type list #115
|
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.
|
6 |
Text Domain: schema-and-structured-data-for-wp
|
7 |
Domain Path: /languages
|
8 |
Author: Mohammed Kaludi, Ahmed Kaludi
|
@@ -13,7 +13,7 @@ License: GPL2
|
|
13 |
// Exit if accessed directly.
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
-
define('SASWP_VERSION', '1.
|
17 |
define('SASWP_DIR_NAME_FILE', __FILE__ );
|
18 |
define('SASWP_DIR_NAME', dirname( __FILE__ ));
|
19 |
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
|
2 |
/*
|
3 |
Plugin Name: Schema & Structured Data for WP
|
4 |
Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
|
5 |
+
Version: 1.2
|
6 |
Text Domain: schema-and-structured-data-for-wp
|
7 |
Domain Path: /languages
|
8 |
Author: Mohammed Kaludi, Ahmed Kaludi
|
13 |
// Exit if accessed directly.
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
+
define('SASWP_VERSION', '1.2');
|
17 |
define('SASWP_DIR_NAME_FILE', __FILE__ );
|
18 |
define('SASWP_DIR_NAME', dirname( __FILE__ ));
|
19 |
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
|
view/post_specific.php
CHANGED
@@ -25,6 +25,7 @@ class saswp_post_specific {
|
|
25 |
add_action( 'wp_ajax_saswp_enable_disable_schema_on_post', array($this,'saswp_enable_disable_schema_on_post'));
|
26 |
|
27 |
}
|
|
|
28 |
public function saswp_enable_disable_schema_on_post(){
|
29 |
|
30 |
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
@@ -291,7 +292,7 @@ class saswp_post_specific {
|
|
291 |
|
292 |
}
|
293 |
|
294 |
-
|
295 |
|
296 |
global $post;
|
297 |
global $sd_data;
|
@@ -554,15 +555,17 @@ class saswp_post_specific {
|
|
554 |
}
|
555 |
|
556 |
|
557 |
-
if($meta_field['id'] == 'saswp_service_schema_rating_'.$schema_id
|
558 |
-
$meta_field['id'] == 'saswp_product_schema_rating_'.$schema_id
|
559 |
-
$meta_field['id'] == 'saswp_review_schema_rating_'.$schema_id
|
560 |
-
$meta_field['id'] == 'local_rating_'.$schema_id
|
|
|
561 |
|
562 |
$meta_field['id'] == 'saswp_service_schema_review_count_'.$schema_id ||
|
563 |
$meta_field['id'] == 'saswp_product_schema_review_count_'.$schema_id ||
|
564 |
-
$meta_field['id'] == 'saswp_review_schema_review_count_'.$schema_id
|
565 |
-
$meta_field['id'] == 'local_review_count_'.$schema_id
|
|
|
566 |
|
567 |
)
|
568 |
{
|
@@ -578,6 +581,7 @@ class saswp_post_specific {
|
|
578 |
}
|
579 |
return $output;
|
580 |
}
|
|
|
581 |
public function saswp_post_specific_save_fields( $post_id ) {
|
582 |
|
583 |
if ( ! isset( $_POST['post_specific_nonce'] ) )
|
@@ -637,6 +641,7 @@ class saswp_post_specific {
|
|
637 |
}
|
638 |
}
|
639 |
}
|
|
|
640 |
public function saswp_get_sub_business_ajax(){
|
641 |
|
642 |
if ( ! isset( $_GET['saswp_security_nonce'] ) ){
|
@@ -657,6 +662,7 @@ class saswp_post_specific {
|
|
657 |
}
|
658 |
wp_die();
|
659 |
}
|
|
|
660 |
public function saswp_get_sub_business_array($business_type){
|
661 |
|
662 |
$sub_business_options = array();
|
@@ -1415,6 +1421,53 @@ class saswp_post_specific {
|
|
1415 |
);
|
1416 |
break;
|
1417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1418 |
case 'Recipe':
|
1419 |
$meta_field = array(
|
1420 |
array(
|
@@ -1989,6 +2042,79 @@ class saswp_post_specific {
|
|
1989 |
);
|
1990 |
break;
|
1991 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1992 |
case 'VideoObject':
|
1993 |
$meta_field = array(
|
1994 |
array(
|
25 |
add_action( 'wp_ajax_saswp_enable_disable_schema_on_post', array($this,'saswp_enable_disable_schema_on_post'));
|
26 |
|
27 |
}
|
28 |
+
|
29 |
public function saswp_enable_disable_schema_on_post(){
|
30 |
|
31 |
if ( ! isset( $_POST['saswp_security_nonce'] ) ){
|
292 |
|
293 |
}
|
294 |
|
295 |
+
public function saswp_saswp_post_specific( $post, $schema_id ) {
|
296 |
|
297 |
global $post;
|
298 |
global $sd_data;
|
555 |
}
|
556 |
|
557 |
|
558 |
+
if($meta_field['id'] == 'saswp_service_schema_rating_'.$schema_id ||
|
559 |
+
$meta_field['id'] == 'saswp_product_schema_rating_'.$schema_id ||
|
560 |
+
$meta_field['id'] == 'saswp_review_schema_rating_'.$schema_id ||
|
561 |
+
$meta_field['id'] == 'local_rating_'.$schema_id ||
|
562 |
+
$meta_field['id'] == 'saswp_software_schema_rating_'.$schema_id ||
|
563 |
|
564 |
$meta_field['id'] == 'saswp_service_schema_review_count_'.$schema_id ||
|
565 |
$meta_field['id'] == 'saswp_product_schema_review_count_'.$schema_id ||
|
566 |
+
$meta_field['id'] == 'saswp_review_schema_review_count_'.$schema_id ||
|
567 |
+
$meta_field['id'] == 'local_review_count_'.$schema_id ||
|
568 |
+
$meta_field['id'] == 'saswp_software_schema_rating_count_'.$schema_id
|
569 |
|
570 |
)
|
571 |
{
|
581 |
}
|
582 |
return $output;
|
583 |
}
|
584 |
+
|
585 |
public function saswp_post_specific_save_fields( $post_id ) {
|
586 |
|
587 |
if ( ! isset( $_POST['post_specific_nonce'] ) )
|
641 |
}
|
642 |
}
|
643 |
}
|
644 |
+
|
645 |
public function saswp_get_sub_business_ajax(){
|
646 |
|
647 |
if ( ! isset( $_GET['saswp_security_nonce'] ) ){
|
662 |
}
|
663 |
wp_die();
|
664 |
}
|
665 |
+
|
666 |
public function saswp_get_sub_business_array($business_type){
|
667 |
|
668 |
$sub_business_options = array();
|
1421 |
);
|
1422 |
break;
|
1423 |
|
1424 |
+
case 'Course':
|
1425 |
+
$meta_field = array(
|
1426 |
+
array(
|
1427 |
+
'label' => 'Name',
|
1428 |
+
'id' => 'saswp_course_name_'.$schema_id,
|
1429 |
+
'type' => 'text',
|
1430 |
+
'default' => get_the_title()
|
1431 |
+
),
|
1432 |
+
array(
|
1433 |
+
'label' => 'Description',
|
1434 |
+
'id' => 'saswp_course_description_'.$schema_id,
|
1435 |
+
'type' => 'textarea',
|
1436 |
+
'default' => $post->post_excerpt
|
1437 |
+
) ,
|
1438 |
+
array(
|
1439 |
+
'label' => 'URL',
|
1440 |
+
'id' => 'saswp_course_url_'.$schema_id,
|
1441 |
+
'type' => 'text',
|
1442 |
+
'default' => get_permalink()
|
1443 |
+
),
|
1444 |
+
array(
|
1445 |
+
'label' => 'Date Published',
|
1446 |
+
'id' => 'saswp_course_date_published_'.$schema_id,
|
1447 |
+
'type' => 'text',
|
1448 |
+
'default' => get_the_date("Y-m-d")
|
1449 |
+
),
|
1450 |
+
array(
|
1451 |
+
'label' => 'Date Modified',
|
1452 |
+
'id' => 'saswp_course_date_modified_'.$schema_id,
|
1453 |
+
'type' => 'text',
|
1454 |
+
'default' => get_the_modified_date("Y-m-d")
|
1455 |
+
),
|
1456 |
+
array(
|
1457 |
+
'label' => 'Provider Name',
|
1458 |
+
'id' => 'saswp_course_provider_name_'.$schema_id,
|
1459 |
+
'type' => 'text',
|
1460 |
+
'default' => get_bloginfo()
|
1461 |
+
),
|
1462 |
+
array(
|
1463 |
+
'label' => 'Provider SameAs',
|
1464 |
+
'id' => 'saswp_course_sameas_'.$schema_id,
|
1465 |
+
'type' => 'text',
|
1466 |
+
'default' => get_home_url()
|
1467 |
+
)
|
1468 |
+
);
|
1469 |
+
break;
|
1470 |
+
|
1471 |
case 'Recipe':
|
1472 |
$meta_field = array(
|
1473 |
array(
|
2042 |
);
|
2043 |
break;
|
2044 |
|
2045 |
+
case 'SoftwareApplication':
|
2046 |
+
|
2047 |
+
$software_schema_details = esc_sql ( get_post_meta($schema_id, 'saswp_software_schema_details', true) );
|
2048 |
+
$meta_field = array(
|
2049 |
+
|
2050 |
+
array(
|
2051 |
+
'label' => 'Name',
|
2052 |
+
'id' => 'saswp_software_schema_name_'.$schema_id,
|
2053 |
+
'type' => 'text',
|
2054 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_name', 'saswp_string')
|
2055 |
+
),
|
2056 |
+
array(
|
2057 |
+
'label' => 'Description',
|
2058 |
+
'id' => 'saswp_software_schema_description_'.$schema_id,
|
2059 |
+
'type' => 'textarea',
|
2060 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_description', 'saswp_string')
|
2061 |
+
),
|
2062 |
+
array(
|
2063 |
+
'label' => 'Operating System',
|
2064 |
+
'id' => 'saswp_software_schema_operating_system_'.$schema_id,
|
2065 |
+
'type' => 'text',
|
2066 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_operating_system', 'saswp_string')
|
2067 |
+
),
|
2068 |
+
array(
|
2069 |
+
'label' => 'Application Category',
|
2070 |
+
'id' => 'saswp_software_schema_application_category_'.$schema_id,
|
2071 |
+
'type' => 'text',
|
2072 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_application_category', 'saswp_string')
|
2073 |
+
),
|
2074 |
+
array(
|
2075 |
+
'label' => 'Price',
|
2076 |
+
'id' => 'saswp_software_schema_price_'.$schema_id,
|
2077 |
+
'type' => 'text',
|
2078 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_price', 'saswp_string')
|
2079 |
+
),
|
2080 |
+
array(
|
2081 |
+
'label' => 'Price Currency',
|
2082 |
+
'id' => 'saswp_software_schema_price_currency_'.$schema_id,
|
2083 |
+
'type' => 'text',
|
2084 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_price_currency', 'saswp_string')
|
2085 |
+
),
|
2086 |
+
array(
|
2087 |
+
'label' => 'Date Published',
|
2088 |
+
'id' => 'saswp_software_schema_date_published_'.$schema_id,
|
2089 |
+
'type' => 'text',
|
2090 |
+
'default' => get_the_date("Y-m-d")
|
2091 |
+
),
|
2092 |
+
array(
|
2093 |
+
'label' => 'Date Modified',
|
2094 |
+
'id' => 'saswp_software_schema_date_modified_'.$schema_id,
|
2095 |
+
'type' => 'text',
|
2096 |
+
'default' => get_the_modified_date("Y-m-d")
|
2097 |
+
),
|
2098 |
+
array(
|
2099 |
+
'label' => 'Aggregate Rating',
|
2100 |
+
'id' => 'saswp_software_schema_enable_rating_'.$schema_id,
|
2101 |
+
'type' => 'checkbox',
|
2102 |
+
),
|
2103 |
+
array(
|
2104 |
+
'label' => 'Rating',
|
2105 |
+
'id' => 'saswp_software_schema_rating_'.$schema_id,
|
2106 |
+
'type' => 'text',
|
2107 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_rating', 'saswp_string')
|
2108 |
+
),
|
2109 |
+
array(
|
2110 |
+
'label' => 'Rating Count',
|
2111 |
+
'id' => 'saswp_software_schema_rating_count_'.$schema_id,
|
2112 |
+
'type' => 'text',
|
2113 |
+
'default' => saswp_remove_warnings($software_schema_details, 'saswp_software_schema_rating_count', 'saswp_string')
|
2114 |
+
),
|
2115 |
+
);
|
2116 |
+
break;
|
2117 |
+
|
2118 |
case 'VideoObject':
|
2119 |
$meta_field = array(
|
2120 |
array(
|
view/schema_type.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
3 |
|
4 |
$post_fix = '';
|
5 |
|
@@ -343,7 +343,7 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
343 |
return $reviewed_field;
|
344 |
|
345 |
}
|
346 |
-
|
347 |
function saswp_get_item_reviewed_fields(){
|
348 |
|
349 |
if ( ! isset( $_GET['saswp_security_nonce'] ) ){
|
@@ -506,6 +506,7 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
506 |
);
|
507 |
|
508 |
}
|
|
|
509 |
function saswp_schema_type_get_meta( $value ) {
|
510 |
|
511 |
global $post;
|
@@ -518,6 +519,7 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
518 |
return false;
|
519 |
}
|
520 |
}
|
|
|
521 |
function saswp_schema_type_meta_box_callback( $post) {
|
522 |
|
523 |
wp_nonce_field( 'saswp_schema_type_nonce', 'saswp_schema_type_nonce' );
|
@@ -548,6 +550,12 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
548 |
|
549 |
break;
|
550 |
|
|
|
|
|
|
|
|
|
|
|
|
|
551 |
case 'local_business':
|
552 |
|
553 |
$business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
|
@@ -645,20 +653,22 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
645 |
);
|
646 |
|
647 |
$all_schema_array = array(
|
648 |
-
'Article'
|
649 |
-
'AudioObject'
|
650 |
-
'Blogposting'
|
|
|
651 |
// 'JobPosting' => 'JobPosting',
|
652 |
-
'local_business'
|
653 |
-
'NewsArticle'
|
654 |
-
'Product'
|
655 |
-
'qanda'
|
656 |
-
'Review'
|
657 |
-
'Recipe'
|
658 |
-
'Service'
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
|
|
662 |
);
|
663 |
$all_business_type = array(
|
664 |
'animalshelter' => 'Animal Shelter',
|
@@ -1416,14 +1426,65 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
1416 |
</tr>
|
1417 |
|
1418 |
<!-- AudioObject Schema type ends here -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1420 |
|
1421 |
</table>
|
1422 |
|
1423 |
</div>
|
1424 |
<?php
|
1425 |
-
}
|
1426 |
-
|
1427 |
function saswp_schema_type_add_meta_box_save( $post_id ) {
|
1428 |
|
1429 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
@@ -1506,9 +1567,11 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
1506 |
|
1507 |
|
1508 |
$service_schema_details = array();
|
1509 |
-
$review_schema_details
|
1510 |
$product_schema_details = array();
|
1511 |
-
$audio_schema_details
|
|
|
|
|
1512 |
$schema_type = sanitize_text_field($_POST['schema_type']);
|
1513 |
|
1514 |
if($schema_type =='Service'){
|
@@ -1714,6 +1777,40 @@ function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
|
1714 |
|
1715 |
|
1716 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1717 |
//Service schema details ends here
|
1718 |
|
1719 |
|
1 |
<?php
|
2 |
+
function item_reviewed_fields($item, $post_specific = null, $schema_id = null){
|
3 |
|
4 |
$post_fix = '';
|
5 |
|
343 |
return $reviewed_field;
|
344 |
|
345 |
}
|
346 |
+
|
347 |
function saswp_get_item_reviewed_fields(){
|
348 |
|
349 |
if ( ! isset( $_GET['saswp_security_nonce'] ) ){
|
506 |
);
|
507 |
|
508 |
}
|
509 |
+
|
510 |
function saswp_schema_type_get_meta( $value ) {
|
511 |
|
512 |
global $post;
|
519 |
return false;
|
520 |
}
|
521 |
}
|
522 |
+
|
523 |
function saswp_schema_type_meta_box_callback( $post) {
|
524 |
|
525 |
wp_nonce_field( 'saswp_schema_type_nonce', 'saswp_schema_type_nonce' );
|
550 |
|
551 |
break;
|
552 |
|
553 |
+
case 'SoftwareApplication':
|
554 |
+
|
555 |
+
$software_details = esc_sql ( get_post_meta($post->ID, 'saswp_software_schema_details', true) );
|
556 |
+
|
557 |
+
break;
|
558 |
+
|
559 |
case 'local_business':
|
560 |
|
561 |
$business_type = esc_sql ( get_post_meta($post->ID, 'saswp_business_type', true) );
|
653 |
);
|
654 |
|
655 |
$all_schema_array = array(
|
656 |
+
'Article' => 'Article',
|
657 |
+
'AudioObject' => 'AudioObject',
|
658 |
+
'Blogposting' => 'Blogposting',
|
659 |
+
'Course' => 'Course',
|
660 |
// 'JobPosting' => 'JobPosting',
|
661 |
+
'local_business' => 'Local Business',
|
662 |
+
'NewsArticle' => 'NewsArticle',
|
663 |
+
'Product' => 'Product',
|
664 |
+
'qanda' => 'Q&A',
|
665 |
+
'Review' => 'Review',
|
666 |
+
'Recipe' => 'Recipe',
|
667 |
+
'Service' => 'Service',
|
668 |
+
'SoftwareApplication' => 'SoftwareApplication',
|
669 |
+
'TechArticle' => 'TechArticle',
|
670 |
+
'VideoObject' => 'VideoObject',
|
671 |
+
'WebPage' => 'WebPage'
|
672 |
);
|
673 |
$all_business_type = array(
|
674 |
'animalshelter' => 'Animal Shelter',
|
1426 |
</tr>
|
1427 |
|
1428 |
<!-- AudioObject Schema type ends here -->
|
1429 |
+
|
1430 |
+
<!-- SoftwareApplication Schema type starts here -->
|
1431 |
+
|
1432 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1433 |
+
<td><?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?></td>
|
1434 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_name'])){echo esc_attr($software_details['saswp_software_schema_name']); } ?>" type="text" name="saswp_software_schema_name" placeholder="<?php echo esc_html__('Name', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1435 |
+
</tr>
|
1436 |
+
|
1437 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1438 |
+
<td><?php echo esc_html__('Description', 'schema-and-structured-data-for-wp' ); ?></td>
|
1439 |
+
<td>
|
1440 |
+
<textarea placeholder="Description" rows="5" cols="70" name="saswp_software_schema_description"><?php if(isset($software_details['saswp_software_schema_description'])){echo $software_details['saswp_software_schema_description']; } ?></textarea>
|
1441 |
+
</td>
|
1442 |
+
</tr>
|
1443 |
+
|
1444 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1445 |
+
<td><?php echo esc_html__('Operating System', 'schema-and-structured-data-for-wp' ); ?></td>
|
1446 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_operating_system'])){echo esc_attr($software_details['saswp_software_schema_operating_system']); } ?>" type="text" name="saswp_software_schema_operating_system" placeholder="<?php echo esc_html__('eg. ANDROID', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1447 |
+
</tr>
|
1448 |
+
|
1449 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1450 |
+
<td><?php echo esc_html__('Application Category', 'schema-and-structured-data-for-wp' ); ?></td>
|
1451 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_application_category'])){echo esc_attr($software_details['saswp_software_schema_application_category']); } ?>" type="text" name="saswp_software_schema_application_category" placeholder="<?php echo esc_html__('eg. https://schema.org/GameApplication', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1452 |
+
</tr>
|
1453 |
+
|
1454 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1455 |
+
<td><?php echo esc_html__('Price', 'schema-and-structured-data-for-wp' ); ?></td>
|
1456 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_price'])){echo esc_attr($software_details['saswp_software_schema_price']); } ?>" type="text" name="saswp_software_schema_price" placeholder="<?php echo esc_html__('1.00', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1457 |
+
</tr>
|
1458 |
+
|
1459 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1460 |
+
<td><?php echo esc_html__('Price Currency', 'schema-and-structured-data-for-wp' ); ?></td>
|
1461 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_price_currency'])){echo esc_attr($software_details['saswp_software_schema_price_currency']); } ?>" type="text" name="saswp_software_schema_price_currency" placeholder="<?php echo esc_html__('USD', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1462 |
+
</tr>
|
1463 |
|
1464 |
+
<tr class="saswp-softwareapplication-text-field-tr">
|
1465 |
+
<td><?php echo esc_html__('Aggregate Rating', 'schema-and-structured-data-for-wp' ); ?></td>
|
1466 |
+
<td>
|
1467 |
+
<input class="saswp-enable-rating-review-softwareapplication" type="checkbox" name="saswp_software_schema_enable_rating" value="1" <?php if(isset($software_details['saswp_software_schema_enable_rating'])){echo 'checked'; }else{ echo ''; } ?>>
|
1468 |
+
</td>
|
1469 |
+
</tr>
|
1470 |
+
|
1471 |
+
<tr class="saswp-softwareapplication-text-field-tr saswp-rating-review-softwareapplication">
|
1472 |
+
<td><?php echo esc_html__('Rating', 'schema-and-structured-data-for-wp' ); ?></td>
|
1473 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_rating'])){echo esc_attr($software_details['saswp_software_schema_rating']); } ?>" type="text" name="saswp_software_schema_rating" placeholder="<?php echo esc_html__('4.6', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1474 |
+
</tr>
|
1475 |
+
<tr class="saswp-softwareapplication-text-field-tr saswp-rating-review-softwareapplication">
|
1476 |
+
<td><?php echo esc_html__('Rating Count', 'schema-and-structured-data-for-wp' ); ?></td>
|
1477 |
+
<td><input value="<?php if(isset($software_details['saswp_software_schema_rating_count'])){echo esc_attr($software_details['saswp_software_schema_rating_count']); } ?>" type="text" name="saswp_software_schema_rating_count" placeholder="<?php echo esc_html__('8864', 'schema-and-structured-data-for-wp' ); ?>" ></td>
|
1478 |
+
</tr>
|
1479 |
+
|
1480 |
+
<!-- SoftwareApplication Schema type ends here -->
|
1481 |
|
1482 |
</table>
|
1483 |
|
1484 |
</div>
|
1485 |
<?php
|
1486 |
+
}
|
1487 |
+
|
1488 |
function saswp_schema_type_add_meta_box_save( $post_id ) {
|
1489 |
|
1490 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
1567 |
|
1568 |
|
1569 |
$service_schema_details = array();
|
1570 |
+
$review_schema_details = array();
|
1571 |
$product_schema_details = array();
|
1572 |
+
$audio_schema_details = array();
|
1573 |
+
$software_schema_details = array();
|
1574 |
+
|
1575 |
$schema_type = sanitize_text_field($_POST['schema_type']);
|
1576 |
|
1577 |
if($schema_type =='Service'){
|
1777 |
|
1778 |
|
1779 |
}
|
1780 |
+
|
1781 |
+
if($schema_type =='SoftwareApplication'){
|
1782 |
+
|
1783 |
+
if ( isset( $_POST['saswp_software_schema_name'] ) ){
|
1784 |
+
$software_schema_details['saswp_software_schema_name'] = sanitize_text_field($_POST['saswp_software_schema_name']);
|
1785 |
+
}
|
1786 |
+
if ( isset( $_POST['saswp_software_schema_description'] ) ){
|
1787 |
+
$software_schema_details['saswp_software_schema_description'] = sanitize_textarea_field($_POST['saswp_software_schema_description']);
|
1788 |
+
}
|
1789 |
+
if ( isset( $_POST['saswp_software_schema_operating_system'] ) ){
|
1790 |
+
$software_schema_details['saswp_software_schema_operating_system'] = sanitize_text_field($_POST['saswp_software_schema_operating_system']);
|
1791 |
+
}
|
1792 |
+
if ( isset( $_POST['saswp_software_schema_application_category'] ) ){
|
1793 |
+
$software_schema_details['saswp_software_schema_application_category'] = sanitize_text_field($_POST['saswp_software_schema_application_category']);
|
1794 |
+
}
|
1795 |
+
if ( isset( $_POST['saswp_software_schema_price'] ) ){
|
1796 |
+
$software_schema_details['saswp_software_schema_price'] = sanitize_text_field($_POST['saswp_software_schema_price']);
|
1797 |
+
}
|
1798 |
+
if ( isset( $_POST['saswp_software_schema_price_currency'] ) ){
|
1799 |
+
$software_schema_details['saswp_software_schema_price_currency'] = sanitize_text_field($_POST['saswp_software_schema_price_currency']);
|
1800 |
+
}
|
1801 |
+
|
1802 |
+
if ( isset( $_POST['saswp_software_schema_enable_rating'] ) ){
|
1803 |
+
$software_schema_details['saswp_software_schema_enable_rating'] = sanitize_text_field($_POST['saswp_software_schema_enable_rating']);
|
1804 |
+
}
|
1805 |
+
if ( isset( $_POST['saswp_software_schema_rating'] ) ){
|
1806 |
+
$software_schema_details['saswp_software_schema_rating'] = sanitize_text_field($_POST['saswp_software_schema_rating']);
|
1807 |
+
}
|
1808 |
+
if ( isset( $_POST['saswp_software_schema_rating_count'] ) ){
|
1809 |
+
$software_schema_details['saswp_software_schema_rating_count'] = sanitize_text_field($_POST['saswp_software_schema_rating_count']);
|
1810 |
+
}
|
1811 |
+
|
1812 |
+
update_post_meta( $post_id, 'saswp_software_schema_details', $software_schema_details );
|
1813 |
+
}
|
1814 |
//Service schema details ends here
|
1815 |
|
1816 |
|