Skip to content

Instantly share code, notes, and snippets.

@Burick
Forked from sepiariver/readtime.snippet.php
Created December 21, 2017 12:24
Show Gist options
  • Save Burick/3b7c98823de11f7b7e9c8fd3d64385a2 to your computer and use it in GitHub Desktop.
Save Burick/3b7c98823de11f7b7e9c8fd3d64385a2 to your computer and use it in GitHub Desktop.
Reading time MODX output filter.
<?php
$options = (int) $modx->getOption('options', $scriptProperties, 200, true); // 200 words per minute
$wordCount = (int) str_word_count(strip_tags($input)); // To display word count set options to 0
if ($options === 0) return $wordCount;
return ceil($wordCount / abs($options));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment