<?php
/**
 * Template part for displaying page content
 *
 * @package errigal
 * @since 1.1.0
 *
 * @param array $args {
 *     Associative array of arguments for page content.
 *
 *     @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,
	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_div(
	array(
		Html_Option::ATTRS => array(
			Html_Attr::CLASS_NAME => 'page-content',
		),
	)
)->render_element( $render_callback );
