forked from Adleraci/adlerka.top
test inlining
This commit is contained in:
parent
20d8f2513c
commit
729a80b647
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
function inlineLocalStylesFromHref($inputString) {
|
function inlineLocalStylesFromHref($inputString) {
|
||||||
// Define the regular expression pattern to match <link> tags with href attribute for CSS files
|
// Define the regular expression pattern to match <link> tags with href attribute for CSS files
|
||||||
$pattern = '/<link.*?href=["\']\/(.*?)["\'].*?rel=["\']stylesheet["\'].*?>/i';
|
$pattern = '/<link.*?(?:href=["\']\/(.*?)["\'].*?rel=["\']stylesheet["\']|rel=["\']stylesheet["\'].*?href=["\']\/(.*?)["\']).*?>/i';
|
||||||
|
|
||||||
// Use preg_replace_callback to replace matched link tags with inline styles
|
// Use preg_replace_callback to replace matched link tags with inline styles
|
||||||
$outputString = preg_replace_callback($pattern, function($match) {
|
$outputString = preg_replace_callback($pattern, function($match) {
|
||||||
// Extract the href attribute value
|
// Extract the href attribute value
|
||||||
$href = $match[1];
|
$href = isset($match[1]) ? $match[1] : $match[2];
|
||||||
|
|
||||||
// Get the content of the local CSS file
|
// Get the content of the local CSS file
|
||||||
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
|
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
|
||||||
|
Loading…
Reference in New Issue
Block a user