Add officials importer and improve admin placement

This commit is contained in:
Brian Miyaji
2017-11-18 18:15:09 +11:00
parent 32fd7ddfd7
commit fbf385258b
6 changed files with 175 additions and 251 deletions

View File

@@ -49,9 +49,13 @@ class SportsPress_Officials {
add_filter( 'sportspress_after_event_template', array( $this, 'add_event_template' ), 30 );
add_filter( 'sportspress_event_options', array( $this, 'add_event_options' ) );
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
add_filter( 'sportspress_menu_items', array( $this, 'add_menu_item' ) );
add_filter( 'sportspress_glance_items', array( $this, 'add_glance_item' ) );
add_filter( 'sportspress_importers', array( $this, 'register_importer' ) );
add_filter( 'sportspress_screen_ids', array( $this, 'screen_ids' ) );
add_filter( 'sportspress_post_types', array( $this, 'add_post_type' ) );
add_filter( 'sportspress_primary_post_types', array( $this, 'add_post_type' ) );
add_filter( 'sportspress_importable_post_types', array( $this, 'add_post_type' ) );
add_filter( 'sportspress_post_type_hierarchy', array( $this, 'add_to_hierarchy' ) );
add_filter( 'manage_edit-sp_duty_columns', array( $this, 'taxonomy_columns' ) );
add_filter( 'manage_sp_duty_custom_column', array( $this, 'taxonomy_column_value' ), 10, 3 );
@@ -460,6 +464,47 @@ class SportsPress_Officials {
) );
}
/**
* Add menu item
*/
public function add_menu_item( $items ) {
$items[] = 'edit.php?post_type=sp_official';
return $items;
}
/**
* Add glance item
*/
public function add_glance_item( $items ) {
$items[] = 'sp_official';
return $items;
}
/**
* Register importer
*/
public function register_importer( $importers = array() ) {
$importers['sp_official_csv'] = array(
'name' => __( 'SportsPress Officials (CSV)', 'sportspress' ),
'description' => __( 'Import <strong>officials</strong> from a csv file.', 'sportspress'),
'callback' => array( $this, 'officials_importer' ),
);
return $importers;
}
/**
* Officials importer
*/
public function officials_importer() {
SP_Admin_Importers::includes();
require SP()->plugin_path() . '/includes/admin/importers/class-sp-official-importer.php';
// Dispatch
$importer = new SP_Official_Importer();
$importer->dispatch();
}
/**
* Add screen ids.
*