<?php
/**
 * Template part for displaying no entry section
 *
 * @package errigal
 * @since 1.1.0
 *
 * @param array $args {
 *     Associative array of arguments for no entry section.
 *
 *     @type callable $render_callback Render callback. Default null.
 * }
 */

defined( 'ABSPATH' ) || exit;

use Errigal\Constant\{
	Errigal_Html_Attr as Html_Attr,
	Errigal_Html_Option as Html_Option,
};
use Errigal\Constant\Errigal_Template_Part as Template_Part;
use Errigal\Shared\{
	Errigal_Html_Builder as Html_Builder,
	Errigal_Validator as Validator,
};

$args = $args ?? array();
$args = wp_parse_args(
	$args,
	array(
		Template_Part::RENDER_CALLBACK => null,
	)
);

$render_callback = $args[ Template_Part::RENDER_CALLBACK ];

if ( ! Validator::is_closure( $render_callback ) ) {
	return;
}

Html_Builder::create()->create_section(
	array(
		Html_Option::ATTRS => array(
			Html_Attr::CLASS_NAME => 'no-entry',
		),
	)
)->render_element( $render_callback );
