diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php
index 85d3e3a2..4b5b6d78 100644
--- a/includes/admin/class-sp-admin-post-types.php
+++ b/includes/admin/class-sp-admin-post-types.php
@@ -31,8 +31,12 @@ class SP_Admin_Post_Types {
public function include_post_type_handlers() {
//include( 'post-types/class-sp-admin-meta-boxes.php' );
include( 'post-types/class-sp-admin-cpt-event.php' );
+ include( 'post-types/class-sp-admin-cpt-calendar.php' );
include( 'post-types/class-sp-admin-cpt-team.php' );
+ include( 'post-types/class-sp-admin-cpt-table.php' );
include( 'post-types/class-sp-admin-cpt-player.php' );
+ include( 'post-types/class-sp-admin-cpt-list.php' );
+ include( 'post-types/class-sp-admin-cpt-staff.php' );
}
/**
diff --git a/includes/admin/post-types/class-sp-admin-cpt-calendar.php b/includes/admin/post-types/class-sp-admin-cpt-calendar.php
new file mode 100644
index 00000000..d2ef35ed
--- /dev/null
+++ b/includes/admin/post-types/class-sp-admin-cpt-calendar.php
@@ -0,0 +1,196 @@
+type = 'sp_calendar';
+
+ // Admin Columns
+ add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ add_filter( 'manage_edit-sp_calendar_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_calendar' == $_GET['post_type'] ) {
+ return true;
+ }
+ if ( ! empty( $_GET['post'] ) && 'sp_calendar' == get_post_type( $_GET['post'] ) ) {
+ return true;
+ }
+ if ( ! empty( $_REQUEST['post_id'] ) && 'sp_calendar' == get_post_type( $_REQUEST['post_id'] ) ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => '',
+ 'title' => __( 'Title', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_venue' => __( 'Venue', 'sportspress' ),
+ 'sp_team' => __( 'Team', 'sportspress' ),
+ 'sp_events' => __( 'Events', '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_venue':
+ echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
+ 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_events':
+ echo sizeof( sportspress_get_calendar_data( $post_id ) );
+ 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_calendar' )
+ 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 );
+
+ $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 );
+ }
+
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
+
+ if ( $typenow == 'sp_calendar' ) {
+
+ if ( isset( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = $_GET['team'];
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
+ }
+}
+
+endif;
+
+return new SP_Admin_CPT_Calendar();
diff --git a/includes/admin/post-types/class-sp-admin-cpt-event.php b/includes/admin/post-types/class-sp-admin-cpt-event.php
index 593ba15d..77eecc26 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-event.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-event.php
@@ -41,7 +41,6 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
add_filter( 'parse_query', array( $this, 'filters_query' ) );
-
// Call SP_Admin_CPT constructor
parent::__construct();
}
diff --git a/includes/admin/post-types/class-sp-admin-cpt-list.php b/includes/admin/post-types/class-sp-admin-cpt-list.php
new file mode 100644
index 00000000..061ea8f2
--- /dev/null
+++ b/includes/admin/post-types/class-sp-admin-cpt-list.php
@@ -0,0 +1,185 @@
+type = 'sp_list';
+
+ // Admin Columns
+ add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ add_filter( 'manage_edit-sp_list_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_list' == $_GET['post_type'] ) {
+ return true;
+ }
+ if ( ! empty( $_GET['post'] ) && 'sp_list' == get_post_type( $_GET['post'] ) ) {
+ return true;
+ }
+ if ( ! empty( $_REQUEST['post_id'] ) && 'sp_list' == get_post_type( $_REQUEST['post_id'] ) ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => '',
+ 'title' => __( 'Title', 'sportspress' ),
+ 'sp_player' => __( 'Players', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_team' => __( 'Team', '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_player':
+ echo sportspress_posts( $post_id, 'sp_player' );
+ 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_team':
+ $teams = (array)get_post_meta( $post_id, 'sp_team', false );
+ $teams = array_filter( $teams );
+ if ( empty( $teams ) ):
+ echo '—';
+ else:
+ foreach( $teams as $team_id ):
+ if ( ! $team_id ) continue;
+ $team = get_post( $team_id );
+ if ( $team ) echo $team->post_title . '
';
+ endforeach;
+ endif;
+ 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_list' )
+ 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 );
+
+ $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 );
+ }
+
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
+
+ if ( $typenow == 'sp_list' ) {
+
+ if ( isset( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = $_GET['team'];
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
+ }
+}
+
+endif;
+
+return new SP_Admin_CPT_List();
diff --git a/includes/admin/post-types/class-sp-admin-cpt-player.php b/includes/admin/post-types/class-sp-admin-cpt-player.php
index 8fa6c655..de561261 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-player.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-player.php
@@ -38,7 +38,6 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
add_filter( 'parse_query', array( $this, 'filters_query' ) );
-
// Call SP_Admin_CPT constructor
parent::__construct();
}
@@ -80,7 +79,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
$columns = array(
'cb' => '',
'sp_number' => '',
- 'title' => __( 'Player', 'sportspress' ),
+ 'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php
new file mode 100644
index 00000000..81a20c15
--- /dev/null
+++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php
@@ -0,0 +1,209 @@
+type = 'sp_staff';
+
+ // Post title fields
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+
+ // Admin Columns
+ add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ add_filter( 'manage_edit-sp_staff_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_staff' == $_GET['post_type'] ) {
+ return true;
+ }
+ if ( ! empty( $_GET['post'] ) && 'sp_staff' == get_post_type( $_GET['post'] ) ) {
+ return true;
+ }
+ if ( ! empty( $_REQUEST['post_id'] ) && 'sp_staff' == 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_staff' )
+ return __( 'Name', 'sportspress' );
+
+ return $text;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => '',
+ 'title' => __( 'Name', 'sportspress' ),
+ 'sp_role' => __( 'Role', '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_role':
+ $role = get_post_meta ( $post_id, 'sp_role', true );
+ echo $role ? $role : '—';
+ 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_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_staff' )
+ 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_staff' ) {
+
+ if ( isset( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = $_GET['team'];
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
+ }
+}
+
+endif;
+
+return new SP_Admin_CPT_Staff();
diff --git a/includes/admin/post-types/class-sp-admin-cpt-table.php b/includes/admin/post-types/class-sp-admin-cpt-table.php
new file mode 100644
index 00000000..71ff274e
--- /dev/null
+++ b/includes/admin/post-types/class-sp-admin-cpt-table.php
@@ -0,0 +1,171 @@
+type = 'sp_table';
+
+ // Admin Columns
+ add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ add_filter( 'manage_edit-sp_table_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_table' == $_GET['post_type'] ) {
+ return true;
+ }
+ if ( ! empty( $_GET['post'] ) && 'sp_table' == get_post_type( $_GET['post'] ) ) {
+ return true;
+ }
+ if ( ! empty( $_REQUEST['post_id'] ) && 'sp_table' == get_post_type( $_REQUEST['post_id'] ) ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => '',
+ 'title' => __( 'Title', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_team' => __( 'Teams', '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_team':
+ echo sportspress_posts( $post_id, 'sp_team' );
+ 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_table' )
+ 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 );
+
+ $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 );
+ }
+
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
+
+ if ( $typenow == 'sp_table' ) {
+
+ if ( isset( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = $_GET['team'];
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
+ }
+}
+
+endif;
+
+return new SP_Admin_CPT_Table();
diff --git a/includes/admin/post-types/class-sp-admin-cpt-team.php b/includes/admin/post-types/class-sp-admin-cpt-team.php
index def65f4f..60139a6a 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-team.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-team.php
@@ -37,7 +37,6 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
// Filtering
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
-
// Call SP_Admin_CPT constructor
parent::__construct();
}
diff --git a/includes/class-sp-post-types.php b/includes/class-sp-post-types.php
index a1db4fd7..b914b067 100644
--- a/includes/class-sp-post-types.php
+++ b/includes/class-sp-post-types.php
@@ -170,9 +170,8 @@ class SP_Post_types {
do_action( 'sportspress_register_post_type' );
register_post_type( 'sp_event',
- apply_filters( 'sportspress_register_post_type_product',
+ apply_filters( 'sportspress_register_post_type_event',
array(
- 'label' => __( 'Events', 'sportspress' ),
'labels' => array(
'name' => __( 'Schedule', 'sportspress' ),
'singular_name' => __( 'Event', 'sportspress' ),
@@ -193,7 +192,6 @@ class SP_Post_types {
'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,
@@ -201,6 +199,192 @@ class SP_Post_types {
)
)
);
+
+ register_post_type( 'sp_calendar',
+ apply_filters( 'sportspress_register_post_type_calendar',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Calendars', 'sportspress' ),
+ 'singular_name' => __( 'Calendar', 'sportspress' ),
+ 'all_items' => __( 'Calendars', 'sportspress' ),
+ 'add_new_item' => __( 'Add New Calendar', 'sportspress' ),
+ 'edit_item' => __( 'Edit Calendar', '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_calendar',
+ 'map_meta_cap' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'hierarchical' => false,
+ 'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
+ 'supports' => array( 'title', 'author', 'thumbnail' ),
+ 'has_archive' => false,
+ 'show_in_nav_menus' => true,
+ 'show_in_menu' => 'edit.php?post_type=sp_event',
+ )
+ )
+ );
+
+ register_post_type( 'sp_team',
+ apply_filters( 'sportspress_register_post_type_team',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Teams', 'sportspress' ),
+ 'singular_name' => __( 'Team', 'sportspress' ),
+ 'all_items' => __( 'Teams', 'sportspress' ),
+ 'add_new_item' => __( 'Add New Team', 'sportspress' ),
+ 'edit_item' => __( 'Edit Team', '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_team',
+ 'map_meta_cap' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'hierarchical' => true,
+ 'rewrite' => array( 'slug' => get_option( 'sportspress_teams_slug', 'teams' ) ),
+ 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
+ 'has_archive' => true,
+ 'show_in_nav_menus' => true,
+ 'menu_icon' => 'dashicons-shield-alt',
+ )
+ )
+ );
+
+ register_post_type( 'sp_table',
+ apply_filters( 'sportspress_register_post_type_table',
+ array(
+ 'labels' => array(
+ 'name' => __( 'League Tables', 'sportspress' ),
+ 'singular_name' => __( 'League Table', 'sportspress' ),
+ 'all_items' => __( 'League Tables', 'sportspress' ),
+ 'add_new_item' => __( 'Add New League Table', 'sportspress' ),
+ 'edit_item' => __( 'Edit League Table', '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_table',
+ 'map_meta_cap' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'hierarchical' => false,
+ 'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
+ 'supports' => array( 'title', 'author', 'thumbnail' ),
+ 'has_archive' => false,
+ 'show_in_nav_menus' => true,
+ 'show_in_menu' => 'edit.php?post_type=sp_team',
+ )
+ )
+ );
+
+ register_post_type( 'sp_player',
+ apply_filters( 'sportspress_register_post_type_player',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Roster', 'sportspress' ),
+ 'singular_name' => __( 'Player', 'sportspress' ),
+ 'all_items' => __( 'Players', 'sportspress' ),
+ 'add_new_item' => __( 'Add New Player', 'sportspress' ),
+ 'edit_item' => __( 'Edit Player', '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_player',
+ 'map_meta_cap' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'hierarchical' => false,
+ 'rewrite' => array( 'slug' => get_option( 'sportspress_players_slug', 'players' ) ),
+ 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'page-attributes' ),
+ 'has_archive' => true,
+ 'show_in_nav_menus' => true,
+ 'menu_icon' => 'dashicons-groups',
+ )
+ )
+ );
+
+ register_post_type( 'sp_list',
+ apply_filters( 'sportspress_register_post_type_list',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Player Lists', 'sportspress' ),
+ 'singular_name' => __( 'Player List', 'sportspress' ),
+ 'all_items' => __( 'Player Lists', 'sportspress' ),
+ 'add_new_item' => __( 'Add New Player List', 'sportspress' ),
+ 'edit_item' => __( 'Edit Player List', '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_list',
+ 'map_meta_cap' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'hierarchical' => false,
+ 'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
+ 'supports' => array( 'title', 'author', 'thumbnail' ),
+ 'has_archive' => false,
+ 'show_in_nav_menus' => true,
+ 'show_in_menu' => 'edit.php?post_type=sp_player',
+ )
+ )
+ );
+
+ register_post_type( 'sp_staff',
+ apply_filters( 'sportspress_register_post_type_staff',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Staff', 'sportspress' ),
+ 'singular_name' => __( 'Staff', 'sportspress' ),
+ 'all_items' => __( 'Staff', 'sportspress' ),
+ 'add_new_item' => __( 'Add New Staff', 'sportspress' ),
+ 'edit_item' => __( 'Edit Staff', '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_staff',
+ 'map_meta_cap' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'hierarchical' => false,
+ 'rewrite' => array( 'slug' => get_option( 'sportspress_staff_slug', 'staff' ) ),
+ 'supports' => array( 'title', 'author', 'thumbnail' ),
+ 'has_archive' => true,
+ 'show_in_nav_menus' => true,
+ 'show_in_menu' => 'edit.php?post_type=sp_player',
+ )
+ )
+ );
}
public function display_scheduled_events( $posts ) {
diff --git a/sportspress.php b/sportspress.php
index 740aff0a..f16d9272 100644
--- a/sportspress.php
+++ b/sportspress.php
@@ -216,12 +216,12 @@ final class SportsPress {
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/calendar.php' );
- include_once( 'admin/post-types/team.php' );
- include_once( 'admin/post-types/table.php' );
- include_once( 'admin/post-types/player.php' );
- include_once( 'admin/post-types/list.php' );
- include_once( 'admin/post-types/staff.php' );
+ //include_once( 'admin/post-types/calendar.php' );
+ //include_once( 'admin/post-types/team.php' );
+ //include_once( 'admin/post-types/table.php' );
+ //include_once( 'admin/post-types/player.php' );
+ //include_once( 'admin/post-types/list.php' );
+ //include_once( 'admin/post-types/staff.php' );
//include_once( 'admin/post-types/directory.php' );
if ( is_admin() ) {