Yoast\WP\SEO\Presentations
Indexable_Presentation::generate_estimated_reading_time_minutes
Generates the estimated reading time.
Метод класса: Indexable_Presentation{}
Хуков нет.
Возвращает
int|null. The estimated reading time.
Использование
$Indexable_Presentation = new Indexable_Presentation(); $Indexable_Presentation->generate_estimated_reading_time_minutes();
Код Indexable_Presentation::generate_estimated_reading_time_minutes() Indexable Presentation::generate estimated reading time minutes Yoast 27.4
public function generate_estimated_reading_time_minutes() {
if ( $this->model->estimated_reading_time_minutes !== null ) {
return $this->model->estimated_reading_time_minutes;
}
if ( $this->context->post === null ) {
return null;
}
// 200 is the approximate estimated words per minute across languages.
$words_per_minute = 200;
$words = \str_word_count( \wp_strip_all_tags( $this->context->post->post_content ) );
return (int) \round( $words / $words_per_minute );
}