From 8807414d1b61a1b7deae503d14328b1f382df756 Mon Sep 17 00:00:00 2001 From: floppy0 <31189947+floppy0@users.noreply.github.com> Date: Thu, 15 Feb 2018 14:51:21 +0100 Subject: [PATCH] reading time --- bl-kernel/page.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 5388218a..b260c58f 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -485,6 +485,17 @@ class Page { return $list; } + // Returns the amount of minutes takes to read the page + public function readingTime() { + $words = $this->content(true); + $words = strip_tags($words); + $words = str_word_count($words); + $average = $words / 200; + $minutes = round($average); + + return $minutes; + } + // Returns relative time (e.g. "1 minute ago") // Based on http://stackoverflow.com/a/18602474 // Modified for Bludit