<?php
/**
 * Error404.
 *
 * @package MadeByAura\Prime\Pages
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Pages;

use MadeByAura\Prime\Base;
use MadeByAura\Prime\Helpers\SingletonTrait;

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

/**
 * Error404.
 */
class Error404 {
	use SingletonTrait;

	/**
	 * Constructor.
	 */
	protected function __construct() {
		// Add hooks after WordPress environment has been set up.
		add_action( 'wp', [ __CLASS__, 'add_hooks' ] );
	}

	/**
	 * Add hooks after WordPress environment has been set up.
	 */
	public static function add_hooks() {
		// Do not proceed if the current page is not 404.
		if ( ! is_404() ) {
			return;
		}

		// Disable page title.
		add_filter( 'aura_theme|view|disable|views/preface', '__return_true' );

		// Disable middle content.
		add_filter( 'aura_theme|view|disable|views/middle/content', '__return_true' );

		// Add sections.
		add_filter( 'aura_theme|view|disable|views/middle/open', [ __CLASS__, 'add_sections' ] );
	}

	/**
	 * Add sections.
	 */
	public static function add_sections() {
		Base::view( 'views/nothing-found' );
	}
}
