Created
November 25, 2013 21:49
-
-
Save anonymous/7649521 to your computer and use it in GitHub Desktop.
Patch to add 'if-last' and 'if-not-last' functionality to the current release of 'Google Calendar Events'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Naur a/admin/add.php b/admin/add.php | |
--- a/admin/add.php 2012-12-11 14:48:34.000000000 -0500 | |
+++ b/admin/add.php 2013-11-25 16:45:50.863521512 -0500 | |
@@ -265,6 +265,8 @@ | |
<li><code>[if-not-ended]…[/if-not-ended]</code><span class="description"> - <?php _e( 'The event has not ended (even if it hasn\'t started)', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-first]…[/if-first]</code><span class="description"> - <?php _e( 'The event is the first of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-not-first]…[/if-not-first]</code><span class="description"> - <?php _e( 'The event is not the first of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
+ <li><code>[if-last]…[/if-last]</code><span class="description"> - <?php _e( 'The event is the last of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
+ <li><code>[if-not-last]…[/if-not-last]</code><span class="description"> - <?php _e( 'The event is not the last of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-multi-day]…[/if-multi-day]</code><span class="description"> - <?php _e( 'The event spans multiple days', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-single-day]…[/if-single-day]</code><span class="description"> - <?php _e( 'The event does not span multiple days', GCE_TEXT_DOMAIN ); ?></span></li> | |
</ul> | |
@@ -373,4 +375,4 @@ | |
<input type="text" name="gce_options[display_link_text]" value="More details" /> | |
<?php | |
} | |
-?> | |
\ No newline at end of file | |
+?> | |
diff -Naur a/admin/edit.php b/admin/edit.php | |
--- a/admin/edit.php 2012-12-11 14:48:34.000000000 -0500 | |
+++ b/admin/edit.php 2013-11-25 16:45:50.863521512 -0500 | |
@@ -266,6 +266,8 @@ | |
<li><code>[if-not-ended]…[/if-not-ended]</code><span class="description"> - <?php _e( 'The event has not ended (even if it hasn\'t started)', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-first]…[/if-first]</code><span class="description"> - <?php _e( 'The event is the first of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-not-first]…[/if-not-first]</code><span class="description"> - <?php _e( 'The event is not the first of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
+ <li><code>[if-last]…[/if-last]</code><span class="description"> - <?php _e( 'The event is the last of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
+ <li><code>[if-not-last]…[/if-not-last]</code><span class="description"> - <?php _e( 'The event is not the last of the day', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-multi-day]…[/if-multi-day]</code><span class="description"> - <?php _e( 'The event spans multiple days', GCE_TEXT_DOMAIN ); ?></span></li> | |
<li><code>[if-single-day]…[/if-single-day]</code><span class="description"> - <?php _e( 'The event does not span multiple days', GCE_TEXT_DOMAIN ); ?></span></li> | |
</ul> | |
@@ -386,4 +388,4 @@ | |
<input type="text" name="gce_options[display_link_text]" value="<?php echo stripslashes(esc_html($options['display_link_text'])); ?>" /> | |
<?php | |
} | |
-?> | |
\ No newline at end of file | |
+?> | |
diff -Naur a/inc/gce-event.php b/inc/gce-event.php | |
--- a/inc/gce-event.php 2012-12-11 14:48:34.000000000 -0500 | |
+++ b/inc/gce-event.php 2013-11-25 16:45:50.861521340 -0500 | |
@@ -14,6 +14,7 @@ | |
private $day_type; | |
private $time_now; | |
private $regex; | |
+ private $last; | |
function __construct( $id, $title, $description, $location, $start_time, $end_time, $link ) { | |
$this->id = $id; | |
@@ -23,6 +24,7 @@ | |
$this->start_time = $start_time; | |
$this->end_time = $end_time; | |
$this->link = $link; | |
+ $this->last = FALSE; | |
//Calculate which day type this event is (SWD = single whole day, SPD = single part day, MWD = multiple whole day, MPD = multiple part day) | |
if ( ( $start_time + 86400 ) <= $end_time ) { | |
@@ -155,6 +157,8 @@ | |
'if-ended', //The event has ended | |
'if-not-ended', //The event has not ended (and even if it hasn't started) | |
'if-first', //The event is the first in the day | |
+ 'if-last', //The event is the last in the day | |
+ 'if-not-last', //The event is not the last in the day | |
'if-not-first', //The event is not the first in the day | |
'if-multi-day', //The event spans multiple days | |
'if-single-day' //The event does not span multiple days | |
@@ -392,6 +396,18 @@ | |
return ''; | |
+ case 'if-last': | |
+ if ($this->last) | |
+ return $m[1] . $this->look_for_shortcodes( $m[5] ) . $m[6]; | |
+ | |
+ return ''; | |
+ | |
+ case 'if-not-last': | |
+ if (!$this->last) | |
+ return $m[1] . $this->look_for_shortcodes( $m[5] ) . $m[6]; | |
+ | |
+ return ''; | |
+ | |
case 'if-multi-day': | |
if ( 'MPD' == $this->day_type || 'MWD' == $this->day_type ) | |
return $m[1] . $this->look_for_shortcodes( $m[5] ) . $m[6]; | |
@@ -523,5 +539,9 @@ | |
return sprintf( $smallest[0], 1 ); | |
} | |
} | |
+ | |
+ public function setLast() { | |
+ $this->last = TRUE; | |
+ } | |
} | |
-?> | |
\ No newline at end of file | |
+?> | |
diff -Naur a/inc/gce-parser.php b/inc/gce-parser.php | |
--- a/inc/gce-parser.php 2012-12-11 14:48:34.000000000 -0500 | |
+++ b/inc/gce-parser.php 2013-11-25 16:45:50.861521340 -0500 | |
@@ -328,6 +328,9 @@ | |
'<div class="gce-list-title">' . esc_html( $this->title ) . ' ' . date_i18n( $event_day[0]->get_feed()->get_date_format(), $key ) . '</div>' . | |
'<ul>'; | |
} | |
+ | |
+ $last = end($event_day); | |
+ $last->setLast(); | |
foreach ( $event_day as $num_in_day => $event ) { | |
//Create the markup for this event | |
@@ -352,4 +355,4 @@ | |
return $markup; | |
} | |
} | |
-?> | |
\ No newline at end of file | |
+?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment