define_constants(); add_action( 'init', array( $this, 'get_statuses' ) ); add_action( 'post_submitbox_misc_actions', array( $this, 'section' ) ); add_action( 'sportspress_process_sp_event_meta', array( $this, 'save' ), 10, 1 ); add_filter( 'sportspress_event_time', array( $this, 'filter' ), 10, 2 ); add_filter( 'sportspress_event_time_admin', array( $this, 'filter' ), 10, 2 ); add_filter( 'sportspress_main_results_or_time', array( $this, 'filter_array' ), 10, 2 ); add_filter( 'sportspress_event_blocks_team_result_or_time', array( $this, 'filter_array' ), 10, 2 ); } /** * Define constants. */ private function define_constants() { if ( ! defined( 'SP_EVENT_STATUS_VERSION' ) ) { define( 'SP_EVENT_STATUS_VERSION', '2.1' ); } if ( ! defined( 'SP_EVENT_STATUS_URL' ) ) { define( 'SP_EVENT_STATUS_URL', plugin_dir_url( __FILE__ ) ); } if ( ! defined( 'SP_EVENT_STATUS_DIR' ) ) { define( 'SP_EVENT_STATUS_DIR', plugin_dir_path( __FILE__ ) ); } } /** * Define statuses. */ public function get_statuses() { $this->statuses = apply_filters( 'sportspress_event_statuses', array( 'ok' => esc_attr__( 'On time', 'sportspress' ), 'tbd' => esc_attr__( 'TBD', 'sportspress' ), 'postponed' => esc_attr__( 'Postponed', 'sportspress' ), 'cancelled' => esc_attr__( 'Canceled', 'sportspress' ), ) ); } /** * Add status section to submit box. */ public function section() { if ( 'sp_event' !== get_post_type() ) { return; } $status = get_post_meta( get_the_ID(), 'sp_status', true ); if ( ! $status ) { $status = 'ok'; } ?>
statuses[ $status ] ); ?>
statuses as $value => $label ) { ?>

OK Cancel

statuses ) ) { return $time; } return $this->statuses[ $status ]; } /** * Event time array filter. */ public function filter_array( $array, $post_id = 0 ) { if ( ! $post_id ) { $post_id = get_the_ID(); } $status = get_post_meta( $post_id, 'sp_status', true ); if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) { return $array; } return array( $this->statuses[ $status ] ); } } endif; new SportsPress_Event_Status();