1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-06-10 00:04:56 +00:00

Bugfix: only replace the first instance when inserting the estimated reading time

This commit is contained in:
Starbeamrainbowlabs 2020-05-25 21:26:36 +01:00
parent e55308f50a
commit 27b4d57c46
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -23,11 +23,12 @@ register_module([
$insert = "<small><em>{$reading_time[0]} minute read</em></small>"; $insert = "<small><em>{$reading_time[0]} minute read</em></small>";
// TODO: Create a canonical way to insert something just below the header - this might be tough though 'cause the that isn't handled by the page_renderer though // TODO: Create a canonical way to insert something just below the header - this might be tough though 'cause the that isn't handled by the page_renderer though
$replace_count = 1; // Without a temp variable we get "only variables can be passed by reference", ref PHP 7.4.6 $insert = "\n\t\t\t<p class='system-text-insert readingtime-estimate'>$insert</p>";
$parts["{content}"] = str_replace( $parts["{content}"] = substr_replace(
"</h1>", "</h1><p class='system-text-insert readingtime-estimate'>$insert</p>",
$parts["{content}"], $parts["{content}"],
$replace_count "</h1>$insert",
strpos($parts["{content}"], "</h1>"),
5
); );
}); });
} }