'https://schema.org/',
'@type' => 'Product',
'name' => $title,
'description' => $description,
);
if ( ! empty( $image_url ) ) {
$schema['image'] = $image_url;
}
if ( $score > 0.0 ) {
$numeric_count = preg_replace( '/[^0-9]/', '', $count_text );
$count_val = ! empty( $numeric_count ) ? absint( $numeric_count ) : 1;
$schema['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => (string) number_format( $score, 1, '.', '' ),
'reviewCount' => (string) $count_val,
'bestRating' => '5',
'worstRating' => '1',
);
}
$schema = apply_filters( 'affistyle_product_schema_data', $schema, $data );
echo '' . "\n";
}
}