コード例 #1
0
 /** @inheritdoc */
 public function shortcode(array $attributes)
 {
     $setId = $attributes['set_id'];
     if (!is_numeric($setId)) {
         return;
     }
     $set = OpeningHours::getSet($setId);
     if (!$set instanceof Set) {
         return;
     }
     $attributes['set'] = $set;
     $attributes['irregular_openings'] = $set->getIrregularOpenings();
     echo $this->renderShortcodeTemplate($attributes);
 }
コード例 #2
0
 /** @inheritdoc */
 public function shortcode(array $attributes)
 {
     if (!isset($attributes['set_id']) or !is_numeric($attributes['set_id']) or $attributes['set_id'] == 0) {
         trigger_error("Set id not properly set in Opening Hours Overview shortcode");
         return;
     }
     $setId = (int) $attributes['set_id'];
     $set = OpeningHours::getSet($setId);
     if (!$set instanceof Set) {
         trigger_error(sprintf("Set with id %d does not exist", $setId));
         return;
     }
     $attributes['set'] = $set;
     echo $this->renderShortcodeTemplate($attributes);
 }
コード例 #3
0
ファイル: IsOpen.php プロジェクト: misagues/WP-Opening-Hours
 /** @inheritdoc */
 public function shortcode(array $attributes)
 {
     $setId = $attributes['set_id'];
     if ($setId === null or !is_numeric($setId) or $setId <= 0) {
         return;
     }
     $set = OpeningHours::getSet($setId);
     if (!$set instanceof Set) {
         return;
     }
     $isOpen = $set->isOpen();
     $nextPeriod = $set->getNextOpenPeriod();
     if ($attributes['show_next'] and $nextPeriod instanceof Period) {
         $attributes['next_period'] = $nextPeriod;
         $attributes['next_string'] = sprintf($attributes['next_format'], $nextPeriod->getTimeStart()->format($attributes['date_format']), Weekdays::getWeekday($nextPeriod->getWeekday())->getName(), $nextPeriod->getTimeStart()->format($attributes['time_format']), $nextPeriod->getTimeEnd()->format($attributes['time_format']));
     }
     $attributes['is_open'] = $isOpen;
     $attributes['classes'] .= $isOpen ? $attributes['open_class'] : $attributes['closed_class'];
     $attributes['text'] = $isOpen ? $attributes['open_text'] : $attributes['closed_text'];
     $attributes['next_period'] = $set->getNextOpenPeriod();
     echo $this->renderShortcodeTemplate($attributes);
 }