<?php
/*=================================================;
/* ARCHIVE - REMOVE PREFIX PAGE TITLE
/*=================================================
 * remove prefix archive on category
 */
function rt_archive_remove_prefix_title($title) {
    $title = single_cat_title('', false);

    return $title;
}
add_filter('get_the_archive_title', 'rt_archive_remove_prefix_title');

/*=================================================;
/* LIMIT TEXT OUTPUT THE EXCERPT
/*=================================================
 * limit summary text for post
 *
 * @version 1.0.0
 * @see https://developer.wordpress.org/reference/functions/get_the_excerpt/
 * @return string
 */
function rt_limit_excerpt_length($length) {
    return intval(rt_get_option('post_excerpt_length', 15));
}
add_filter('excerpt_length', 'rt_limit_excerpt_length', 999);

/*=================================================;
/* CHANGE SYMBOL EXCERPT MORE
/*================================================= */
function rt_custom_excerpt_more($more) {
    return '...';
}
add_filter('excerpt_more', 'rt_custom_excerpt_more');

/*=================================================;
/* GET POST VIEW
/*=================================================
 * Get post view from metabox
 * This value form core/post-view
 */
function rt_get_post_view() {
    $post_view = get_post_meta(get_the_ID(), 'wp_post_views_count', true);
    return !empty($post_view) ? number_format($post_view, 0, "", ".") : 0;
}

/*====================================================
/* READING TIME
/*====================================================*/
// Reading speed around 200 to 250 words per minute
// Get total words content from metabox 
function rt_get_reading_time() {
    $clean_content = strip_shortcodes(get_the_content());
    $clean_content = strip_tags($clean_content);
    $word_count = str_word_count($clean_content);
    $time = ceil($word_count / apply_filters('words_per_minute', 250));
    return $time;
}