rebase on oct-10-2023
This commit is contained in:
@@ -28,70 +28,50 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Recipe';
|
||||
|
||||
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
|
||||
$schema['name'] = wp_strip_all_tags( $data['name'] );
|
||||
}
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
if ( isset( $data['reviewer-type'] ) && ! empty( $data['reviewer-type'] ) ) {
|
||||
$schema['author']['@type'] = wp_strip_all_tags( $data['reviewer-type'] );
|
||||
$schema['author']['@type'] = wp_strip_all_tags( (string)$data['reviewer-type'] );
|
||||
} else {
|
||||
$schema['author']['@type'] = 'Person';
|
||||
}
|
||||
if ( isset( $data['author'] ) && ! empty( $data['author'] ) ) {
|
||||
$schema['author']['name'] = wp_strip_all_tags( $data['author'] );
|
||||
}
|
||||
$schema['author']['name'] = ! empty( $data['author'] ) ? wp_strip_all_tags( (string)$data['author'] ) : NULL;
|
||||
|
||||
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
|
||||
$schema['description'] = wp_strip_all_tags( $data['description'] );
|
||||
}
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
|
||||
|
||||
if ( isset( $data['preperation-time'] ) && ! empty( $data['preperation-time'] ) ) {
|
||||
$schema['prepTime'] = wp_strip_all_tags( $data['preperation-time'] );
|
||||
}
|
||||
$schema['prepTime'] = ! empty( $data['preperation-time'] ) ? wp_strip_all_tags( (string)$data['preperation-time'] ) : NULL;
|
||||
|
||||
if ( isset( $data['cook-time'] ) && ! empty( $data['cook-time'] ) ) {
|
||||
$schema['cookTime'] = wp_strip_all_tags( $data['cook-time'] );
|
||||
}
|
||||
$schema['cookTime'] = ! empty( $data['cook-time'] ) ? wp_strip_all_tags( (string)$data['cook-time'] ) : NULL;
|
||||
if ( isset( $data['recipe-yield'] ) && ! empty( $data['recipe-yield'] ) ) {
|
||||
$schema['recipeYield'] = esc_html( $data['recipe-yield'] );
|
||||
}
|
||||
if ( isset( $data['recipe-keywords'] ) && ! empty( $data['recipe-keywords'] ) ) {
|
||||
$schema['keywords'] = wp_strip_all_tags( $data['recipe-keywords'] );
|
||||
}
|
||||
$schema['keywords'] = ! empty( $data['recipe-keywords'] ) ? wp_strip_all_tags( (string)$data['recipe-keywords'] ) : NULL;
|
||||
|
||||
if ( isset( $data['recipe-category'] ) && ! empty( $data['recipe-category'] ) ) {
|
||||
$schema['recipeCategory'] = wp_strip_all_tags( $data['recipe-category'] );
|
||||
}
|
||||
$schema['recipeCategory'] = ! empty( $data['recipe-category'] ) ? wp_strip_all_tags( (string)$data['recipe-category'] ) : NULL;
|
||||
|
||||
if ( isset( $data['recipe-cuisine'] ) && ! empty( $data['recipe-cuisine'] ) ) {
|
||||
$schema['recipeCuisine'] = wp_strip_all_tags( $data['recipe-cuisine'] );
|
||||
}
|
||||
$schema['recipeCuisine'] = ! empty( $data['recipe-cuisine'] ) ? wp_strip_all_tags( (string)$data['recipe-cuisine'] ) : NULL;
|
||||
|
||||
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
|
||||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
|
||||
|
||||
$schema['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
|
||||
$schema['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
|
||||
}
|
||||
if ( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) {
|
||||
$schema['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['review-count'] );
|
||||
}
|
||||
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string)$data['rating'] ) : NULL;
|
||||
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string)$data['review-count'] ) : NULL;
|
||||
}
|
||||
|
||||
if ( isset( $data['nutrition'] ) && ! empty( $data['nutrition'] ) ) {
|
||||
$schema['nutrition']['@type'] = 'NutritionInformation';
|
||||
$schema['nutrition']['calories'] = wp_strip_all_tags( $data['nutrition'] );
|
||||
$schema['nutrition']['calories'] = wp_strip_all_tags( (string)$data['nutrition'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['ingredients'] ) && ! empty( $data['ingredients'] ) ) {
|
||||
$recipe_ingredients = explode( ',', $data['ingredients'] );
|
||||
foreach ( $recipe_ingredients as $key => $value ) {
|
||||
$schema['recipeIngredient'][ $key ] = wp_strip_all_tags( $value );
|
||||
$schema['recipeIngredient'][ $key ] = wp_strip_all_tags( (string)$value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,14 +81,9 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
|
||||
if ( isset( $value['steps'] ) && ! empty( $value['steps'] ) ) {
|
||||
|
||||
$schema['recipeInstructions'][ $key ]['@type'] = 'HowToStep';
|
||||
$schema['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( $value['steps'] );
|
||||
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
|
||||
|
||||
$schema['recipeInstructions'][ $key ]['name'] = wp_strip_all_tags( $value['name'] );
|
||||
}
|
||||
if ( isset( $value['url'] ) && ! empty( $value['url'] ) ) {
|
||||
$schema['recipeInstructions'][ $key ]['url'] = wp_strip_all_tags( $value['url'] );
|
||||
}
|
||||
$schema['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( (string)$value['steps'] );
|
||||
$schema['recipeInstructions'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string)$value['name'] ) : NULL;
|
||||
$schema['recipeInstructions'][ $key ]['url'] = ! empty( $value['url'] ) ? wp_strip_all_tags( (string)$value['url'] ) : NULL;
|
||||
if ( isset( $value['image'] ) && ! empty( $value['image'] ) ) {
|
||||
$schema['recipeInstructions'][ $key ]['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['image'], 'URL' );
|
||||
}
|
||||
@@ -121,13 +96,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
|
||||
foreach ( $data['recipe-video'] as $key => $value ) {
|
||||
if ( isset( $value['video-name'] ) && ! empty( $value['video-name'] ) ) {
|
||||
$schema['video'][ $key ]['@type'] = 'VideoObject';
|
||||
if ( isset( $value['video-name'] ) && ! empty( $value['video-name'] ) ) {
|
||||
|
||||
$schema['video'][ $key ]['name'] = wp_strip_all_tags( $value['video-name'] );
|
||||
}
|
||||
if ( isset( $value['video-desc'] ) && ! empty( $value['video-desc'] ) ) {
|
||||
$schema['video'][ $key ]['description'] = wp_strip_all_tags( $value['video-desc'] );
|
||||
}
|
||||
$schema['video'][ $key ]['name'] = wp_strip_all_tags( (string)$value['video-name'] );
|
||||
$schema['video'][ $key ]['description'] = ! empty( $value['video-desc'] ) ? wp_strip_all_tags( (string)$value['video-desc'] ) : NULL;
|
||||
if ( isset( $value['video-image'] ) && ! empty( $value['video-image'] ) ) {
|
||||
$schema['video'][ $key ]['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['video-image'], 'URL' );
|
||||
}
|
||||
@@ -137,16 +107,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
|
||||
if ( isset( $value['recipe-video-embed-url'] ) && ! empty( $value['recipe-video-embed-url'] ) ) {
|
||||
$schema['video'][ $key ]['embedUrl'] = esc_url( $value['recipe-video-embed-url'] );
|
||||
}
|
||||
if ( isset( $value['recipe-video-duration'] ) && ! empty( $value['recipe-video-duration'] ) ) {
|
||||
$schema['video'][ $key ]['duration'] = wp_strip_all_tags( $value['recipe-video-duration'] );
|
||||
}
|
||||
if ( isset( $value['recipe-video-upload-date'] ) && ! empty( $value['recipe-video-upload-date'] ) ) {
|
||||
$schema['video'][ $key ]['uploadDate'] = wp_strip_all_tags( $value['recipe-video-upload-date'] );
|
||||
}
|
||||
if ( isset( $value['recipe-video-interaction-count'] ) && ! empty( $value['recipe-video-interaction-count'] ) ) {
|
||||
$schema['video'][ $key ]['interactionCount'] = wp_strip_all_tags( $value['recipe-video-interaction-count'] );
|
||||
}
|
||||
if ( isset( $value['recipe-video-expires-date'] ) && ! empty( $value['recipe-video-expires-date'] ) ) {
|
||||
$schema['video'][ $key ]['duration'] = ! empty( $value['recipe-video-duration'] ) ? wp_strip_all_tags( (string)$value['recipe-video-duration'] ) : NULL;
|
||||
$schema['video'][ $key ]['uploadDate'] = ! empty( $value['recipe-video-upload-date'] ) ? wp_strip_all_tags( (string)$value['recipe-video-upload-date'] ) : NULL;
|
||||
$schema['video'][ $key ]['interactionCount'] = ! empty( $value['recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string)$value['recipe-video-interaction-count'] ) : NULL;
|
||||
if ( isset( $value['recipe-video-expires-date'] ) && ! empty( $value['recipe-video-expires-date'] ) && is_string( $value['recipe-video-expires-date'] ) ) {
|
||||
$schema['video'][ $key ]['expires'] = wp_strip_all_tags( $value['recipe-video-expires-date'] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user