Skip to content

Commit 61073fe

Browse files
committed
gpeb-display-stars-for-rating-fields.php: Added customizable SVG star with empty star display option for rating fields.
1 parent 4eafadb commit 61073fe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gp-entry-blocks/gpeb-display-stars-for-rating-fields.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
}, 10, 2 );
3838

3939
// Unescape HTML-encoded SVG content for rating fields
40-
function decode_rating_field_svgs($content, $entry_form, $entry) {
41-
foreach ($entry_form['fields'] as $field) {
42-
if ($field->get_input_type() === 'rating' && isset($entry[$field->id]) && strpos($entry[$field->id], '<svg') !== false) {
43-
$content = str_replace(htmlspecialchars($entry[$field->id], ENT_QUOTES), $entry[$field->id], $content);
40+
if ( ! function_exists( 'decode_rating_field_svgs' ) ) {
41+
function decode_rating_field_svgs($content, $entry_form, $entry) {
42+
foreach ($entry_form['fields'] as $field) {
43+
if ($field->get_input_type() === 'rating' && isset($entry[$field->id]) && strpos($entry[$field->id], '<svg') !== false) {
44+
$content = str_replace(esc_html($entry[$field->id]), $entry[$field->id], $content);
45+
}
4446
}
47+
return $content;
4548
}
46-
return $content;
4749
}
4850
add_filter('gpeb_loop_entry_content', 'decode_rating_field_svgs', 10, 3);
4951
add_filter('gpeb_view_entry_content', 'decode_rating_field_svgs', 10, 3);

0 commit comments

Comments
 (0)