diff --git a/admin/post-types/event.php b/admin/post-types/event.php index 37c657d5..cb225446 100644 --- a/admin/post-types/event.php +++ b/admin/post-types/event.php @@ -28,32 +28,6 @@ function sportspress_event_post_init() { } add_action( 'init', 'sportspress_event_post_init' ); -function sportspress_event_edit_columns() { - $columns = array( - 'cb' => '', - 'sp_format' => '', - 'title' => __( 'Event', 'sportspress' ), - 'date' => __( 'Date', 'sportspress' ), - 'sp_time' => __( 'Time', 'sportspress' ), - 'sp_team' => __( 'Teams', 'sportspress' ), - 'sp_league' => __( 'League', 'sportspress' ), - 'sp_season' => __( 'Season', 'sportspress' ), - 'sp_venue' => __( 'Venue', 'sportspress' ), - 'sp_views' => __( 'Views', 'sportspress' ), - ); - return $columns; -} -add_filter( 'manage_edit-sp_event_columns', 'sportspress_event_edit_columns' ); - -function sportspress_event_display_scheduled( $posts ) { - global $wp_query, $wpdb; - if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] )) { - $posts = $wpdb->get_results( $wp_query->request ); - } - return $posts; -} -add_filter( 'the_posts', 'sportspress_event_display_scheduled' ); - function sportspress_event_meta_init( $post ) { $teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $players = (array)get_post_meta( $post->ID, 'sp_player', false ); diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php new file mode 100644 index 00000000..85d3e3a2 --- /dev/null +++ b/includes/admin/class-sp-admin-post-types.php @@ -0,0 +1,98 @@ + '', // Unused. Messages start at index 1. + 1 => sprintf( __( 'Product updated. View Product', 'sportspress' ), esc_url( get_permalink($post_ID) ) ), + 2 => __( 'Custom field updated.', 'sportspress' ), + 3 => __( 'Custom field deleted.', 'sportspress' ), + 4 => __( 'Product updated.', 'sportspress' ), + 5 => isset($_GET['revision']) ? sprintf( __( 'Product restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => sprintf( __( 'Product published. View Product', 'sportspress' ), esc_url( get_permalink($post_ID) ) ), + 7 => __( 'Product saved.', 'sportspress' ), + 8 => sprintf( __( 'Product submitted. Preview Product', 'sportspress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + 9 => sprintf( __( 'Product scheduled for: %1$s. Preview Product', 'sportspress' ), + date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), + 10 => sprintf( __( 'Product draft updated. Preview Product', 'sportspress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + ); + + $messages['shop_order'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Order updated.', 'sportspress' ), + 2 => __( 'Custom field updated.', 'sportspress' ), + 3 => __( 'Custom field deleted.', 'sportspress' ), + 4 => __( 'Order updated.', 'sportspress' ), + 5 => isset($_GET['revision']) ? sprintf( __( 'Order restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Order updated.', 'sportspress' ), + 7 => __( 'Order saved.', 'sportspress' ), + 8 => __( 'Order submitted.', 'sportspress' ), + 9 => sprintf( __( 'Order scheduled for: %1$s.', 'sportspress' ), + date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ) ), + 10 => __( 'Order draft updated.', 'sportspress' ) + ); + + $messages['shop_coupon'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Coupon updated.', 'sportspress' ), + 2 => __( 'Custom field updated.', 'sportspress' ), + 3 => __( 'Custom field deleted.', 'sportspress' ), + 4 => __( 'Coupon updated.', 'sportspress' ), + 5 => isset($_GET['revision']) ? sprintf( __( 'Coupon restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Coupon updated.', 'sportspress' ), + 7 => __( 'Coupon saved.', 'sportspress' ), + 8 => __( 'Coupon submitted.', 'sportspress' ), + 9 => sprintf( __( 'Coupon scheduled for: %1$s.', 'sportspress' ), + date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ) ), + 10 => __( 'Coupon draft updated.', 'sportspress' ) + ); + + return $messages; + } +} + +endif; + +return new SP_Admin_Post_Types(); \ No newline at end of file diff --git a/includes/admin/class-sp-admin.php b/includes/admin/class-sp-admin.php index edd45fd4..7ccea99f 100644 --- a/includes/admin/class-sp-admin.php +++ b/includes/admin/class-sp-admin.php @@ -34,7 +34,7 @@ class SP_Admin { // include_once( 'sp-meta-box-functions.php' ); // Classes -// include_once( 'class-sp-admin-post-types.php' ); + include_once( 'class-sp-admin-post-types.php' ); // include_once( 'class-sp-admin-taxonomies.php' ); // Classes we only need if the ajax is not-ajax diff --git a/includes/admin/post-types/class-sp-admin-cpt-event.php b/includes/admin/post-types/class-sp-admin-cpt-event.php new file mode 100644 index 00000000..593ba15d --- /dev/null +++ b/includes/admin/post-types/class-sp-admin-cpt-event.php @@ -0,0 +1,254 @@ +type = 'sp_event'; + + // Post title fields + add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 ); + + // Before data updates + add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 ); + + // Admin Columns + add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) ); + add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 ); + add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'custom_columns_sort' ) ); + + // Filtering + add_action( 'restrict_manage_posts', array( $this, 'filters' ) ); + add_filter( 'parse_query', array( $this, 'filters_query' ) ); + + + // Call SP_Admin_CPT constructor + parent::__construct(); + } + + /** + * Check if we're editing or adding an event + * @return boolean + */ + private function is_editing() { + if ( ! empty( $_GET['post_type'] ) && 'sp_event' == $_GET['post_type'] ) { + return true; + } + if ( ! empty( $_GET['post'] ) && 'sp_event' == get_post_type( $_GET['post'] ) ) { + return true; + } + if ( ! empty( $_REQUEST['post_id'] ) && 'sp_event' == get_post_type( $_REQUEST['post_id'] ) ) { + return true; + } + return false; + } + + /** + * Change title boxes in admin. + * @param string $text + * @param object $post + * @return string + */ + public function enter_title_here( $text, $post ) { + if ( $post->post_type == 'sp_event' ) + return __( '(Auto)', 'sportspress' ); + + return $text; + } + + /** + * Auto-generate an event title based on the team playing if left blank. + * + * @param array $data + * @return array + */ + public function wp_insert_post_data( $data, $postarr ) { + global $sportspress_options; + + if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ): + + $teams = sportspress_array_value( $postarr, 'sp_team', array() ); + + $team_names = array(); + foreach( $teams as $team ): + $team_names[] = get_the_title( $team ); + endforeach; + + $data['post_title'] = implode( ' ' . sportspress_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ', $team_names ); + + endif; + + return $data; + } + + /** + * Change the columns shown in admin. + */ + public function edit_columns( $existing_columns ) { + $columns = array( + 'cb' => '', + 'sp_format' => '', + 'title' => __( 'Event', 'sportspress' ), + 'date' => __( 'Date', 'sportspress' ), + 'sp_time' => __( 'Time', 'sportspress' ), + 'sp_team' => __( 'Teams', 'sportspress' ), + 'sp_league' => __( 'League', 'sportspress' ), + 'sp_season' => __( 'Season', 'sportspress' ), + 'sp_venue' => __( 'Venue', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), + ); + return $columns; + } + + /** + * Define our custom columns shown in admin. + * @param string $column + */ + public function custom_columns( $column, $post_id ) { + switch ( $column ): + case 'sp_format': + $format = get_post_meta( $post_id, 'sp_format', true ); + switch ( $format ): + case 'league': + echo ''; + break; + case 'friendly': + echo ''; + break; + endswitch; + break; + case 'sp_time': + echo get_post_time( 'H:i', false, $post_id ); + break; + case 'sp_team': + $teams = (array)get_post_meta( $post_id, 'sp_team', false ); + $teams = array_filter( $teams ); + if ( empty( $teams ) ): + echo '—'; + else: + $current_team = get_post_meta( $post_id, 'sp_current_team', true ); + foreach( $teams as $team_id ): + if ( ! $team_id ) continue; + $team = get_post( $team_id ); + if ( $team ): + echo $team->post_title; + if ( $team_id == $current_team ): + echo ''; + endif; + echo '
'; + endif; + endforeach; + endif; + break; + case 'sp_league': + echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—'; + break; + case 'sp_season': + echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; + break; + case 'sp_venue': + echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—'; + break; + case 'sp_views': + echo sportspress_get_post_views( $post_id ); + break; + endswitch; + } + + /** + * Make columns sortable + * + * https://gist.github.com/906872 + * + * @access public + * @param mixed $columns + * @return array + */ + public function custom_columns_sort( $columns ) { + $custom = array( + 'sp_views' => 'sp_views', + ); + return wp_parse_args( $custom, $columns ); + } + + /** + * Show a category filter box + */ + public function filters() { + global $typenow, $wp_query; + + if ( $typenow != 'sp_event' ) + return; + + sportspress_highlight_admin_menu(); + + $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null; + $args = array( + 'post_type' => 'sp_team', + 'name' => 'team', + 'show_option_none' => __( 'Show all teams', 'sportspress' ), + 'selected' => $selected, + 'values' => 'ID', + ); + wp_dropdown_pages( $args ); + + $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; + $args = array( + 'show_option_all' => __( 'Show all leagues', 'sportspress' ), + 'taxonomy' => 'sp_league', + 'name' => 'sp_league', + 'selected' => $selected + ); + sportspress_dropdown_taxonomies( $args ); + + $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; + $args = array( + 'show_option_all' => __( 'Show all seasons', 'sportspress' ), + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', + 'selected' => $selected + ); + sportspress_dropdown_taxonomies( $args ); + } + + /** + * Filter in admin based on options + * + * @param mixed $query + */ + public function filters_query( $query ) { + global $typenow, $wp_query; + + if ( $typenow == 'sp_event' ) { + + if ( isset( $_GET['team'] ) ) { + $query->query_vars['meta_value'] = $_GET['team']; + $query->query_vars['meta_key'] = 'sp_team'; + } + } + } +} + +endif; + +return new SP_Admin_CPT_Event(); diff --git a/includes/admin/post-types/class-sp-admin-cpt-player.php b/includes/admin/post-types/class-sp-admin-cpt-player.php new file mode 100644 index 00000000..8fa6c655 --- /dev/null +++ b/includes/admin/post-types/class-sp-admin-cpt-player.php @@ -0,0 +1,233 @@ +type = 'sp_player'; + + // Post title fields + add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 ); + + // Admin Columns + add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) ); + add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 ); + add_filter( 'manage_edit-sp_player_sortable_columns', array( $this, 'custom_columns_sort' ) ); + + // Filtering + add_action( 'restrict_manage_posts', array( $this, 'filters' ) ); + add_filter( 'parse_query', array( $this, 'filters_query' ) ); + + + // Call SP_Admin_CPT constructor + parent::__construct(); + } + + /** + * Check if we're editing or adding an event + * @return boolean + */ + private function is_editing() { + if ( ! empty( $_GET['post_type'] ) && 'sp_player' == $_GET['post_type'] ) { + return true; + } + if ( ! empty( $_GET['post'] ) && 'sp_player' == get_post_type( $_GET['post'] ) ) { + return true; + } + if ( ! empty( $_REQUEST['post_id'] ) && 'sp_player' == get_post_type( $_REQUEST['post_id'] ) ) { + return true; + } + return false; + } + + /** + * Change title boxes in admin. + * @param string $text + * @param object $post + * @return string + */ + public function enter_title_here( $text, $post ) { + if ( $post->post_type == 'sp_player' ) + return __( 'Name', 'sportspress' ); + + return $text; + } + + /** + * Change the columns shown in admin. + */ + public function edit_columns( $existing_columns ) { + $columns = array( + 'cb' => '', + 'sp_number' => '', + 'title' => __( 'Player', 'sportspress' ), + 'sp_position' => __( 'Positions', 'sportspress' ), + 'sp_team' => __( 'Teams', 'sportspress' ), + 'sp_league' => __( 'Leagues', 'sportspress' ), + 'sp_season' => __( 'Seasons', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), + ); + return $columns; + } + + /** + * Define our custom columns shown in admin. + * @param string $column + */ + public function custom_columns( $column, $post_id ) { + switch ( $column ): + case 'sp_position': + echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—'; + break; + case 'sp_team': + $teams = (array)get_post_meta( $post_id, 'sp_team', false ); + $teams = array_filter( $teams ); + if ( empty( $teams ) ): + echo '—'; + else: + $results = get_post_meta( $post_id, 'sp_results', true ); + global $sportspress_options; + $main_result = sportspress_array_value( $sportspress_options, 'main_result', null ); + foreach( $teams as $team_id ): + if ( ! $team_id ) continue; + $team = get_post( $team_id ); + + if ( $team ): + $team_results = sportspress_array_value( $results, $team_id, null ); + + if ( $main_result ): + $team_result = sportspress_array_value( $team_results, $main_result, null ); + else: + if ( is_array( $team_results ) ): + end( $team_results ); + $team_result = prev( $team_results ); + else: + $team_result = null; + endif; + endif; + + if ( $team_result != null ): + unset( $team_results['outcome'] ); + $team_results = implode( ' | ', $team_results ); + echo '' . $team_result . ' '; + endif; + + echo $team->post_title; + + echo '
'; + endif; + endforeach; + endif; + break; + case 'sp_league': + echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—'; + break; + case 'sp_season': + echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; + break; + case 'sp_venue': + echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—'; + break; + case 'sp_views': + echo sportspress_get_post_views( $post_id ); + break; + endswitch; + } + + /** + * Make columns sortable + * + * https://gist.github.com/906872 + * + * @access public + * @param mixed $columns + * @return array + */ + public function custom_columns_sort( $columns ) { + $custom = array( + 'sp_views' => 'sp_views', + ); + return wp_parse_args( $custom, $columns ); + } + + /** + * Show a category filter box + */ + public function filters() { + global $typenow, $wp_query; + + if ( $typenow != 'sp_player' ) + return; + + sportspress_highlight_admin_menu(); + + $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null; + $args = array( + 'post_type' => 'sp_team', + 'name' => 'team', + 'show_option_none' => __( 'Show all teams', 'sportspress' ), + 'selected' => $selected, + 'values' => 'ID', + ); + wp_dropdown_pages( $args ); + + $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; + $args = array( + 'show_option_all' => __( 'Show all leagues', 'sportspress' ), + 'taxonomy' => 'sp_league', + 'name' => 'sp_league', + 'selected' => $selected + ); + sportspress_dropdown_taxonomies( $args ); + + $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; + $args = array( + 'show_option_all' => __( 'Show all seasons', 'sportspress' ), + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', + 'selected' => $selected + ); + sportspress_dropdown_taxonomies( $args ); + } + + /** + * Filter in admin based on options + * + * @param mixed $query + */ + public function filters_query( $query ) { + global $typenow, $wp_query; + + if ( $typenow == 'sp_player' ) { + + if ( isset( $_GET['team'] ) ) { + $query->query_vars['meta_value'] = $_GET['team']; + $query->query_vars['meta_key'] = 'sp_team'; + } + } + } +} + +endif; + +return new SP_Admin_CPT_Player(); diff --git a/includes/admin/post-types/class-sp-admin-cpt-team.php b/includes/admin/post-types/class-sp-admin-cpt-team.php new file mode 100644 index 00000000..def65f4f --- /dev/null +++ b/includes/admin/post-types/class-sp-admin-cpt-team.php @@ -0,0 +1,157 @@ +type = 'sp_team'; + + // Post title fields + add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 ); + + // Admin Columns + add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) ); + add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 ); + add_filter( 'manage_edit-sp_team_sortable_columns', array( $this, 'custom_columns_sort' ) ); + + // Filtering + add_action( 'restrict_manage_posts', array( $this, 'filters' ) ); + + + // Call SP_Admin_CPT constructor + parent::__construct(); + } + + /** + * Check if we're editing or adding a team + * @return boolean + */ + private function is_editing() { + if ( ! empty( $_GET['post_type'] ) && 'sp_team' == $_GET['post_type'] ) { + return true; + } + if ( ! empty( $_GET['post'] ) && 'sp_team' == get_post_type( $_GET['post'] ) ) { + return true; + } + if ( ! empty( $_REQUEST['post_id'] ) && 'sp_team' == get_post_type( $_REQUEST['post_id'] ) ) { + return true; + } + return false; + } + + /** + * Change title boxes in admin. + * @param string $text + * @param object $post + * @return string + */ + public function enter_title_here( $text, $post ) { + if ( $post->post_type == 'sp_team' ) + return __( 'Name', 'sportspress' ); + + return $text; + } + + /** + * Change the columns shown in admin. + */ + public function edit_columns( $existing_columns ) { + $columns = array( + 'cb' => '', + 'sp_icon' => '', + 'title' => __( 'Team', 'sportspress' ), + 'sp_league' => __( 'Leagues', 'sportspress' ), + 'sp_season' => __( 'Seasons', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), + ); + return $columns; + } + + /** + * Define our custom columns shown in admin. + * @param string $column + */ + public function custom_columns( $column, $post_id ) { + switch ( $column ): + case 'sp_league': + echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—'; + break; + case 'sp_season': + echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; + break; + case 'sp_views': + echo sportspress_get_post_views( $post_id ); + break; + endswitch; + } + + /** + * Make columns sortable + * + * https://gist.github.com/906872 + * + * @access public + * @param mixed $columns + * @return array + */ + public function custom_columns_sort( $columns ) { + $custom = array( + 'sp_views' => 'sp_views', + ); + return wp_parse_args( $custom, $columns ); + } + + /** + * Show a category filter box + */ + public function filters() { + global $typenow, $wp_query; + + if ( $typenow != 'sp_team' ) + return; + + sportspress_highlight_admin_menu(); + + $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; + $args = array( + 'show_option_all' => __( 'Show all leagues', 'sportspress' ), + 'taxonomy' => 'sp_league', + 'name' => 'sp_league', + 'selected' => $selected + ); + sportspress_dropdown_taxonomies( $args ); + + $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; + $args = array( + 'show_option_all' => __( 'Show all seasons', 'sportspress' ), + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', + 'selected' => $selected + ); + sportspress_dropdown_taxonomies( $args ); + } +} + +endif; + +return new SP_Admin_CPT_Team(); diff --git a/includes/admin/post-types/class-sp-admin-cpt.php b/includes/admin/post-types/class-sp-admin-cpt.php new file mode 100644 index 00000000..5a17f34a --- /dev/null +++ b/includes/admin/post-types/class-sp-admin-cpt.php @@ -0,0 +1,73 @@ +type ) { + $obj = get_post_type_object( $this->type ); + + $strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'woocommerce' ), $obj->labels->singular_name ); + $strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'woocommerce' ), $obj->labels->singular_name ); + } + + return $strings; + } + + /** + * Custom column orderby + * + * http://scribu.net/wordpress/custom-sortable-columns.html#comment-4732 + * + * @access public + * @param mixed $vars + * @return array + */ + public function custom_columns_orderby( $vars ) { + if (isset( $vars['orderby'] )) : + if ( 'sp_views' == $vars['orderby'] ) : + $vars = array_merge( $vars, array( + 'meta_key' => 'sp_views', + 'orderby' => 'meta_value_num' + ) ); + endif; + endif; + + return $vars; + } +} + +endif; \ No newline at end of file diff --git a/includes/class-sp-post-types.php b/includes/class-sp-post-types.php index 8faa5f5e..a1db4fd7 100644 --- a/includes/class-sp-post-types.php +++ b/includes/class-sp-post-types.php @@ -22,6 +22,7 @@ class SP_Post_types { public function __construct() { add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 ); add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 ); + add_filter( 'the_posts', array( __CLASS__, 'display_scheduled_events' ) ); } /** @@ -155,9 +156,59 @@ class SP_Post_types { */ public static function register_post_types() { + register_post_type( 'sp_separator', + array( + 'label' => '', + 'public' => false, + 'show_ui' => true, + 'show_in_nav_menus' => false, + 'show_in_admin_bar' => false, + 'can_export' => false, + ) + ); + do_action( 'sportspress_register_post_type' ); + register_post_type( 'sp_event', + apply_filters( 'sportspress_register_post_type_product', + array( + 'label' => __( 'Events', 'sportspress' ), + 'labels' => array( + 'name' => __( 'Schedule', 'sportspress' ), + 'singular_name' => __( 'Event', 'sportspress' ), + 'all_items' => __( 'Events', 'sportspress' ), + 'add_new_item' => __( 'Add New Event', 'sportspress' ), + 'edit_item' => __( 'Edit Event', 'sportspress' ), + 'new_item' => __( 'New', 'sportspress' ), + 'view_item' => __( 'View', 'sportspress' ), + 'search_items' => __( 'Search', 'sportspress' ), + 'not_found' => __( 'No results found.', 'sportspress' ), + 'not_found_in_trash' => __( 'No results found.', 'sportspress' ), + ), + 'public' => true, + 'show_ui' => true, + 'capability_type' => 'sp_event', + 'map_meta_cap' => true, + 'publicly_queryable' => true, + 'exclude_from_search' => false, + 'hierarchical' => false, + 'rewrite' => array( 'slug' => get_option( 'sportspress_events_slug', 'events' ) ), + 'query_var' => true, + 'supports' => array( 'title', 'author', 'thumbnail', 'comments' ), + 'has_archive' => true, + 'show_in_nav_menus' => true, + 'menu_icon' => 'dashicons-calendar', + ) + ) + ); + } + public function display_scheduled_events( $posts ) { + global $wp_query, $wpdb; + if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] )) { + $posts = $wpdb->get_results( $wp_query->request ); + } + return $posts; } } diff --git a/sportspress.php b/sportspress.php index d7571eed..740aff0a 100644 --- a/sportspress.php +++ b/sportspress.php @@ -208,14 +208,14 @@ final class SportsPress { include_once( 'includes/admin/settings/options-permalink.php' ); // Custom post types (deprecating) - include_once( 'admin/post-types/separator.php' ); + //include_once( 'admin/post-types/separator.php' ); include_once( 'admin/post-types/column.php' ); include_once( 'admin/post-types/performance.php' ); //include_once( 'admin/post-types/statistic.php' ); include_once( 'admin/post-types/metric.php' ); include_once( 'admin/post-types/result.php' ); include_once( 'admin/post-types/outcome.php' ); - include_once( 'admin/post-types/event.php' ); + //include_once( 'admin/post-types/event.php' ); include_once( 'admin/post-types/calendar.php' ); include_once( 'admin/post-types/team.php' ); include_once( 'admin/post-types/table.php' ); @@ -235,13 +235,6 @@ final class SportsPress { // Post types include_once( 'includes/class-sp-post-types.php' ); // Registers post types - // Include abstract classes -// include_once( 'includes/abstracts/abstract-sp-product.php' ); // Products -// include_once( 'includes/abstracts/abstract-sp-settings-api.php' ); // Settings API (for gateways, shipping, and integrations) -// include_once( 'includes/abstracts/abstract-sp-shipping-method.php' ); // A Shipping method -// include_once( 'includes/abstracts/abstract-sp-payment-gateway.php' ); // A Payment gateway -// include_once( 'includes/abstracts/abstract-sp-integration.php' ); // An integration with a service - // Classes (used on all pages) include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries include_once( 'includes/class-sp-text.php' ); // Defines editable strings @@ -264,10 +257,10 @@ final class SportsPress { include_once( 'admin/hooks/current-screen.php' ); // Administrative actions (deprecating) - include_once( 'admin/hooks/manage-posts-columns.php' ); + //include_once( 'admin/hooks/manage-posts-columns.php' ); include_once( 'admin/hooks/post-thumbnail-html.php' ); - include_once( 'admin/hooks/restrict-manage-posts.php' ); - include_once( 'admin/hooks/parse-query.php' ); + //include_once( 'admin/hooks/restrict-manage-posts.php' ); + //include_once( 'admin/hooks/parse-query.php' ); include_once( 'admin/hooks/save-post.php' ); // Filters (deprecating)