diff --git a/includes/class-sp-calendar.php b/includes/class-sp-calendar.php
index 97d6d35f..143539b1 100644
--- a/includes/class-sp-calendar.php
+++ b/includes/class-sp-calendar.php
@@ -12,6 +12,30 @@
*/
class SP_Calendar extends SP_Custom_Post {
+ /** @var array The events status. */
+ public $status;
+
+ /**
+ * __construct function.
+ *
+ * @access public
+ * @param mixed $post
+ */
+ public function __construct( $post ) {
+ if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ):
+ $this->ID = absint( $post->ID );
+ $this->post = $post;
+ else:
+ $this->ID = absint( $post );
+ $this->post = get_post( $this->ID );
+ endif;
+
+ $this->status = $this->__get( 'status' );
+
+ if ( ! $this->status )
+ $this->status = 'any';
+ }
+
/**
* Returns formatted data
*
@@ -21,17 +45,13 @@ 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' => $post_status,
+ 'post_status' => $this->status,
'tax_query' => array(
'relation' => 'AND'
),
diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php
index d5dd41c5..bd58ffb8 100644
--- a/includes/sp-core-functions.php
+++ b/includes/sp-core-functions.php
@@ -378,6 +378,7 @@ if ( !function_exists( 'sp_get_post_order' ) ) {
if ( !function_exists( 'sp_dropdown_statuses' ) ) {
function sp_dropdown_statuses( $args = array() ) {
$defaults = array(
+ 'show_option_default' => false,
'name' => 'sp_status',
'id' => null,
'selected' => null,
@@ -387,6 +388,10 @@ if ( !function_exists( 'sp_dropdown_statuses' ) ) {
printf( '
+
+ __( 'Default', 'sportspress' ),
+ 'name' => $this->get_field_name('status'),
+ 'id' => $this->get_field_id('status'),
+ 'selected' => $status,
+ 'class' => 'sp-event-status-select widefat',
+ );
+ sp_dropdown_statuses( $args );
+ ?>
+
+
-
'default',
'number' => -1,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false,
@@ -28,6 +29,8 @@ extract( $defaults, EXTR_SKIP );
status = $status;
$data = $calendar->data();
$usecolumns = $calendar->columns;