<?php

/**
 * Post-related functionality and customizations
 *
 * @package Kubelio\Core
 * @since 1.0.0
 */

namespace Kubelio\Core;

if (! defined('ABSPATH')) {
	exit;
}

/**
 * Post Class
 */
class Post {

	/**
	 * Constructor.
	 */
	public function __construct() {
		add_filter('get_the_archive_title', array($this, 'archive_remove_prefix_title'));
		add_filter('excerpt_more', array($this, 'custom_excerpt_more'));
	}

	/**
	 * Remove prefix from archive titles
	 *
	 * Removes the default 'Category:', 'Tag:', etc. prefixes from archive titles
	 *
	 * @param string $title The archive title.
	 * @return string
	 */
	public function archive_remove_prefix_title($title) {
		if (is_category()) {
			$title = single_cat_title('', false);
		} elseif (is_tag()) {
			$title = single_tag_title('', false);
		} elseif (is_author()) {
			$title = get_the_author();
		} elseif (is_post_type_archive()) {
			$title = post_type_archive_title('', false);
		}

		return $title;
	}

	/**
	 * Change symbol excerpt more
	 *
	 * @param string $more The string shown within the more link.
	 * @return string
	 */
	public function custom_excerpt_more($more) {
		return '...';
	}
}
