From d9024cbe59a43da10f7baa332991b9f2d0025e65 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 24 May 2020 21:50:09 +0100 Subject: [PATCH] readingtime: limit replacements to the 1st occurrence --- modules/feature-readingtime.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/feature-readingtime.php b/modules/feature-readingtime.php index 85deeeb..1ad4174 100644 --- a/modules/feature-readingtime.php +++ b/modules/feature-readingtime.php @@ -26,7 +26,12 @@ register_module([ $insert = "{$reading_time[0]} minute read"; // 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 - $parts["{content}"] = str_replace("", "

$insert

", $parts["{content}"]); + $replace_count = 1; // Without a temp variable we get "only variables can be passed by reference", ref PHP 7.4.6 + $parts["{content}"] = str_replace( + "", "

$insert

", + $parts["{content}"], + $replace_count + ); }); } ]);