Detach duties from officials to simplify admin

This commit is contained in:
Brian Miyaji
2017-11-16 16:15:21 +11:00
parent 41d4d69e57
commit 608ff2b871
2 changed files with 23 additions and 138 deletions

View File

@@ -31,7 +31,6 @@ class SportsPress_Officials {
// Actions
add_action( 'sportspress_after_register_taxonomy', array( $this, 'register_taxonomy' ) );
add_action( 'sportspress_after_register_post_type', array( $this, 'register_post_type' ) );
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
@@ -41,6 +40,8 @@ class SportsPress_Officials {
add_action( 'sportspress_calendar_data_meta_box_table_row', array( $this, 'calendar_meta_row' ), 10, 2 );
add_action( 'sp_duty_edit_form_fields', array( $this, 'edit_taxonomy_fields' ), 10, 1 );
add_action( 'edited_sp_duty', array( $this, 'save_taxonomy_fields' ), 10, 1 );
add_action( 'admin_menu', array( $this, 'duties_menu' ) );
add_action( 'parent_file', array( $this, 'parent_file' ) );
// Filters
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
@@ -102,7 +103,7 @@ class SportsPress_Officials {
'rest_controller_class' => '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;