<?php
/**
 * Block pattern setup file.
 *
 * @package    Zooey
 * @copyright  WebMan Design, Oliver Juhas
 *
 * @since    1.0.0
 * @version  2.0.6
 */

namespace WebManDesign\Zooey\Content;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

// Add block pattern setup args.
Block_Pattern::add_pattern_args( __FILE__, array(
	'title'    => _x( 'Working hours', 'Block pattern title.', 'zooey' ),
	'keywords' => array(
		esc_html_x( 'business hours', 'keyword', 'zooey' ),
		esc_html_x( 'opening hours', 'keyword', 'zooey' ),
		esc_html_x( 'time', 'keyword', 'zooey' ),
	),
	'viewportWidth' => 500,
) );

// Block pattern content:

$days = array(

	'open' => array(
		'mon',
		'tue',
		'wed',
		'thu',
		'fri',
	),

	'close' => array(
		'sat',
		'sun',
	),
);

ob_start(); ?>

	<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
	<div class="wp-block-group">
		<!-- wp:paragraph {"style":{"typography":{"textTransform":"uppercase"}},"fontSize":"s"} -->
		<p class="has-s-font-size" style="text-transform:uppercase">[DAY]</p>
		<!-- /wp:paragraph -->
		<!-- wp:separator {"className":"is-style-dotted"} -->
		<hr class="wp-block-separator has-alpha-channel-opacity is-style-dotted" />
		<!-- /wp:separator -->
		<!-- wp:paragraph -->
		<p>[TIME]</p>
		<!-- /wp:paragraph -->
	</div>
	<!-- /wp:group -->

<?php $item = ob_get_clean(); ?>

<!-- wp:group {"metadata":{"name":"<?php esc_attr_e( 'Working hours', 'zooey' ); ?>"}} -->
<div class="wp-block-group">

	<!-- wp:group {"style":{"spacing":{"blockGap":{"top":"var:preset|spacing|xs","left":"var:preset|spacing|xs"}}}} -->
	<div class="wp-block-group">
		<?php

		foreach ( $days['open'] as $day ) :

			echo str_replace(
				array( '[DAY]', '[TIME]' ),
				array( Demo::get_text( 'date/' . $day ), '9:00 - 17:00' ),
				$item
			);

		endforeach;

		?>
	</div>
	<!-- /wp:group -->

	<!-- wp:group {"style":{"spacing":{"blockGap":{"top":"var:preset|spacing|xs","left":"var:preset|spacing|xs"}}}} -->
	<div class="wp-block-group">
		<?php

		foreach ( $days['close'] as $day ) :

			echo str_replace(
				array( '[DAY]', '[TIME]' ),
				array( Demo::get_text( 'date/' . $day ), esc_html_x( 'Closed', 'As in time, working hours.', 'zooey' ) ),
				$item
			);

		endforeach;

		?>
	</div>
	<!-- /wp:group -->

</div>
<!-- /wp:group -->
