I'm trying to namespace my plugin functions by using a class and static functions. I'm getting the error:
Fatal error: Constructor Read_Time::read_time() cannot be static in /Applications/MAMP/htdocs/Wordpress/wp-content/plugins/readtime/readtime.php on line 41
class Read_Time {
public $options;
static public function init() {
add_filter('wp_meta', __CLASS__ . '::post_text');
}
static private function post_text() {
if(is_single()) {
global $post;
$content = $post->post_content;
echo("<h1>" . self::read_time($content) . "</h1>");
}
}
static private function word_count($to_count) {
return str_word_count($to_count);
}
static private function read_time($content) {
$wpm = 200;
$int_minutes = ceil( self::word_count($content) / $wpm );
if($int_minutes == 1) {
return $int_minutes . " minute";
}
else {
return $int_minutes . " minutes";
}
}
}
add_action('init', 'Read_Time::init');
Can someone tell me what I'm doing wrong?