<?php
/**
 * Preface.
 *
 * @package MadeByAura\Prime\Modules
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Modules;

use MadeByAura\Prime\Helpers\Preface as HelpersPreface;

defined( 'ABSPATH' ) || die();

/**
 * Preface.
 */
class Preface {
	/**
	 * Get title.
	 *
	 * @return string $title
	 */
	public static function get_title() {
		$title = '';

		if (
			is_home() ||
			is_singular( 'post' ) ||
			is_category() ||
			is_tag() ||
			is_author()
		) {
			$title = HelpersPreface::get_blog_title();

		} elseif (
			is_post_type_archive( 'product' ) ||
			is_singular( 'product' ) ||
			is_tax( [ 'product_cat', 'product_tag' ] )
		) {
			$title = HelpersPreface::get_shop_title();

		} elseif ( is_singular( 'page' ) ) {
			$title = get_the_title();

		} elseif ( is_singular() ) {
			$post_type = get_queried_object()->post_type;
			$title     = get_post_type_object( $post_type )->label;

		} elseif ( is_post_type_archive() ) {
			$title = get_queried_object()->labels->name;
		}

		$title = $title ?: get_the_title();

		return apply_filters( 'aura_theme_preface_title', $title );
	}
}
