Skip to content

Commit 87a367f

Browse files
authored
Merge pull request #68 from n49/slider_v1.0.96
prioritized font-load before other scripts
2 parents ddc50fb + ad9a32e commit 87a367f

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

includes/class-feed-shortcode.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,37 @@ private function extract_jsonld_schema(&$html) {
3333

3434
/**
3535
* Extract all link and script tags from head section (everything except JSON-LD schema)
36+
* Prioritizes font links to ensure they load first
3637
*/
3738
private function extract_head_resources($html) {
38-
$resources = '';
39+
$font_links = '';
40+
$other_links = '';
41+
$scripts = '';
42+
3943
// Extract head content
4044
if (preg_match('/<head[^>]*>(.*?)<\/head>/is', $html, $head_matches)) {
4145
$head_content = $head_matches[1];
4246

4347
// Extract all link tags
4448
if (preg_match_all('/<link[^>]*>/i', $head_content, $link_matches)) {
45-
$resources .= implode("\n", $link_matches[0]) . "\n";
49+
foreach ($link_matches[0] as $link) {
50+
// Prioritize font links (Google Fonts, etc.)
51+
if (preg_match('/fonts\.(googleapis|gstatic)/i', $link) || preg_match('/font/i', $link)) {
52+
$font_links .= $link . "\n";
53+
} else {
54+
$other_links .= $link . "\n";
55+
}
56+
}
4657
}
4758

4859
// Extract all script tags with src attribute (external scripts)
4960
if (preg_match_all('/<script[^>]*src=["\'][^"\']+["\'][^>]*><\/script>/i', $head_content, $script_matches)) {
50-
$resources .= implode("\n", $script_matches[0]);
61+
$scripts = implode("\n", $script_matches[0]);
5162
}
5263
}
53-
return trim($resources);
64+
65+
// Return with font links first
66+
return trim($font_links . $other_links . $scripts);
5467
}
5568

5669
/**

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.0.95
6+
Version: 1.0.96
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.0.95');
25+
define('OPIO_PLUGIN_VERSION' , '1.0.96');
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.0.95
5+
Stable tag: 1.0.96
66
License: GPLv2 or later
77
License URI: http://www.gnu.org/licenses/gpl-2.0.html
88

0 commit comments

Comments
 (0)