Skip to content

Commit

Permalink
Merge pull request #12 from cmoa/feature/time-display-override
Browse files Browse the repository at this point in the history
Adds custom time display.
  • Loading branch information
pburke authored Jul 17, 2020
2 parents bdd1597 + e4db75e commit 7956a60
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 40 deletions.
60 changes: 35 additions & 25 deletions cmoa-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,55 +302,65 @@ public function formatted_instances() {
}

/*
* display_dates
* custom_date
*
* This function will conditionally render an html template based on event conditions
* This function will return a custom date format field
*
* @type function
* @date 11/09/16
* @since 1.1.0
* @date 07/17/20
* @since 4.2.2
*
* @return html template string
* @return string
*/

public function custom_date() {
return function_exists('get_field') ? get_field('date_display', $this->details->get('post_id')) : false;
}

/*
* custom_formatting
* custom_date
*
* This function will return a custom format field
* This function will return a custom date format field
*
* @type function
* @date 11/12/19
* @since 4.2.0
* @date 07/17/20
* @since 4.2.2
*
* @return string
*/

public function custom_formatting() {
return function_exists('get_field') ? get_field('date_display', $this->details->get('post_id')) : false;
public function custom_time() {
return function_exists('get_field') ? get_field('time_display', $this->details->get('post_id')) : false;
}

/*
* display_dates
*
* This function will conditionally render an html template based on event conditions
*
* @type function
* @date 11/09/16
* @since 1.1.0
*
* @return html template string
*/

public function display_dates() {
if($this->custom_formatting()) {
if($this->custom_date()):
$template = 'custom';
}
elseif($this->has_end_date() && $this->recurrence() === 'CUSTOM') {
elseif($this->has_end_date() && $this->recurrence() === 'CUSTOM'):
$template = 'date_range';
}
elseif($this->recurrence() !== false && $this->recurrence() !== 'CUSTOM') {
elseif($this->recurrence() !== false && $this->recurrence() !== 'CUSTOM'):
$template = 'recurring';
}
elseif($this->details->get('recurrence_rules')) {
elseif($this->details->get('recurrence_rules')):
$template = 'multi';
}
elseif ($this->all_day() || $this->has_no_end_time()) {
elseif ($this->all_day() || $this->has_no_end_time()):
$template = 'start_date';
}
elseif ($this->details->get('start')->format('Ymd') != $this->details->get('end')->format('Ymd')) {
elseif ($this->details->get('start')->format('Ymd') != $this->details->get('end')->format('Ymd')):
$template = 'mixed_range';
}
else {
else:
$template = 'single';
}
endif;

return $this->mustache->render("$template.html", $this);
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cmoa/wp-museum-calendar",
"description": "Bridge to WordPress calendar data",
"version": "4.2.1",
"version": "4.2.2",
"keywords": ["wordpress", "plugin", "carneyplusco", "all-in-one-event-calendar"],
"homepage": "https://carney.co",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Bridge to WordPress calendar data
* Author: Carney+Co.
* Author URI: https://carney.co
* Version: 4.2.1
* Version: 4.2.2
*/

/**
Expand Down
9 changes: 7 additions & 2 deletions templates/custom.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<time itemprop="startDate" content="{{start_date_iso}}">
<strong>{{{custom_formatting}}}</strong>
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
<strong>{{{custom_date}}}</strong>
{{^ custom_time}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{/ custom_time}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
</time>
7 changes: 6 additions & 1 deletion templates/date_range.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<time itemprop="startDate" content="{{start_date_iso}}">
<strong>{{start_date}}</strong>{{^in_same_year}}, {{start_year}}{{/in_same_year}}&ndash;<strong>{{end_date}}</strong>, {{end_year}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{^ custom_time}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{/ custom_time}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
</time>
3 changes: 3 additions & 0 deletions templates/mixed_range.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<time itemprop="startDate" content="{{start_date_iso}}">
<strong>{{start_date}}</strong>, {{start_year}}, {{start_time}}&ndash;<strong>{{end_date}}</strong>, {{end_year}}, {{end_time}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
</time>
11 changes: 8 additions & 3 deletions templates/multi.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
{{#formatted_instances}}
<span class="event__day">{{day}}</span>,
<span class="event__year">{{year}}</span>
{{^all_day}}
<span class="times">{{start_time}}{{^has_no_end_time}}&ndash;{{end_time}}{{/has_no_end_time}}</span>
{{/all_day}}
{{^ custom_time}}
{{^ all_day}}
<span class="times">{{start_time}}{{^has_no_end_time}}&ndash;{{end_time}}{{/has_no_end_time}}</span>
{{/ all_day}}
{{/ custom_time}}
<br />
{{/formatted_instances}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
</p>
</time>
11 changes: 8 additions & 3 deletions templates/recurring.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<time itemprop="startDate" content="{{start_date_iso}}">
<strong>{{recurrence}}</strong>, <strong>{{start_date}}</strong>{{^in_same_year}}, {{start_year}}{{/in_same_year}}&ndash;<strong>{{end_date}}</strong>, {{end_year}}
{{^ all_day}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{/ all_day}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
{{^ custom_time}}
{{^ all_day}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{/ all_day}}
{{/ custom_time}}
</time>
7 changes: 6 additions & 1 deletion templates/single.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<time itemprop="startDate" content="{{start_date_iso}}">
<strong>{{start_date}}</strong>, {{start_year}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{^ custom_time}}
<span class="times">{{start_time}}&ndash;{{end_time}}</span>
{{/ custom_time}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
</time>
11 changes: 8 additions & 3 deletions templates/start_date.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<time itemprop="startDate" content="{{start_date_iso}}">
<strong>{{start_date}}</strong>, {{start_year}}
{{^all_day}}
<span class="times">{{start_time}}{{^has_no_end_time}}&ndash;{{end_time}}{{/has_no_end_time}}</span>
{{/all_day}}
{{# custom_time}}
<span class="times">{{{custom_time}}}</span>
{{/ custom_time}}
{{^ custom_time}}
{{^ all_day}}
<span class="times">{{start_time}}{{^has_no_end_time}}&ndash;{{end_time}}{{/has_no_end_time}}</span>
{{/ all_day}}
{{/ custom_time}}
</time>

0 comments on commit 7956a60

Please sign in to comment.