<?php
if (!function_exists('walker_news_template_excerpt_more_postfix')) {
    function walker_news_template_excerpt_more_postfix($more)
    {
        if (is_admin()) {
            return $more;
        }
        return '...';
    }
    add_filter('excerpt_more', 'walker_news_template_excerpt_more_postfix');
}
if (!function_exists('walker_news_template_excerpt_limit')) {
    function walker_news_template_excerpt_limit($length)
    {
        if (is_admin()) {
            return $length;
        }
        return 29;
    }
    add_filter('excerpt_length', 'walker_news_template_excerpt_limit');
}

if (!function_exists('walker_news_template_filter_archive_title')) :
    function walker_news_template_filter_archive_title($title)
    {
        return preg_replace('#^[\w\d\s]+:\s*#', '', strip_tags($title));
    }
    add_filter('get_the_archive_title', 'walker_news_template_filter_archive_title');
endif;


/**
 * Set the default image if none exists.
 *
 * @param string $html              The post thumbnail HTML.
 * @param int    $post_id           The post ID.
 * @param int    $post_thumbnail_id The post thumbnail ID.
 * @return html
 */
function walker_news_template_default_featured_post_thumbnail_html($html, $post_id, $post_thumbnail_id)
{
    if (empty($html)) {
        $html = '<img width="1000" height="800" class="wnt-default-thumbnail" src="' . get_template_directory_uri() . '/assets/images/wnt_default_featured_image.png' . '" alt="' . get_the_title($post_id) . '" />';
    }

    return $html;
}
add_filter('post_thumbnail_html', 'walker_news_template_default_featured_post_thumbnail_html', 5, 3);
