<?php
/**
 * Echo post fragments.
 *
 * @package SplendorStudio\Framework\Templates\Fragments
 *
 * @since   1.0.0
 */
class Fancify_Lite_Post_Fragment extends Fancify_Lite_Template_Parts {
	/**
	 * post object
	 * @since    1.0.0
	 */
	public $post;
	/**
	 * Call type ajax or simple
	 * @since    1.0.0
	 */
	public $call_type = null;
	/**
	 * Constructor
	 *
	 * @since    1.0.0
	 */
	function __construct() {
		$this->register_hook_callbacks();
	}
	/**
	 * Set post call type
	 *
	 * @since    1.0.0
	 */
	public function set_post( $query ) {
		$this->post = $query->post;
		$this->call_type = 'ajax';
	}

	/**
	 * Register callbacks for actions and filters
	 *
	 * @since    1.0.0
	 */
	protected function register_hook_callbacks() {
		// Get post title
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_page_banner' , array( $this, 'post_page_title' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_before_loop', array( $this, 'post_search_title' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_main_grid_before_markup', array( $this, 'single_post_banner' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_body', array( $this, 'post_body' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_content_after_markup', array( $this, 'post_more_link' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_body', array( $this, 'post_content_navigation' ), 20);
		Fancify_Lite_Actions::add_smart_action( 'next_post_link', array( $this, 'next_post_link' ), 10, 4 );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_after_markup', array( $this, 'post_share' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_after_markup', array( $this, 'post_navigation' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_after_markup', array( $this, 'post_author' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_post_after_markup', array( $this, 'post_suggestion' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_after_posts_loop', array( $this, 'posts_pagination' ) );
		Fancify_Lite_Actions::add_smart_action( 'fancify_lite_no_post', array( $this, 'fancify_lite_no_post' ) );
		Fancify_Lite_Actions::add_smart_action( 'the_password_form', array( $this, 'post_password_form' ) );
	}

	/**
	 * Echo search post title.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_page_title() {
		global $post;

		$this->post = $post;

		if ( is_null( $post ) ) {
			return;
		}

		$title_bar = Fancify_Lite_ACF::get_field( 'page_option_title_bar', 'theme_default', $post->ID );

		if ( 'theme_default' === $title_bar ) {
			$title_bar = get_theme_mod( 'general_title_layout_option', 'display_title_only' );
		}

		if ( 'no_title' === $title_bar ) {
			return;
		}

		// get Images
		$post_image = Fancify_Lite_Image::get_post_attachment( $post->ID, 'full' );

		// Set post type
		$post_type = isset( $post->post_type ) ? $post->post_type : ''; 


		// If post-type is post or page show content based on blog design
		if ( 'page' == $post_type || is_archive() || is_search() ) {

			// Set title
			$title_escaped = isset( $post->post_title ) ? esc_html( $post->post_title ) : '';

			// top banner of pages and posts- get image from featured image.
			if ( isset( $post_image->src ) && $title_bar === 'display_title_image' ) {

				// Get featured image size
				$page_featured_image = Fancify_Lite_ACF::get_field( 'page_option_featured_image_size', 'theme_default', $post->ID );
				// Get custom size from page option
				if ( $page_featured_image == 'custom' ) {
					$height = Fancify_Lite_ACF::get_field( 'page_option_featured_image_height_px', '630', $post->ID );
					$width = Fancify_Lite_ACF::get_field( 'page_option_featured_image_width_px', '1920', $post->ID );
				} else {
					$featured_image = get_theme_mod( 'general_page_featured_image' );
					$height = isset( $featured_image['height'] ) ? $featured_image['height'] : 630;
					$width  = isset( $featured_image['width'] )  ? $featured_image['width'] : 1920;
				}

				$image = $this->image_edit( null, $post_image->src, array( $width , $height ) );

				fancify_lite_open_markup_e( 'fancify_lite_post_banner', 'div', array( 'class' => 'fancify-post-banner' ) );

					fancify_lite_selfclose_markup_e(
						'fancify_lite_post_banner_image',
						'img',
						array(
							'src'      => esc_url( $image ),
							'alt'      => esc_attr( $post_image->alt ),
							'itemprop' => 'image',
							'class'    => 'fancify-post-banner-image',
						),
						$post_image
					);

					fancify_lite_open_markup_e( 'fancify_lite_post_banner_title_box', 'div', array( 'class' => 'fancify-post-banner-title-box' ) );

						fancify_lite_open_markup_e( 'fancify_lite_post_banner_title', 'h1', array( 'class' => 'fancify-post-banner-title' ) );

							fancify_lite_output_e( 'fancify_lite_post_banner_title', $title_escaped );

						fancify_lite_close_markup_e( 'fancify_lite_post_banner_title', 'h1' );

					fancify_lite_close_markup_e( 'fancify_lite_post_banner_title_box', 'div' );

				fancify_lite_close_markup_e( 'fancify_lite_post_banner', 'div' );

			} else {
				// In case it's archive page
				$title_escaped = ( is_archive() ) ? get_the_archive_title() : $title_escaped;
				$title_escaped = ( is_search() ) ? esc_html__( 'Search' , 'fancify-lite' ) : $title_escaped;

				fancify_lite_open_markup_e( 'fancify_lite_post_banner', 'div', array( 'class' => 'fancify-post-banner-noimage' ) );

					fancify_lite_open_markup_e( 'fancify_lite_post_banner_title', 'h1', array( 'class' => 'fancify-post-banner-title' ) );

						fancify_lite_output_e( 'fancify_lite_post_banner_title', $title_escaped );

					fancify_lite_close_markup_e( 'fancify_lite_post_banner_title', 'h1' );

				fancify_lite_close_markup_e( 'fancify_lite_post_banner', 'div' );

			}
		}
	}

	/**
	 * Print single post featured image.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function single_post_banner() {
		global $post;

		$this->post = $post;

		// Get post type
		$post_type = isset( $post->post_type ) ? $post->post_type : '';

		// Single posts.
		if ( is_single() && 'post' === $post_type ) {

			if ( has_post_thumbnail() ) {

				// Check if user enabled single post image
				$show_image_single = get_theme_mod( 'enable_single_blog_image', true );
				if ( !$show_image_single ) {
					return;
				}
				// Get height and width
				$featured_image = get_theme_mod( 'single_featured_image' );
				$height = isset( $featured_image['height'] ) ? $featured_image['height'] : 720;
				$width  = isset( $featured_image['width'] )  ? $featured_image['width'] : 1674;

				$post_image = Fancify_Lite_Image::get_post_attachment( $post->ID, 'full' );

				// Get image 
				$image = $this->image_edit( null, $post_image->src, array( $width , $height ) );

				fancify_lite_open_markup_e( 'fancify_lite_single_post', 'div', array( 'class' => 'fancify-single-post' ) );

				fancify_lite_selfclose_markup_e(
					'fancify_lite_single_post_thumbnail',
					'img',
					array(
						'height'    => esc_attr( $height ),
						'src'       => esc_url( $image ), // Automatically escaped.
						'class'     => 'fancify-single-post-thumbnail',
						 'alt'      => esc_attr( $post_image->alt ), // Automatically escaped.
						// 'itemprop' => 'image',
					),
					esc_url( $image )
				);

				// display article category
				if ( has_category() ) {

					$article_category      = get_the_category();
					$article_category_name = $article_category[0]->name;
					$article_category_link = get_category_link( $article_category[0]->cat_ID );

				} else {

					$article_category_name = esc_attr__( 'Uncategorized', 'fancify-lite' );

				}

				fancify_lite_open_markup_e(
					'fancify_lite_post_category',
					'a', 
					array(
						'class' => 'fancify-article-category',
						'href'  => esc_url( $article_category_link )
					)
				);

				fancify_lite_output_e( 'fancify_lite_post_category', esc_html( $article_category_name ) );

				fancify_lite_close_markup_e( 'fancify_lite_post_category', 'a' );

				fancify_lite_close_markup_e( 'fancify_lite_single_post', 'div' );

			} else {

				fancify_lite_open_markup_e( 'fancify_lite_single_post', 'div', array( 'class' => 'fancify-single-post fancify-single-post-no-thumbnail' ) );
				
				fancify_lite_close_markup_e( 'fancify_lite_single_post', 'div' );

			}
		}

	}

	/**
	 * Echo search post title.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_search_title() {
		if ( !is_search() ) {
			return;
		}
		
		$search_markup = fancify_lite_open_markup_e(
			'fancify_lite_search_title_text',
			'div', 
			array(
				'class' => 'fancify-search-result-text',
			)
		);

			$search_markup .= fancify_lite_output_e( 'fancify_lite_search_title_text', esc_html__('Search results for: ', 'fancify-lite') );

			$search_markup = fancify_lite_open_markup_e(
				'fancify_lite_search_title_text[:span]',
				'span', 
				array(
					'class' => 'fancify-search-result-text',
				)
			);
				
				$search_markup .= fancify_lite_output_e( 'fancify_lite_search_title_text[:span]', esc_html( get_search_query() ) );
			
			$search_markup .= fancify_lite_close_markup_e( 'fancify_lite_search_title_text[:span]', 'span' );

		
		$search_markup .= fancify_lite_close_markup_e( 'fancify_lite_search_title_text', 'div' );
		printf( $search_markup );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped before print
	}

	/**
	 * Get post body
	 *
	 * @since 1.0.0
	 * 
	 * @return void
	 */
	public function post_body() {
		global $post;

		$this->post = $post;

		// Get post type
		$post_type = isset( $this->post->post_type ) ? $this->post->post_type : '';

		// If post-type is post or page show content based on blog design
		if ( 'page' == $post_type || 'post' == $post_type ) {

			if ( ! is_singular() && get_theme_mod( 'blog_page_featured_image', true ) ) {
				// display post media
				$this->post_media();
			}

			fancify_lite_open_markup_e( 'fancify_lite_post_title_container', 'div', array( 'class' => 'fancify-article-title-container' ) );

				// displays post meta tags
				$this->post_meta();

				// post title.
				$this->post_title();
			fancify_lite_close_markup_e( 'fancify_lite_post_title_container', 'div' );

			// post content
			$this->post_content();

		} else {
			the_content();
		}

	}

	/**
	 * Display post media in archive page
	 *
	 * @since 1.0.0
	 *
	 * @return bool
	 */
	public function post_media() {
		$post = $this->post;

		$post_format = get_post_format();

		switch ( $post_format ) {

		case false:
		// Image post format
		case 'image':

			/**
			 * Image Post Format
			 *
			 * If post has thumbnail image will be displayed
			 */
			if ( ! has_post_thumbnail() || ! current_theme_supports( 'post-thumbnails' ) ) {
				return false;
			}

			fancify_lite_open_markup_e( 'fancify_lite_post_media', 'div', array( 'class' => 'fancify-article-media' ) );
			

			fancify_lite_open_markup_e( 'fancify_lite_post_image', 'div', array( 'class' => 'fancify-article-image' ) );

			if ( ! is_singular() ) {

				fancify_lite_open_markup_e(
					'fancify_lite_post_image_link',
					'a',
					array(
						'href'  => esc_url( get_permalink() ), // Automatically escaped.
						'title' => the_title_attribute('echo=0'),
					)
				);

			}

			fancify_lite_open_markup_e('fancify_lite_post_image_item_wrap', 'picture');

			// Call image edit
			$edit = apply_filters( 'fancify_lite_post_image_edit', true );

			if ( $edit ) {
				$image_size = get_theme_mod( 'blog_page_image_size' );
				$height = isset( $image_size['height'] ) ? $image_size['height'] : 640 ;
				$width  = isset( $image_size['width'] )  ? $image_size['width']  : 1136 ;
				// Get full image
				$post_image = Fancify_Lite_Image::get_post_attachment( $post->ID, 'full' );

				$image = $this->image_edit( null, $post_image->src, array( $width , $height ) );

				fancify_lite_selfclose_markup_e(
					'fancify_lite_post_image_item',
					'img',
					array(
						'width'    => esc_attr( $width ),
						'height'   => esc_attr( $height ),
						'src'      => esc_url( $image ), // Automatically escaped.
						'itemprop' => 'image',
						'alt'      => esc_attr( $post_image->alt ),
					),
					$image
				);

			} else {

				// Fancify API isn't available
				the_post_thumbnail();

			}

			fancify_lite_close_markup_e( 'fancify_lite_post_image_item_wrap', 'picture' );

			if ( ! is_singular() ) {

				fancify_lite_close_markup_e( 'fancify_lite_post_image_link', 'a' );

			}

			// Get category
			$category = $this->get_category();

			fancify_lite_close_markup_e( 'fancify_lite_post_image', 'div' );

			fancify_lite_close_markup_e( 'fancify_lite_post_media', 'div', array('class' => 'fancify-article-media' ) );

			break;

		case 'quote':

			fancify_lite_open_markup_e( 'fancify_lite_post_quote', 'div', array( 'class' => 'fancify-post-quote-container' ) );

				fancify_lite_open_markup_e( 'fancify_lite_post_quote_doublequotation', 'span', array( 'class' => 'fancify-post-quote-doublequotation' ) );
					fancify_lite_output_e( 'fancify_lite_post_category', '“' );
				fancify_lite_close_markup_e( 'fancify_lite_post_quote_doublequotation', 'span', array( 'class' => 'fancify-post-quote-doublequotation' ) );

				fancify_lite_open_markup_e(
					'fancify_lite_post_quote_content', 
					'a', 
					array(
						'class' => 'fancify-post-quote-content',
						'href'  => esc_url( get_post_permalink() ),
					)
				);
					fancify_lite_output_e( 'fancify_lite_post_category', esc_html( get_the_excerpt() ) );
				fancify_lite_close_markup_e( 'fancify_lite_post_quote_content', 'a', array( 'class' => 'fancify-post-quote-content' ) );

				fancify_lite_open_markup_e( 'fancify_lite_post_quote_author', 'span', array( 'class' => 'fancify-post-quote-author' ) );
					fancify_lite_output_e( 'fancify_lite_post_category', esc_html( get_the_author() ) );
				fancify_lite_close_markup_e( 'fancify_lite_post_quote_author', 'span', array( 'class' => 'fancify-post-quote-author' ) );

			fancify_lite_close_markup_e( 'fancify_lite_post_quote', 'div', array( 'class' => 'fancify-post-quote-container' ) );

			break;

		}

		do_action( 'fancify_lite_do_blog_post_format', $this );
	}

	/**
	 * Get resized image
	 * @return [array]         [image]
	 */
	public function image_edit( $attache_id = null, $attache_url = null, $resize = array() ) {
		/**
		 * Filter the arguments to edit the post image.
		 */
		$edit_args = apply_filters(
			'fancify_lite_edit_post_gallery_args',
			array(
				'resize' => $resize,
			)
		);

		$image = Fancify_Lite_Image::edit_attachment_media( $attache_id, $attache_url, $edit_args['resize'] );

		return $image;
	}    

	/**
	 * display article category
	 * @return void
	 */
	public function get_category() {
		$article_category = array();

		// get cat
		if ( has_category() ) {

			$article_category                   = get_the_category();

			$article_category['name']           = $article_category[0]->name;

			$article_category['category_link']  = get_category_link( $article_category[0]->cat_ID );
			// Free
			unset($article_category[0]);

		} else {

			$article_category['name'] = esc_html( 'Uncategorized', 'fancify' );
			$article_category['category_link'] = '#';

		}

		fancify_lite_open_markup_e( 
			'fancify_lite_post_category', 
			'a', 
			array(
				'class' => 'fancify-article-category',
				'href'  => esc_url( $article_category['category_link'] ),
			)
		);

		fancify_lite_output_e( 'fancify_lite_post_category', esc_html( $article_category['name'] ) );

		fancify_lite_close_markup_e( 'fancify_lite_post_category', 'a' );
	}

	/**
	 * Echo post meta.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_meta() {
		$post = $this->post;

		// Filter whether {@see post_meta()} should be short-circuit or not
		if ( apply_filters( 'fancify_lite_pre_post_meta', 'post' !== get_post_type() ) ) {
			return;
		}

		// If it's qoute
		if ( get_post_format() == 'quote' && !is_singular() ) {
			return;
		}

		fancify_lite_open_markup_e('fancify_lite_post_meta', 'ul', array('class' => 'fancify-article-meta '));

		// Get author
		$article_author_escaped = esc_html( get_the_author_meta( 'display_name' ) );

		fancify_lite_open_markup_e( 'fancify_lite_post_meta_author', 'li', array( 'class' => 'fancify-article-author' ) );

			fancify_lite_output_e( 'fancify_lite_post_meta_author', get_avatar( get_the_author_meta( 'ID' ), '45' ) );

			fancify_lite_open_markup_e( 
				'fancify_lite_post_meta_author_title', 
				'a', 
				array(
					'class' => 'fancify-article-author-name',
					'href'      => esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
				)
			);

				fancify_lite_output_e( 'fancify_lite_post_meta_author_title', $article_author_escaped );

			fancify_lite_close_markup_e( 'fancify_lite_post_meta_author_title', 'a' );

		fancify_lite_close_markup_e( 'fancify_lite_post_meta_author', 'li' );

		// get date of post
		$article_date_escaped = get_the_date();

		fancify_lite_open_markup_e( 'fancify_lite_post_meta_article_date', 'li', array( 'class' => 'fancify-article-date' ) );

			fancify_lite_open_markup_e( 'fancify_lite_post_meta_article_date_icon', 'i', array( 'class' => 'fancify-font fancify-font-calendar-1' ) );
				
			fancify_lite_close_markup_e( 'fancify_lite_post_meta_article_date_icon', 'i' );

			fancify_lite_output_e( 'fancify_lite_post_meta_article_date', esc_html( $article_date_escaped ) );

		fancify_lite_close_markup_e( 'fancify_lite_post_meta_article_date', 'li' );

		// comment count
		$article_comment_count = get_comment_count( $post->ID )['all'];

		if ( ! $article_comment_count ) {

			$article_comment = $article_comment_count . ' ' . __( 'Comment', 'fancify-lite' );

		} else {

			$article_comment = $article_comment_count . ' ' . __( 'Comments', 'fancify-lite' );

		}

		fancify_lite_open_markup_e( 'fancify_lite_post_meta_article_comment', 'li', array( 'class' => 'fancify-article-comment' ) );

			fancify_lite_open_markup_e( 'fancify_lite_post_meta_article_comment_icon', 'i', array( 'class' => 'fancify-font fancify-font-comment-alt' ) );
			fancify_lite_close_markup_e( 'fancify_lite_post_meta_article_comment_icon', 'i' );
			fancify_lite_open_markup_e(
				'fancify_lite_post_meta_article_comment_text', 
				'a', 
				array(
					'href' => esc_url( get_comments_link() )
				)
			);
			fancify_lite_output_e( 'fancify_lite_post_meta_article_comment_text', esc_html( $article_comment ) );
			fancify_lite_close_markup_e( 'fancify_lite_post_meta_article_comment_text', 'a' );

		fancify_lite_close_markup_e('fancify_lite_post_meta_article_comment', 'li');
		
		fancify_lite_close_markup_e('fancify_lite_post_meta', 'ul');
	}

	/**
	 * Echo post title, If it's not qoute post-format
	 *
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_title() {
		$post = $this->post;

		$title  = get_the_title();

		if ( empty( $title ) || ( get_post_format() == 'quote' && ! is_singular() ) ) {
			return;
		}

		if ( ! is_page() ) {


			fancify_lite_open_markup_e(
				'fancify_lite_post_title',
				'h2',
				array(
					'class'    => 'fancify-article-title',
					'itemprop' => 'headline',
				)
			);

				fancify_lite_open_markup_e(
					'fancify_lite_post_title_link',
					'a',
					array(
						'href'  => esc_url( get_permalink() ),
						'title' => the_title_attribute( 'echo=0' ),
						'rel'   => 'bookmark',
					)
				);

				fancify_lite_output_e( 'fancify_lite_post_title_text', esc_html( $title ) );

				fancify_lite_close_markup_e('fancify_lite_post_title_link', 'a');

			fancify_lite_close_markup_e( 'fancify_lite_post_title', 'h2' );
		}
	}

	/**
	 * Echo post content.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_content() {
		$post = $this->post;

		$post_format = get_post_format();

		if ( ! is_singular() ) {

			if ( 'quote' != $post_format ) {
				fancify_lite_open_markup_e(
					'fancify_lite_post_content',
					'div',
					array(
						'class'    => 'fancify-article-content',
						'itemprop' => 'text',
					)
				);

				if ( has_excerpt() ) {

					the_excerpt();

				} else {

					echo wp_kses_post( wp_trim_words( get_the_content(), 30 ) );

				}
			}else{
				fancify_lite_open_markup_e(
					'fancify_lite_post_content',
					'div',
					array(
						'class'    => 'fancify-article-content fancify-firstletter',
						'itemprop' => 'text',
					)
				);
			}

		} else {
			if( is_singular( 'post' ) ){
				fancify_lite_open_markup_e(
					'fancify_lite_post_content',
					'div',
					array(
						'class'    => 'fancify-article-content fancify-firstletter-big',
						'itemprop' => 'text',
					)
				);

				the_content();
			} else {
				fancify_lite_open_markup_e(
					'fancify_lite_post_content',
					'div',
					array(
						'class'    => 'fancify-article-content',
						'itemprop' => 'text',
					)
				);

				the_content();
			}
		}

		if (is_singular() && 'open' === get_option('default_ping_status') && post_type_supports($post->post_type, 'trackbacks')) {
			echo '<!--';
			trackback_rdf();
			echo '-->' . "\n";
		}

		fancify_lite_close_markup_e('fancify_lite_post_content', 'div');
	}

	/**
	 * Read more link
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_more_link() {
		$title  = get_the_title();

		if ( empty( $title ) || is_singular() || get_post_format() == 'quote' ) {
			return;
		}
		

		fancify_lite_open_markup_e(
			'fancify_lite_post_more_link_div',
			'a',
			array(
				'href'  =>  esc_url( get_permalink() ), // Automatically escaped.
				'class' => 'fancify-article-more-button fancify-new-main-button',
			)
		);
			fancify_lite_open_markup_e('fancify_lite_post_more_link[screen_reader]', 'span', array('class' => 'screen-reader-text',) );
			
				fancify_lite_output_e( 'fancify_lite_post_more_link[screen_reader_text]', esc_html( $title ) );

			fancify_lite_close_markup_e('fancify_lite_post_more_link[screen_reader]', 'span');

			$reading = get_theme_mod( 'blog_page_read_more', __( 'Read More', 'fancify-lite' ) );

			fancify_lite_output_e('fancify_lite_post_more_link_text', esc_html( $reading ) );

		fancify_lite_close_markup_e('fancify_lite_post_more_link_div', 'a');
	}

	/**
	 * Echo post content navigation.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_content_navigation() {
		if ( ! is_single() ) {
			return;
		}

		echo wp_link_pages(
			array(
				'before' => fancify_lite_open_markup( 'fancify_lite_post_content_navigation', 'p', array( 'class' => 'fancify-text-bold' ) ) . fancify_lite_output('fancify_lite_post_content_navigation_text', __( 'Pages:', 'fancify-lite' ) ),
				'after'  => fancify_lite_close_markup( 'fancify_lite_post_content_navigation', 'p' ),
				'echo'   => false,
			)
		);
	}

	/**
	 * Modify post "next link".
	 *
	 * @since 1.0.0
	 *
	 * @param string $output "Next link" output.
	 * @param string $format Link output format.
	 * @param string $link Link permalink format.
	 * @param int    $post Post ID.
	 *
	 * @return string The modified "next link".
	 */
	public function next_post_link($output, $format, $link, $post) {
		// Using $link won't apply WP filters, so rather strip tags the $output.
		$text = strip_tags($output);

		$output = fancify_lite_open_markup(
			'fancify_lite_next_link[_post_navigation]',
			'a',
			array(
				'href'  => esc_url( get_permalink($post) ), // Automatically escaped.
				'rel'   => 'next',
				'title' => esc_attr( $post->post_title ), // Automatically escaped.
			)
		);

		$output .= fancify_lite_output('fancify_lite_next_text[_post_navigation]', $text);

		$output .= fancify_lite_open_markup(
			'fancify_lite_next_icon[_post_navigation]',
			'span',
			array(
				'class'       => 'fancify-icon-angle-double-right fancify-margin-small-left',
				'aria-hidden' => 'true',
			)
		);

		$output .= fancify_lite_close_markup('fancify_lite_next_icon[_post_navigation]', 'span');

		$output .= fancify_lite_close_markup('fancify_lite_next_link[_post_navigation]', 'a');

		return $output;
	}

	/**
	 * Echo post navigation.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 *
	 * phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Layout mirrors HTML markup
	 */
	public function post_share() {
		$post = $this->post;

		if ( ! is_singular( 'post' ) ) {
			return;
		}

		if ( false === get_theme_mod( 'blog_options_share', true ) ) {
			return;
		}

		// Get current page URL
		$fancify_lite_URL = urlencode( get_permalink() );

		// Get current page title
		$fancify_lite_Title = htmlspecialchars( urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) ), ENT_COMPAT, 'UTF-8' );

		// Get Post Thumbnail for pinterest
		$fancify_lite_Thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
		$fancify_lite_Thumbnail = isset( $fancify_lite_Thumbnail[0] ) ? $fancify_lite_Thumbnail[0] : '';

		// Construct sharing URL without using any script
		$facebookURL_escaped  = 'https://www.facebook.com/sharer/sharer.php?u=' . $fancify_lite_URL;
		$twitterURL_escaped   = 'https://twitter.com/intent/tweet?text=' . $fancify_lite_Title . '&amp;url=' . $fancify_lite_URL . '&amp;via=Crunchify';
		$linkedInURL_escaped  = 'https://www.linkedin.com/shareArticle?mini=true&url=' . $fancify_lite_URL . '&amp;title=' . $fancify_lite_Title;
		$pinterestURL_escpaed = 'https://pinterest.com/pin/create/button/?url=' . $fancify_lite_URL . '&amp;media=' . $fancify_lite_Thumbnail . '&amp;description=' . $fancify_lite_Title;

		fancify_lite_open_markup_e( 'fancify_lite_post_share', 'div', array( 'class' => 'fancify-single-post-share' ) );

			fancify_lite_open_markup_e( 'fancify_lite_post_share_title', 'span', array( 'class' => 'fancify-single-post-share-title' ) );
				fancify_lite_output_e( 'fancify_lite_post_share_title', esc_html__( 'Share Post: ', 'fancify-lite' ) );
			fancify_lite_close_markup_e('fancify_lite_post_share', 'span');

			fancify_lite_open_markup_e(
				'fancify_lite_post_share_icon_link', 
				'a', 
				array(
					'href'      => esc_url( $facebookURL_escaped ),
					'class'     => 'fancify-default-icon',
				)
			);

			fancify_lite_open_markup_e( 'fancify_lite_post_share_icon', 'i', array( 'class' => 'fancify-single-post-share-icon fancify-font-facebook-1' ) );
			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon', 'i' );

			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon_link', 'a' );

			fancify_lite_open_markup_e(
				'fancify_lite_post_share_icon_link',
				'a',
				array(
					'href' => esc_url( $twitterURL_escaped ),
					'class' => 'fancify-default-icon'
				)
			);

			fancify_lite_open_markup_e( 'fancify_lite_post_share_icon', 'i', array( 'class' => 'fancify-single-post-share-icon fancify-font-twitter' ) );
			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon', 'i' );
			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon_link', 'a' );

			fancify_lite_open_markup_e(
				'fancify_lite_post_share_icon_link',
				'a',
				array(
					'href' => esc_url( $linkedInURL_escaped ),
					'class' => 'fancify-default-icon'
				)
			);

			fancify_lite_open_markup_e( 'fancify_lite_post_share_icon', 'i', array( 'class' => 'fancify-single-post-share-icon fancify-font-linkedin' ) );
			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon', 'i' );

			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon_link', 'a' );

			fancify_lite_open_markup_e(
				'fancify_lite_post_share_icon_link',
				'a',
				array(
					'href' => esc_url( $pinterestURL_escpaed ),
					'class' => 'fancify-default-icon'
				)
			);

			fancify_lite_open_markup_e( 'fancify_lite_post_share_icon', 'i', array( 'class' => 'fancify-single-post-share-icon fancify-font-pinterest-alt' ) );
			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon', 'i' );

			fancify_lite_close_markup_e( 'fancify_lite_post_share_icon_link', 'a' );

		fancify_lite_close_markup_e('fancify_lite_post_share', 'div');
	}

	/**
	 * Echo post navigation.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 *
	 * phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Layout mirrors HTML markup
	 */
	public function post_navigation() {
		// checks if is singular post
		if ( ! is_singular( 'post' ) ) {
			return;
		}

		if ( false === get_theme_mod( 'blog_options_navigation', true ) ) {
			return;
		}

		$previous = is_attachment() ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
		$next     = get_adjacent_post( false, '', false );

		if ( ! $next && ! $previous ) {
			return;
		}

		$post_type = get_post_type();

		$prev_title_escaped = esc_html__( 'Previous POST', 'fancify-lite' );
		$next_title_escaped = esc_html__( 'Next POST', 'fancify-lite' );        

		fancify_lite_open_markup_e(
			'fancify_lite_post_navigation_nav_container',
			'nav',
			array(
				'role'       => 'navigation',
				'aria-label' => esc_attr__('Pagination Navigation', 'fancify-lite'),
			)
		);

		fancify_lite_open_markup_e(
			'fancify_lite_post_navigation',
			'div',
			array(
				'class' => 'fancify-single-post-pagination',
			)
		);

		$previous_post_link = get_adjacent_post( false, '', false );
		$next_post_link     = get_adjacent_post( false, '', true );

		if ( $previous_post_link ) {
			fancify_lite_open_markup_e(
				'fancify_lite_post_navigation_item[_previous]', 
				'div', 
				array(
				   'class' => 'fancify-single-post-pagination-previous'
			   )
			);

			fancify_lite_open_markup_e(
				'fancify_lite_post_navigation_item[_previous]_container', 
				'a', 
				array(
					'class' => 'fancify-pagination-previous-container',
					'href'  => esc_url( get_permalink( $previous_post_link->ID ) ),
				)
			);
			fancify_lite_open_markup_e( 'fancify_lite_post_navigation_item[_previous]_icon_container', 'div', array( 'class' => 'fancify-pagination-icon-container' ) );
				fancify_lite_open_markup_e( 'fancify_lite_post_navigation_item[_previous]_icon', 'i', array( 'class' => 'fancify-font-angle-left' ) );
				fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_previous]_icon', 'i' );
			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_previous]_icon_container', 'div' );


			fancify_lite_open_markup_e( 'fancify_lite_post_navigation_item[_previous]_content', 'div',
			array(
				'class' => 'fancify-pagination-previous-label-container'
			));

			fancify_lite_open_markup_e( 
				'fancify_lite_post_navigation_item[_previous]_label',
				'span', 
				array(
				   'class' => 'fancify-pagination-previous-label'
			   )
			);

			fancify_lite_output_e( 'fancify_lite_post_navigation_item[_previous]_label', $prev_title_escaped );
			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_previous]_label', 'span' );

			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_previous]_content', 'div' );

			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_previous]_container', 'a' );

			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_previous]', 'div' );
		}

		if ( $next_post_link ) {
			fancify_lite_open_markup_e(
				'fancify_lite_post_navigation_item[_next]', 
				'div', 
				array(
					'class' => 'fancify-single-post-pagination-next'
				)
			);

			fancify_lite_open_markup_e(
				'fancify_lite_post_navigation_item[_next]_container',
				'a', 
				array(
					'class' => 'fancify-pagination-next-container',
					'href'  => esc_url( get_permalink( $next_post_link->ID ) ),
				)
			);
			
			fancify_lite_open_markup_e( 'fancify_lite_post_navigation_item[_next]_icon_container', 'div', array( 'class' => 'fancify-pagination-icon-container' ) );
				fancify_lite_open_markup_e( 'fancify_lite_post_navigation_item[_next]_icon', 'i', array( 'class' => 'fancify-font-angle-right' ) );
				fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_next]_icon', 'i' );
			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_next]_icon_container', 'div' );

			fancify_lite_open_markup_e('fancify_lite_post_navigation_item[_next]_content', 'div',
			array(
				'class' => 'fancify-pagination-next-label-container'
			));

			fancify_lite_open_markup_e(
				'fancify_lite_post_navigation_item[_next]_label',
				'span',
				array(
					'class' => 'fancify-pagination-next-label'
				)
			);

			fancify_lite_output_e( 'fancify_lite_post_navigation_item[_next]_label', $next_title_escaped );
			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_next]_label', 'span' );
			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_next]_content', 'div' );

			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_next]_container', 'a' );

			fancify_lite_close_markup_e( 'fancify_lite_post_navigation_item[_next]', 'div' );
		}

		fancify_lite_close_markup_e( 'fancify_lite_post_navigation', 'div' );

		fancify_lite_close_markup_e( 'fancify_lite_post_navigation_nav_container', 'nav' );
	}

	/**
	 * Echo post About Author.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_author() {
		if ( ! is_singular('post') ) {
			return;
		}

		if ( false === get_theme_mod( 'blog_options_author', true ) ) {
			return;
		}

		?>
		<div class="fancify-singlepost-author">
			<h3 class="fancify-singlepost-author-title fancify-post-line-before-title"><?php echo esc_html( 'About Author', 'fancify-lite' ); ?></h3>
			<div class="fancify-singlepost-author-container">
				<div class="fancify-singlepost-author-image">
					<img src="<?php echo esc_url( get_avatar_url(get_the_author_meta('ID'), array('size'=>'300')) ); ?>" alt="<?php esc_attr( get_the_author_meta( 'display_name' ) ); ?>">
				</div>
				<div class="fancify-singlepost-author-detail">
					<div>
						<div class="fancify-singlepost-author-name">
							<div>
								<h4>
									<?php echo esc_html( get_the_author_meta( 'display_name' ) ); ?>
								</h4>
							</div>
						</div>
					</div>
				</div>
				<div>
					<div class="fancify-singlepost-author-description">
						<?php echo esc_html( get_the_author_meta( 'description' ) ); ?>
					</div>
				</div>
			</div>
		</div>
		<?php
	}

	/**
	 * Echo post You may also Like.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function post_suggestion() {
		if ( ! is_singular( 'post' ) ) {
			return;
		}

		if ( false === get_theme_mod( 'blog_options_suggestion', true ) ) {
			return;
		}

		$post = $this->post;

		$tags = wp_get_post_terms( $post->ID, 'post_tag', ['fields' => 'ids'] );
		$categories = wp_get_post_categories( $post->ID, ['fields' => 'ids'] );

		if ( ! empty( $tags ) || ! empty( $categories ) ) {
			$args      =  array(
				'post__not_in'     => array($post->ID),
				'posts_per_page'   => 8,
				'tax_query'        => array(
					'relation' => 'OR',
					array(
						'taxonomy' => 'post_tag',
						'terms'    => $tags,
					),
					array(
						'taxonomy' => 'category',
						'terms'    => $categories,
					),
				),
			);

			$my_query = new WP_Query( $args );

			if ( $my_query->have_posts() ) {
				fancify_lite_open_markup_e(
					'fancify_lite_post_suggestion',
					'div', 
					array(
						'class' => 'fancify-post-suggestion'
					)
				);

				fancify_lite_open_markup_e(
					'fancify_lite_post_suggestion_header',
					'h3',
					array(
						'class' => 'fancify-post-suggestion-header fancify-post-line-before-title'
					)
				);

				fancify_lite_output_e( 
					'fancify_lite_post_suggestion_header',
					esc_html__( 'Recommended Posts', 'fancify-lite' )
				);

				fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_header', 'h3' );

				fancify_lite_open_markup_e( 
					'fancify_lite_post_suggestion_container',
					'div', 
					array(
						'class' => 'fancify-post-suggestion-container'
					)
				);

				fancify_lite_open_markup_e(
					'fancify_lite_post_suggestion_swiper',
					'div', 
					array(
						'class' => 'swiper-wrapper'
					)
				);

				while ( $my_query->have_posts() ) {
					$my_query->the_post();

				   fancify_lite_open_markup_e('fancify_lite_post_suggestion_swiper_slide', 'a',
						array(
							'class' => 'swiper-slide',
							'href'  =>  esc_url( get_the_permalink( $my_query->ID ) ),
						));
					if ( has_post_thumbnail( $my_query->ID ) ) {
						$image = Fancify_Lite_Image::edit_attachment_by_postid( $my_query->ID, array('360','326') );

						fancify_lite_selfclose_markup_e(
							'fancify_lite_post_suggestion_swiper_slide_image',
							'img',
							array(
								'src'      => esc_url( $image->src ),
								'alt'      => esc_attr( $image->alt ),
								'itemprop' => 'image',
							)
						);
					} 
					fancify_lite_open_markup_e( 
						'fancify_lite_post_suggestion_swiper_content',
						'div',
						array(
							'class' => 'fancify-post-suggestion-content'
						)
					);

					fancify_lite_open_markup_e(
						'fancify_lite_post_suggestion_swiper_content_date',
						'div', 
						array(
							'class' => 'fancify-post-suggestion-date'
						)
					);

					fancify_lite_output_e( 'fancify_lite_post_suggestion_header', esc_html( the_time( 'F j, Y' ) ) );
					fancify_lite_close_markup_e('fancify_lite_post_suggestion_swiper_content_date', 'div');

					fancify_lite_open_markup_e( 
						'fancify_lite_post_suggestion_swiper_content_title',
						'div',
						array(
							'class' => 'fancify-post-suggestion-title')
					);

					fancify_lite_output_e( 'fancify_lite_post_suggestion_header', esc_html( the_title() ) );
					fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_swiper_content_title', 'div' );

					fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_swiper_content', 'div' );
					fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_swiper_slide', 'a' );

				}

				wp_reset_query();

				fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_swiper', 'div' );

				fancify_lite_open_markup_e(
					'fancify_lite_post_suggestion_swiper_pagination',
					'div',
					array(
						'class' => 'fancify-post-suggestion-swiper-pagination'
					)
				);

				fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_swiper_pagination', 'div' );

				fancify_lite_close_markup_e( 'fancify_lite_post_suggestion_container', 'div' );
				fancify_lite_close_markup_e( 'fancify_lite_post_suggestion', 'div' );
			}
		}
	}

	/**
	 * Echo posts pagination.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function posts_pagination() {
		$post = $this->post;

		if ( is_singular() || isset( $post->post_type ) && 'property_builder' == $post->post_type || 'agency_builder' == $post->post_type || 'agent_builder' == $post->post_type || 'footer_builder' == $post->post_type ) {
			return;
		}

		global $wp_query;

		if ( get_theme_mod( 'blog_page_pagination', 'pagination' ) === 'load_more' && $this->call_type === null  ) {
			$offset = get_theme_mod( 'blog_page_loadmore_count', 3 );
			fancify_lite_open_markup_e(
				'fancify_lite_blog_loadmore',
				'div',
				array(
					'id'            => 'fancify_lite_blog_loadmore',
					'class'         => 'fancify-blog-loadmore',
					'data-ppp'      => esc_attr( $wp_query->found_posts ),
					'data-offset'   => esc_attr( $offset ),
					'data-loaded'   => esc_attr( $offset )
				)
			);
				fancify_lite_open_markup_e( 'fancify_lite_blog_loadmore_text', 'span' );

				fancify_lite_output_e( 'fancify_lite_blog_loadmore_text', esc_html__( 'Load More', 'fancify-lite' ) );
				fancify_lite_close_markup_e( 'fancify_lite_blog_loadmore_text', 'span' );

			fancify_lite_close_markup_e( 'fancify_lite_blog_loadmore', 'div' );

		} else {
			if ( $wp_query->max_num_pages <= 1 ) {
				return;
			}

			$current = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
			$count   = intval( $wp_query->max_num_pages );

			fancify_lite_open_markup_e(
				'fancify_lite_posts_pagination_nav_container',
				'nav',
				array(
					'role'       => 'navigation',
					'aria-label' => esc_attr__('Posts Pagination Navigation', 'fancify-lite'),
				)
			);

			fancify_lite_open_markup_e(
				'fancify_lite_posts_pagination',
				'ul',
				array(
					'class' => 'fancify-pagination',
				)
			);

			// Previous.
			if ( get_previous_posts_link() ) {
				fancify_lite_open_markup_e('fancify_lite_posts_pagination_item[_previous]', 'li', array( 'class' => 'next'));

				fancify_lite_open_markup_e(
					'fancify_lite_previous_link[_posts_pagination]',
					'a',
					array(
						'href' => esc_url( previous_posts(false) ),
					),
					$current
				);

				fancify_lite_open_markup_e(
					'fancify_lite_previous_icon[_posts_pagination]',
					'span',
					array(
						'class'       => 'fancify-icon-angle-double-left fancify-margin-small-right',
						'aria-hidden' => 'true',
					)
				);

				fancify_lite_close_markup_e('fancify_lite_previous_icon[_posts_pagination]', 'span');

				fancify_lite_output_e('fancify_lite_previous_text[_posts_pagination]', esc_html__('Previous Page', 'fancify-lite'));

				fancify_lite_close_markup_e('fancify_lite_previous_link[_posts_pagination]', 'a');

				fancify_lite_close_markup_e('fancify_lite_posts_pagination_item[_previous]', 'li');
			}

			// Links.
			foreach ( range(1, (int) $wp_query->max_num_pages ) as $link ) {
				// Skip if next is set.
				if (isset($next) && $link !== $next) {
					continue;
				} else {
					$next = $link + 1;
				}

				$is_separator = array(
					1 !== $link, // Not first.
					1 === $current && 3 === $link ? false : true, // Force first 3 items.
					$count > 3, // More.
					$count !== $link, // Not last.
					($current - 1) !== $link, // Not previous.
					$current !== $link, // Not current.
					($current + 1) !== $link, // Not next.
				);

				// Separator.
				if ( !in_array( false, $is_separator, true ) ) {
					fancify_lite_open_markup_e('fancify_lite_posts_pagination_item[_separator]', 'li', array('class' => 'fancify-pagination-dots'));

					fancify_lite_output_e('fancify_lite_posts_pagination_item_separator_text', '...');

					fancify_lite_close_markup_e('fancify_lite_posts_pagination_item[_separator]', 'li');

					// Jump.
					if ($link < $current) {
						$next = $current - 1;
					} elseif ($link > $current) {
						$next = $count;
					}

					continue;
				}

				// Integer.
				if ( $link === $current ) {
					fancify_lite_open_markup_e('fancify_lite_posts_pagination_item[_active]', 'li', array('class' => 'fancify-active'));

					fancify_lite_open_markup_e('fancify_lite_posts_pagination_item[_active]_wrap', 'span');

					fancify_lite_output_e('fancify_lite_posts_pagination_item[_active]_text', esc_html( $link ) );

					fancify_lite_close_markup_e('fancify_lite_posts_pagination_item[_active]_wrap', 'span');

					fancify_lite_close_markup_e('fancify_lite_posts_pagination_item[_active]', 'li');
				} else {
					fancify_lite_open_markup_e('fancify_lite_posts_pagination_item', 'li',array( 'class' => 'fancify-normal-item'));

					fancify_lite_open_markup_e(
						'fancify_lite_posts_pagination_item_link',
						'a',
						array(
							'href' => esc_url( get_pagenum_link( $link ) ),
						),
						$link
					);

					fancify_lite_output_e('fancify_lite_posts_pagination_item_link_text', esc_html( $link ) );

					fancify_lite_close_markup_e('fancify_lite_posts_pagination_item_link', 'a');

					fancify_lite_close_markup_e('fancify_lite_posts_pagination_item', 'li');
				}
			}

			// Next.
			if ( get_next_posts_link() ) {
				fancify_lite_open_markup_e('fancify_lite_posts_pagination_item[_next]', 'li', array( 'class' => 'next'));

				fancify_lite_open_markup_e(
					'fancify_lite_next_link[_posts_pagination]',
					'a',
					array(
						'href' => esc_url( next_posts( $count, false ) ),
					),
					$current
				);

				fancify_lite_output_e('fancify_lite_next_text[_posts_pagination]', esc_html__('Next Page', 'fancify-lite'));

				fancify_lite_open_markup_e(
					'fancify_lite_next_icon[_posts_pagination]',
					'span',
					array(
						'class'       => 'fancify-icon-angle-double-right fancify-margin-small-left',
						'aria-hidden' => 'true',
					)
				);

				fancify_lite_close_markup_e('fancify_lite_next_icon[_posts_pagination]', 'span');

				fancify_lite_close_markup_e('fancify_lite_next_link[_posts_pagination]', 'a');

				fancify_lite_close_markup_e('fancify_lite_posts_pagination_item[_next]', 'li');
			}

			fancify_lite_close_markup_e('fancify_lite_posts_pagination', 'ul');

			fancify_lite_close_markup_e('fancify_lite_posts_pagination_nav_container', 'nav');
		}

		wp_reset_postdata();
	}

	/**
	 * Echo no post content.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function fancify_lite_no_post() {
		if ( is_search() ) {
			fancify_lite_open_markup_e(
				'fancify_lite_post',
				'article',
				array(
					'class' => 'fancify-no-article fancify-404' . ( current_theme_supports( 'fancify-default-styling' ) ? ' fancify-panel-box' : null )
				)
			);
			fancify_lite_open_markup_e( 
				'fancify_lite_404_title',
				'h2', 
				array(
					'class' => 'fancify-404-title'
				)
			);
			fancify_lite_output_e( 'fancify_lite_404_title_text', esc_html__( 'Ooops!', 'fancify-lite' ) .  '<br />' . esc_html__( 'Search Not Found', 'fancify-lite' ) );
			fancify_lite_close_markup_e( 'fancify_lite_404_title', 'h2' );
			fancify_lite_close_markup_e( 'fancify_lite_post', 'article' );

			return;
		}

		fancify_lite_open_markup_e(
			'fancify_lite_post',
			'article',
			array(
				'class' => 'fancify-no-article fancify-404' . ( current_theme_supports( 'fancify-default-styling' ) ? ' fancify-panel-box' : null )
			)
		);

			fancify_lite_open_markup_e( 'fancify_lite_404_div', 'div' );
			
				fancify_lite_open_markup_e( 
					'fancify_lite_404_title',
					'h2', 
					array(
						'class' => 'fancify-404-title'
					)
				);
					fancify_lite_output_e( 'fancify_lite_404_title_text', esc_html__( 'Ooops!', 'fancify-lite' ) .  '<br />' . esc_html__( 'Page Not Found', 'fancify-lite' ) );
				fancify_lite_close_markup_e( 'fancify_lite_404_title', 'h2' );

				fancify_lite_open_markup_e( 'fancify_lite_404_divider', 'span', array( 'class' => 'fancify-404-divider' ));
				fancify_lite_close_markup_e( 'fancify_lite_404_divider', 'span' );
				
				fancify_lite_open_markup_e( 'fancify_lite_404_description', 'p', array( 'class' => 'fancify-404-description' ));
					fancify_lite_output_e( 'fancify_lite_404_description_text', esc_html__( 'Sorry, this page does not exist', 'fancify-lite' ) );
				fancify_lite_close_markup_e( 'fancify_lite_404_description', 'p' );

				fancify_lite_open_markup_e( 'fancify_lite_404_home_button', 'a', array( 'class' => 'fancify-new-main-button','href' => esc_url( get_home_url() ) ));
						fancify_lite_open_markup_e( 'fancify_lite_404_home_button_text', 'span');
							fancify_lite_output_e( 'fancify_lite_404_home_button_text', esc_html__( 'BACK TO HOME', 'fancify-lite' ) );
						fancify_lite_close_markup_e( 'fancify_lite_404_home_button_text', 'span' );
				fancify_lite_close_markup_e( 'fancify_lite_404_home_button', 'a' );

			fancify_lite_close_markup_e( 'fancify_lite_404_div', 'div' );

			fancify_lite_open_markup_e( 'fancify_lite_404_div', 'div' );
				fancify_lite_open_markup_e(
					'fancify_lite_404_image',
					'img', 
					array( 
						'class' => 'fancify-404-image',
						'src'   => esc_url( FANCIFY_ASSETS_URL . 'images/404.png' )
					)
				);
				fancify_lite_close_markup_e( 'fancify_lite_404_image', 'img' );
			fancify_lite_close_markup_e( 'fancify_lite_404_div', 'div' );

		fancify_lite_close_markup_e( 'fancify_lite_post', 'article' );
	}

	/**
	 * Modify password protected form.
	 *
	 * @since 1.0.0
	 *
	 * @return string The form.
	 */
	public function post_password_form() {
		$post = $this->post;

		$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );

		// Notice.
		$output = fancify_lite_open_markup(
			'fancify_lite_password_form_notice',
			'p', 
			array(
				'class' => 'fancify-alert fancify-alert-warning'
			)
		);

		$output .= fancify_lite_output(
			'fancify_lite_password_form_notice_text',
			esc_attr__('This post is protected. To view it, enter the password below!', 'fancify-lite')
		);

		$output .= fancify_lite_close_markup( 'fancify_lite_password_form_notice', 'p' );

		$output .= fancify_lite_open_markup(
			'fancify_lite_password_form',
			'form',
			array(
				'class'  => 'fancify-form fancify-margin-bottom',
				'method' => 'post',
				'action' => esc_url( site_url('wp-login.php?action=postpass', 'login_post') ),
			)
		);

		/**
		 * label for screen readers.
		 *
		 * @since 1.0.0
		 */
		$output .= fancify_lite_open_markup(
			'fancify_lite_password_form_input[_label]', 'label', array(
				'class'    => 'screen-reader-text',
				'for'      => 'post_password',
			)
		);

		$output .= fancify_lite_close_markup( 'fancify_lite_comment_form_field[_label]', 'label' );

		$output .= fancify_lite_selfclose_markup(
			'fancify_lite_password_form_input',
			'input',
			array(
				'class'       => 'fancify-margin-small-top fancify-margin-small-right',
				'type'        => 'password',
				'placeholder' => esc_attr__( 'Password', 'fancify-lite' ),
				'name'        => 'post_password',
			)
		);

		$output .= fancify_lite_selfclose_markup(
			'fancify_lite_password_form_submit',
			'input',
			array(
				'class' => 'fancify-button fancify-margin-small-top',
				'type'  => 'submit',
				'name'  => 'submit',
				'value' => esc_attr__( 'Submit', 'fancify-lite' ),
			)
		);

		$output .= fancify_lite_close_markup( 'fancify_lite_password_form', 'form' );

		return $output;
	}
}

Fancify_Lite_Post_Fragment::get_instance();