Skip to content

Commit 4788bcf

Browse files
committed
[OpeningHours] Added schema
and fixes
1 parent 17b2ef1 commit 4788bcf

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

widgets/accordion.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ protected function _register_controls() {
196196
'selectors' => [
197197
'{{WRAPPER}} .mighty-accordion .mt-panel .accordion .mt-accordion-title' => 'color: {{VALUE}};',
198198
],
199+
'default' => '#000',
199200
'scheme' => [
200201
'type' => Scheme_Color::get_type(),
201202
'value' => Scheme_Color::COLOR_1,
@@ -208,6 +209,7 @@ protected function _register_controls() {
208209
[
209210
'label' => __( 'Background', 'mighty' ),
210211
'type' => Controls_Manager::COLOR,
212+
'default' => '#fff',
211213
'selectors' => [
212214
'{{WRAPPER}} .mighty-accordion .mt-panel .accordion' => 'background-color: {{VALUE}};',
213215
],
@@ -222,6 +224,7 @@ protected function _register_controls() {
222224
'selectors' => [
223225
'{{WRAPPER}} .mighty-accordion .mt-panel .active .mt-accordion-title' => 'color: {{VALUE}};',
224226
],
227+
'default' => '#000',
225228
'scheme' => [
226229
'type' => Scheme_Color::get_type(),
227230
'value' => Scheme_Color::COLOR_4,
@@ -238,6 +241,7 @@ protected function _register_controls() {
238241
'type' => Scheme_Color::get_type(),
239242
'value' => Scheme_Color::COLOR_1,
240243
],
244+
'default' => '#fff',
241245
'selectors' => [
242246
'{{WRAPPER}} .mighty-accordion .mt-panel .active' => 'background-color: {{VALUE}}',
243247
],

widgets/opening-hours.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,24 +793,51 @@ protected function render() {
793793
return;
794794
}
795795
?>
796-
<div class="ma-openinghours-wrapper">
796+
<div itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/CivicStructure" class="ma-openinghours-wrapper">
797+
798+
<img style="display:none;" itemprop="image" src="http://via.placeholder.com/350x150" alt="test logo" />
797799

798-
<div class="ma-oh-header"><?php echo $settings['header_text']; ?></div>
800+
<div itemprop="name" class="ma-oh-header"><?php echo $settings['header_text']; ?></div>
799801

800802
<div class="ma-oh-rows">
801803
<?php foreach ( $settings['mt_openinghours_data'] as $item ) :
802804
$closingTime = $item['opening_business_time'] === "Closed" || $item['opening_business_time'] === "24 hours" ? false : true;
805+
$schemaDay = "";
806+
switch( $item['business_day'] ) {
807+
case 'All Days': $schemaDay = "Mo-Su";
808+
break;
809+
case 'Monday - Friday': $schemaDay = "Mo-Fr";
810+
break;
811+
case 'Saturday - Sunday': $schemaDay = "Sa-Su";
812+
break;
813+
default: $schemaDay = substr($item['business_day'], 0, 2);
814+
}
803815
?>
804816
<div class="ma-oh-row <?php echo ($settings['striped_effect'] == true) ? 'mt-striped' : ''; ?> elementor-repeater-item-<?php echo $item['_id']; ?>">
805-
<div class="ma-oh-day"><?php echo $item['business_day']; ?></div>
806-
<div class="ma-oh-time">
807-
<?php echo $item['opening_business_time']; echo $closingTime ? " - ".$item['closing_business_time'] : ''; ?>
817+
<div class="ma-oh-day">
818+
<time itemprop="openingHours" datetime="<?php echo $schemaDay; ?>"><?php echo $item['business_day']; ?></time>.
808819
</div>
820+
821+
<div class="ma-oh-time" itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification">
822+
<?php if ( $item['opening_business_time'] === "24 hours" ) { ?>
823+
824+
<time itemprop="opens" content="<?php echo date("H:i", strtotime("12:00 AM")); ?>"><?php echo $item['opening_business_time']; ?></time>
825+
826+
<time itemprop='closes' content='<?php echo date("H:i", strtotime("12:00 PM")); ?>'></time>
827+
828+
<?php } else { ?>
829+
<time itemprop="opens" content="<?php echo date("H:i", strtotime($item['opening_business_time'])); ?>"><?php echo $item['opening_business_time']; ?></time>
830+
831+
<?php echo $closingTime ? " - <time itemprop='closes' content='". date("H:i", strtotime($item['closing_business_time'])) ."'>". $item['closing_business_time'] ."</time>" : '';
832+
} ?>
833+
834+
</div>
835+
809836
</div>
810837
<?php endforeach; ?>
811838
</div>
812839

813-
<div class="ma-oh-footer"><?php echo $settings['footer_text']; ?></div>
840+
<div itemprop="description" class="ma-oh-footer"><?php echo $settings['footer_text']; ?></div>
814841

815842
</div>
816843
<?php

0 commit comments

Comments
 (0)