From dbb63247fd002c0cee2618d5bb4ac7c0c24e2285 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 27 Apr 2014 18:32:40 +1000 Subject: [PATCH] Include status selector for calendars --- .../class-sp-meta-box-calendar-details.php | 15 +++++++++-- includes/class-sp-calendar.php | 6 ++++- includes/sp-core-functions.php | 26 +++++++++++++++++++ .../class-sp-widget-event-calendar.php | 2 +- .../widgets/class-sp-widget-event-list.php | 2 +- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php index cf253318..77f377d0 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php @@ -19,14 +19,24 @@ class SP_Meta_Box_Calendar_Details { * Output the metabox */ public static function output( $post ) { - global $sportspress_formats; + $status = get_post_meta( $post->ID, 'sp_status', true ); $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); $season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 ); $venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 ); $team_id = get_post_meta( $post->ID, 'sp_team', true ); - $formats = get_post_meta( $post->ID, 'sp_format' ); ?>
+

+

+ 'sp_status', + 'id' => 'sp_status', + 'selected' => $status, + ); + sp_dropdown_statuses( $args ); + ?> +

status; + if ( ! $post_status ) + $post_status = 'any'; + $args = array( 'post_type' => 'sp_event', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'ASC', - 'post_status' => 'any', + 'post_status' => $post_status, 'tax_query' => array( 'relation' => 'AND' ), diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index ed64723f..d5dd41c5 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -375,6 +375,32 @@ if ( !function_exists( 'sp_get_post_order' ) ) { } } +if ( !function_exists( 'sp_dropdown_statuses' ) ) { + function sp_dropdown_statuses( $args = array() ) { + $defaults = array( + 'name' => 'sp_status', + 'id' => null, + 'selected' => null, + 'class' => null, + ); + $args = array_merge( $defaults, $args ); + + printf( '' ); + return true; + } +} + if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { function sp_dropdown_taxonomies( $args = array() ) { $defaults = array( diff --git a/includes/widgets/class-sp-widget-event-calendar.php b/includes/widgets/class-sp-widget-event-calendar.php index ec2861da..05e33c96 100644 --- a/includes/widgets/class-sp-widget-event-calendar.php +++ b/includes/widgets/class-sp-widget-event-calendar.php @@ -3,7 +3,7 @@ class SP_Widget_Event_Calendar extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'widget_calendar widget_sp_event_calendar', 'description' => __( 'A calendar of events.', 'sportspress' ) ); - parent::__construct('sp_event_calendar', __( 'SportsPress Events Calendar', 'sportspress' ), $widget_ops); + parent::__construct('sp_event_calendar', __( 'SportsPress Event Calendar', 'sportspress' ), $widget_ops); } function widget( $args, $instance ) { diff --git a/includes/widgets/class-sp-widget-event-list.php b/includes/widgets/class-sp-widget-event-list.php index a3640efd..615f9faa 100644 --- a/includes/widgets/class-sp-widget-event-list.php +++ b/includes/widgets/class-sp-widget-event-list.php @@ -3,7 +3,7 @@ class SP_Widget_Event_List extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'widget_sp_event_list', 'description' => __( 'A list of events.', 'sportspress' ) ); - parent::__construct('sp_event_list', __( 'SportsPress Events List', 'sportspress' ), $widget_ops); + parent::__construct('sp_event_list', __( 'SportsPress Event List', 'sportspress' ), $widget_ops); } function widget( $args, $instance ) {