You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
cosmopet-architecture/wp-content/themes/cosmopet/modules/blog/module-controller.php

33 lines
885 B

<?php
class BlogPost extends \Timber\Post
{
/**
* Estimates time required to read a post.
*
* The words per minute are based on the English language, which e.g. is much
* faster than German or French.
*
* @link https://www.irisreading.com/average-reading-speed-in-various-languages/
*
* @return string
*/
public function reading_time()
{
$symb_per_minute = 2280;
$symb = strlen(wp_strip_all_tags($this->content()));
$minutes = round($symb / $symb_per_minute);
/* translators: %s: Time duration in minute or minutes. */
return sprintf(_n('%s мин.', '%s мин.', $minutes), (int) $minutes);
}
}
add_filter('timber/post/classmap', function ($classmap) {
$custom_classmap = [
'post' => BlogPost::class,
];
return array_merge($classmap, $custom_classmap);
});