Skip to content

Commit 0f8afb5

Browse files
authored
Merge pull request #87 from n49/slider_v1.1.16
fix schema extraction stripping Glide assets + wptexturize corrupting JS
2 parents 985ea60 + 8c98e8b commit 0f8afb5

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

includes/class-feed-shortcode.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,14 @@ private function extract_schema_from_html($html) {
231231
* Remove schema scripts from HTML content
232232
*/
233233
private function remove_schema_from_html($html) {
234-
// First, remove entire head sections that contain our schema (in case feed has nested head tags)
235-
// Match head tags that contain our schema script
236-
$head_with_schema_pattern = '/<head[^>]*>.*?<script[^>]*(?:id=["\']jsonldSchema["\'][^>]*type=["\']application\/ld\+json["\']|type=["\']application\/ld\+json["\'][^>]*id=["\']jsonldSchema["\'])[^>]*>.*?<\/script>.*?<\/head>/is';
237-
$html = preg_replace($head_with_schema_pattern, '', $html);
238-
239-
// Remove script tags with id="jsonldSchema" and type="application/ld+json"
240-
// Handles attributes in any order and with single or double quotes
241-
// This catches any remaining schema scripts (even outside head tags)
234+
// Remove schema script tags only — preserve other <head> contents (Glide CSS/JS, fonts)
242235
$schema_script_pattern = '/<script[^>]*(?:id=["\']jsonldSchema["\'][^>]*type=["\']application\/ld\+json["\']|type=["\']application\/ld\+json["\'][^>]*id=["\']jsonldSchema["\'])[^>]*>.*?<\/script>/is';
243236
$html = preg_replace($schema_script_pattern, '', $html);
244-
245-
// Also remove any stray/empty head tags that might be in the content
246-
// Remove opening <head> tags
237+
238+
// Strip <head>/<\/head> wrapper tags but keep their contents
247239
$html = preg_replace('/<head[^>]*>/i', '', $html);
248-
// Remove closing </head> tags
249240
$html = preg_replace('/<\/head>/i', '', $html);
250-
241+
251242
return $html;
252243
}
253244

@@ -300,7 +291,15 @@ public function process_output_buffer() {
300291
* Buffer callback - inject schemas into head section if they weren't output in wp_head
301292
*/
302293
public function buffer_callback($buffer) {
303-
// Only process if we have schemas
294+
// Fix &#038; entities that wptexturize injects inside <script> blocks
295+
// Applies to all feed types: reviewFeed, allReviewFeed, multiReviewFeed
296+
if (strpos($buffer, 'opioEntityId') !== false) {
297+
$buffer = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/is', function($m) {
298+
return str_replace($m[1], html_entity_decode($m[1], ENT_QUOTES | ENT_HTML5, 'UTF-8'), $m[0]);
299+
}, $buffer);
300+
}
301+
302+
// Only process schemas if we have them
304303
if (empty(self::$schema_scripts)) {
305304
return $buffer;
306305
}

opio.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Widget for OPIO Reviews
44
Plugin URI:
55
Description: Instantly add OPIO Reviews on your website to increase user confidence and SEO.
6-
Version: 1.1.15
6+
Version: 1.1.16
77
Author: Dhiraj Timalsina <dhiraj@n49.com>
88
Text Domain: widget-for-opio-reviews
99
Domain Path: /languages
@@ -22,7 +22,7 @@
2222

2323
require(ABSPATH . 'wp-includes/version.php');
2424

25-
define('OPIO_PLUGIN_VERSION' , '1.1.15');
25+
define('OPIO_PLUGIN_VERSION' , '1.1.16');
2626
define('OPIO_PLUGIN_FILE' , __FILE__);
2727
define('OPIO_PLUGIN_URL' , plugins_url(basename(plugin_dir_path(__FILE__ )), basename(__FILE__)));
2828
define('OPIO_ASSETS_URL' , OPIO_PLUGIN_URL . '/assets/');

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Author: Dhiraj Timalsina
33
Tags: Widget for OPIO Reviews, opio, reviews, rating, widget, google business, testimonials
44
Tested up to: 6.4
5-
Stable tag: 1.1.15
5+
Stable tag: 1.1.16
66
License: GPLv2 or later
77
License URI: http://www.gnu.org/licenses/gpl-2.0.html
88

0 commit comments

Comments
 (0)