Include status selector for calendars
This commit is contained in:
@@ -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' );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'Status', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'name' => 'sp_status',
|
||||
'id' => 'sp_status',
|
||||
'selected' => $status,
|
||||
);
|
||||
sp_dropdown_statuses( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
@@ -98,6 +108,7 @@ class SP_Meta_Box_Calendar_Details {
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,17 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
public function data() {
|
||||
global $pagenow;
|
||||
|
||||
$post_status = $this->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'
|
||||
),
|
||||
|
||||
@@ -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( '<select name="%s" class="postform %s">', $args['name'], $args['class'] );
|
||||
|
||||
$statuses = apply_filters( 'sportspress_statuses', array(
|
||||
'any' => __( 'All', 'sportspress' ),
|
||||
'publish' => __( 'Published', 'sportspress' ),
|
||||
'future' => __( 'Scheduled', 'sportspress' )
|
||||
));
|
||||
|
||||
foreach ( $statuses as $value => $label ):
|
||||
printf( '<option value="%s" %s>%s</option>', $value, selected( $value, $args['selected'], false ), $label );
|
||||
endforeach;
|
||||
print( '</select>' );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_dropdown_taxonomies' ) ) {
|
||||
function sp_dropdown_taxonomies( $args = array() ) {
|
||||
$defaults = array(
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
Reference in New Issue
Block a user