public
Created — forked from /yearlist.patch

  • Download Gist
yearlist.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
diff --recursive -u the-events-calendar-orig/lib/the-events-calendar.class.php the-events-calendar/lib/the-events-calendar.class.php
--- the-events-calendar-orig/lib/the-events-calendar.class.php 2012-12-11 00:35:12.000000000 +0100
+++ the-events-calendar/lib/the-events-calendar.class.php 2012-12-26 16:53:00.000000000 +0100
@@ -1461,6 +1461,7 @@
$newRules[$base . $upcoming] = 'index.php?post_type=' . self::POSTTYPE . '&eventDisplay=upcoming';
$newRules[$base . $past . '/page/(\d+)'] = 'index.php?post_type=' . self::POSTTYPE . '&eventDisplay=past&paged=' . $wp_rewrite->preg_index(1);
$newRules[$base . $past] = 'index.php?post_type=' . self::POSTTYPE . '&eventDisplay=past';
+ $newRules[$base . '(\d{4})$'] = 'index.php?post_type=' . self::POSTTYPE . '&eventDisplay=year' .'&eventDate=' . $wp_rewrite->preg_index(1);
$newRules[$base . '(\d{4}-\d{2})$'] = 'index.php?post_type=' . self::POSTTYPE . '&eventDisplay=month' .'&eventDate=' . $wp_rewrite->preg_index(1);
$newRules[$base . '(\d{4}-\d{2}-\d{2})$'] = 'index.php?post_type=' . self::POSTTYPE . '&eventDisplay=day' .'&eventDate=' . $wp_rewrite->preg_index(1);
$newRules[$base . 'feed/?$'] = 'index.php?eventDisplay=upcoming&post_type=' . self::POSTTYPE . '&feed=rss2';
@@ -2455,6 +2456,27 @@
}
/**
+ * Given a date (YYYY-MM-DD), returns the first of the next year
+ *
+ * @param date
+ * @return date
+ */
+ public function nextYear( $date ) {
+ $dateParts = split( '-', $date );
+ return ++$dateParts[0] . '-01-01';
+ }
+ /**
+ * Given a date (YYYY-MM-DD), return the last day of the previous year
+ *
+ * @param date
+ * @return date
+ */
+ public function previousYear( $date ) {
+ $dateParts = split( '-', $date );
+ return --$dateParts[0] . '-12-31';
+ }
+
+ /**
* Callback for adding the Meta box to the admin page
* @return void
*/
@@ -2871,4 +2893,4 @@
} // end TribeEvents class
-} // end if !class_exists TribeEvents
\ Kein Zeilenumbruch am Dateiende.
+} // end if !class_exists TribeEvents
diff --recursive -u the-events-calendar-orig/lib/tribe-event-query.class.php the-events-calendar/lib/tribe-event-query.class.php
--- the-events-calendar-orig/lib/tribe-event-query.class.php 2012-12-11 00:35:12.000000000 +0100
+++ the-events-calendar/lib/tribe-event-query.class.php 2012-12-26 16:51:43.000000000 +0100
@@ -84,6 +84,9 @@
break;
case "month":
$query = self::setMonthDisplayTypeArgs($query);
+ break;
+ case "year":
+ $query = self::setYearDisplayTypeArgs($query);
}
} else if ( is_single() ) {
$args = &$query->query_vars;
@@ -186,6 +189,27 @@
return $query;
}
+
+ // year functions
+ public static function setYearDisplayTypeArgs($query) {
+ global $wp_query;
+ $tribe_ecp = TribeEvents::instance();
+ $args = &$query->query_vars;
+
+ $args['posts_per_page'] = -1; // show ALL month posts
+ $args['start_date'] = date_i18n( TribeDateUtils::DBDATEFORMAT );
+ $args['start_date'] = substr_replace( $args['start_date'], '01-01', -5 );
+
+ if ( isset ( $wp_query->query_vars['eventDate'] ) )
+ $args['start_date'] = $wp_query->query_vars['eventDate'] . "-01-01";
+
+ $args['eventDate'] = $args['start_date'];
+ $args['end_date'] = date( 'Y-m-d', strtotime( $tribe_ecp->nextYear($args['start_date']) ) -(24*3600) );
+ $args['orderby'] = 'event_date';
+ $args['order'] = "DESC";
+
+ return $query;
+ }
public static function addEventConditions($where, $cur_query) {
global $wpdb;
diff --recursive -u the-events-calendar-orig/lib/tribe-templates.class.php the-events-calendar/lib/tribe-templates.class.php
--- the-events-calendar-orig/lib/tribe-templates.class.php 2012-12-11 00:35:12.000000000 +0100
+++ the-events-calendar/lib/tribe-templates.class.php 2012-12-26 16:06:26.000000000 +0100
@@ -106,7 +106,7 @@
$template = TribeEventsTemplates::getTemplateHierarchy('single');
}
// list view
- elseif ( tribe_is_upcoming() || tribe_is_past() || tribe_is_day() || (is_single() && tribe_is_showing_all()) ) {
+ elseif ( tribe_is_upcoming() || tribe_is_past() || tribe_is_day() || tribe_is_year() || (is_single() && tribe_is_showing_all()) ) {
$template = TribeEventsTemplates::getTemplateHierarchy('list');
}
// grid view
diff --recursive -u the-events-calendar-orig/public/template-tags/loop.php the-events-calendar/public/template-tags/loop.php
--- the-events-calendar-orig/public/template-tags/loop.php 2012-12-11 00:35:12.000000000 +0100
+++ the-events-calendar/public/template-tags/loop.php 2012-12-26 16:04:52.000000000 +0100
@@ -50,6 +50,18 @@
return ($tribe_ecp->displaying == 'day') ? true : false;
}
+ /**
+ * Single Year Test
+ *
+ * Returns true if the query is set for single year, false otherwise
+ *
+ * @return bool
+ * @since 2.0
+ */
+ function tribe_is_year() {
+ $tribe_ecp = TribeEvents::instance();
+ return ($tribe_ecp->displaying == 'year') ? true : false;
+ }
/**
* Past Loop View Test
@@ -175,4 +187,4 @@
}
}
-?>
\ Kein Zeilenumbruch am Dateiende.
+?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.