From 608ff2b871e43f80a5c944bb87606095e200a590 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 16 Nov 2017 16:15:21 +1100 Subject: [PATCH] Detach duties from officials to simplify admin --- .../class-sp-meta-box-official-details.php | 120 ------------------ modules/sportspress-officials.php | 41 +++--- 2 files changed, 23 insertions(+), 138 deletions(-) delete mode 100644 includes/admin/post-types/meta-boxes/class-sp-meta-box-official-details.php diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-official-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-official-details.php deleted file mode 100644 index 8464c93d..00000000 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-official-details.php +++ /dev/null @@ -1,120 +0,0 @@ -countries->continents; - - $nationalities = get_post_meta( $post->ID, 'sp_nationality', false ); - foreach ( $nationalities as $index => $nationality ): - if ( 2 == strlen( $nationality ) ): - $legacy = SP()->countries->legacy; - $nationality = strtolower( $nationality ); - $nationality = sp_array_value( $legacy, $nationality, null ); - $nationalities[ $index ] = $nationality; - endif; - endforeach; - - if ( taxonomy_exists( 'sp_duty' ) ): - $positions = get_the_terms( $post->ID, 'sp_duty' ); - $position_ids = array(); - if ( $positions ): - foreach ( $positions as $position ): - $position_ids[] = $position->term_id; - endforeach; - endif; - endif; - - $teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) ); - $past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) ); - $current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) ); - ?> - -

-

- - -

-

'sp_duty', - 'name' => 'tax_input[sp_duty][]', - 'selected' => $position_ids, - 'values' => 'term_id', - 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Duties', 'sportspress' ) ), - 'class' => 'widefat', - 'property' => 'multiple', - 'chosen' => true, - ); - sp_dropdown_taxonomies( $args ); - ?>

- - -

-

'sp_team', - 'name' => 'sp_current_team[]', - 'selected' => $current_teams, - 'values' => 'ID', - 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), - 'class' => 'sp-current-teams widefat', - 'property' => 'multiple', - 'chosen' => true, - ); - sp_dropdown_pages( $args ); - ?>

- -

-

'sp_team', - 'name' => 'sp_past_team[]', - 'selected' => $past_teams, - 'values' => 'ID', - 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), - 'class' => 'sp-past-teams widefat', - 'property' => 'multiple', - 'chosen' => true, - ); - sp_dropdown_pages( $args ); - ?>

- 'SP_REST_Terms_Controller', 'rest_base' => 'duties', ) ); - $object_types = apply_filters( 'sportspress_duty_object_types', array( 'sp_official' ) ); + $object_types = apply_filters( 'sportspress_duty_object_types', array() ); register_taxonomy( 'sp_duty', $object_types, $args ); foreach ( $object_types as $object_type ): register_taxonomy_for_object_type( 'sp_duty', $object_type ); @@ -151,13 +152,6 @@ class SportsPress_Officials { ); } - /** - * Remove meta boxes. - */ - public function remove_meta_boxes() { - remove_meta_box( 'sp_dutydiv', 'sp_official', 'side' ); - } - /** * Conditonally load the class and functions only needed when viewing this post type. */ @@ -315,15 +309,6 @@ class SportsPress_Officials { 'context' => 'side', 'priority' => 'default', ); - $meta_boxes['sp_official'] = array( - 'details' => array( - 'title' => __( 'Details', 'sportspress' ), - 'save' => 'SP_Meta_Box_Official_Details::save', - 'output' => 'SP_Meta_Box_Official_Details::output', - 'context' => 'side', - 'priority' => 'default', - ), - ); return $meta_boxes; } @@ -589,6 +574,26 @@ class SportsPress_Officials { return $columns; } + + /** + * Add menu item + */ + public function duties_menu() { + add_submenu_page( 'edit.php?post_type=sp_official', __( 'Duties', 'sportspress' ), __( 'Duties', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_duty'); + } + + /** + * Highlight parent menu item + */ + public function parent_file( $parent_file ) { + global $current_screen; + $taxonomy = $current_screen->taxonomy; + + if ( 'sp_duty' == $taxonomy ) + $parent_file = 'edit.php?post_type=sp_official'; + + return $parent_file; + } } endif;