3, 'title' => __('Rooster One Opening Hours', 'ai-eshop-optimizer'), 'description' => __("A store location's opening hours. Auto-resolves on a store page, or set a location slug.", 'ai-eshop-optimizer'), 'category' => 'widgets', 'icon' => 'clock', 'keywords' => array('hours', 'opening', 'schedule', 'store'), 'supports' => array('align' => array('wide')), 'attributes' => array( 'locationSlug' => array('type' => 'string', 'default' => ''), 'heading' => array('type' => 'string', 'default' => ''), 'layout' => array('type' => 'string', 'default' => '', 'enum' => array('', 'scale', 'grouped')), ), 'uses_context' => array('postId'), 'render_callback' => array(__CLASS__, 'render'), )); } public static function shortcode($atts) { $atts = shortcode_atts(array('location' => '', 'heading' => ''), $atts, 'aieo_opening_hours'); return self::render(array('locationSlug' => (string) $atts['location'], 'heading' => (string) $atts['heading'])); } public static function render($attrs, $content = '', $block = null) { if (!class_exists('AIEO_Google_Reviews_Helpers')) { return ''; } $attrs = wp_parse_args(is_array($attrs) ? $attrs : array(), array('locationSlug' => '', 'heading' => '', 'layout' => '')); $loc = AIEO_Google_Reviews_Helpers::resolve_single($attrs['locationSlug'], $block); if (!$loc) { return ''; } if ('scale' === $attrs['layout'] && class_exists('AIEO_Store_Page_Blocks')) { $pid = class_exists('AIEO_Store_Locator_Block') ? AIEO_Store_Locator_Block::store_post_for_location($loc) : 0; return AIEO_Store_Page_Blocks::hours_scale($loc, $pid, $block); } $hours = 'grouped' === $attrs['layout'] && class_exists('AIEO_Store_Hours') ? self::grouped_html($loc) : AIEO_Google_Reviews_Helpers::render_hours_html($loc); if ('' === $hours) { return ''; } AIEO_Google_Reviews_Helpers::enqueue_locations_assets(); $wrap = get_block_wrapper_attributes(array('class' => 'aieo-loc-hours-block')); $out = '
'; if ('' !== (string) $attrs['heading']) { $out .= '

' . esc_html($attrs['heading']) . '

'; } $out .= $hours . '
'; return $out; } private static function grouped_html(array $loc) { $runs = AIEO_Store_Hours::runs(AIEO_Store_Hours::intervals($loc)); if (array() === $runs) { return ''; } $out = ''; } }