From dbd8d8d24c5513ff42e82c53a54898064edeaecc Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 20 Sep 2015 21:59:05 +1000 Subject: [PATCH] Modify post type hierarchy in individual mode --- modules/sportspress-individual-mode.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/sportspress-individual-mode.php b/modules/sportspress-individual-mode.php index f53de43c..fae7b9b4 100644 --- a/modules/sportspress-individual-mode.php +++ b/modules/sportspress-individual-mode.php @@ -50,6 +50,8 @@ class SportsPress_Individual_Mode { add_filter( 'sportspress_directory_admin_columns', array( $this, 'remove_team_column' ), 99 ); add_filter( 'sportspress_importers', array( $this, 'remove_teams_importer' ), 99 ); add_filter( 'sportspress_permalink_slugs', array( $this, 'remove_team_permalink_slug' ), 99 ); + add_filter( 'sportspress_primary_post_types', array( $this, 'primary_post_types' ) ); + add_filter( 'sportspress_post_type_hierarchy', array( $this, 'post_type_hierarchy' ) ); add_filter( 'sportspress_event_team_tabs', '__return_false' ); add_filter( 'sportspress_player_team_statistics', '__return_false' ); add_filter( 'sportspress_player_teams', '__return_false' ); @@ -268,6 +270,25 @@ class SportsPress_Individual_Mode { return $slugs; } + /** + * Remove the team primary post type. + */ + public function primary_post_types( $post_types ) { + if ( ( $key = array_search( 'sp_team', $post_types ) ) !== false ) { + unset( $post_types[ $key ] ); + } + return $post_types; + } + + /** + * Adjust post type hierarchy. + */ + public function post_type_hierarchy( $hierarchy ) { + $hierarchy['sp_player'] = array_merge( sp_array_value( $hierarchy, 'sp_player', array() ), sp_array_value( $hierarchy, 'sp_team', array() ) ); + unset( $hierarchy['sp_team'] ); + return $hierarchy; + } + /** * Highlights the correct top level admin menu item for post type add screens. *