From e5f79d4ae3e2e4725633bfb35bc13687cd0373ca Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 23 Jan 2015 17:12:08 +1100 Subject: [PATCH] Add links to importers on post list screens --- includes/admin/class-sp-admin-importers.php | 8 +++---- includes/admin/class-sp-admin.php | 24 +++++++++++++++++++ .../importers/class-sp-event-importer.php | 4 ++-- .../importers/class-sp-player-importer.php | 4 ++-- .../importers/class-sp-staff-importer.php | 4 ++-- .../importers/class-sp-team-importer.php | 4 ++-- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/includes/admin/class-sp-admin-importers.php b/includes/admin/class-sp-admin-importers.php index 65739328..64cd1608 100644 --- a/includes/admin/class-sp-admin-importers.php +++ b/includes/admin/class-sp-admin-importers.php @@ -28,10 +28,10 @@ class SP_Admin_Importers { * Add menu items */ public function register_importers() { - register_importer( 'sportspress_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import events from a csv file.', 'sportspress'), array( $this, 'events_importer' ) ); - register_importer( 'sportspress_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import teams from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) ); - register_importer( 'sportspress_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import players from a csv file.', 'sportspress'), array( $this, 'players_importer' ) ); - register_importer( 'sportspress_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import staff from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) ); + register_importer( 'sp_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import events from a csv file.', 'sportspress'), array( $this, 'events_importer' ) ); + register_importer( 'sp_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import teams from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) ); + register_importer( 'sp_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import players from a csv file.', 'sportspress'), array( $this, 'players_importer' ) ); + register_importer( 'sp_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import staff from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) ); } /** diff --git a/includes/admin/class-sp-admin.php b/includes/admin/class-sp-admin.php index e3f770b7..0e64ca3b 100644 --- a/includes/admin/class-sp-admin.php +++ b/includes/admin/class-sp-admin.php @@ -21,6 +21,11 @@ class SP_Admin { add_action( 'init', array( $this, 'includes' ) ); add_action( 'current_screen', array( $this, 'conditonal_includes' ) ); add_action( 'admin_init', array( $this, 'prevent_admin_access' ) ); + + // Action buttons + add_action( 'admin_print_footer_scripts', array( $this, 'action_links' ) ); + + // Review link add_action( 'sportspress_settings_page', 'sp_review_link' ); add_action( 'sportspress_config_page', 'sp_review_link' ); add_action( 'sportspress_overview_page', 'sp_review_link' ); @@ -86,6 +91,25 @@ class SP_Admin { exit; } } + + /** + * Add action link after post list title + */ + public function action_links() { + global $pagenow, $typenow; + if ( 'edit.php' == $pagenow && in_array( $typenow, sp_primary_post_types() ) ) { + ?> + + import_page = 'sportspress_event_csv'; + $this->import_page = 'sp_event_csv'; $this->import_label = __( 'Import Events', 'sportspress' ); $this->columns = array( 'post_date' => __( 'Date', 'sportspress' ), @@ -449,7 +449,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; echo '

' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '

'; - wp_import_upload_form( 'admin.php?import=sportspress_event_csv&step=1' ); + wp_import_upload_form( 'admin.php?import=sp_event_csv&step=1' ); echo '
'; } diff --git a/includes/admin/importers/class-sp-player-importer.php b/includes/admin/importers/class-sp-player-importer.php index 1faaf50f..92930af6 100644 --- a/includes/admin/importers/class-sp-player-importer.php +++ b/includes/admin/importers/class-sp-player-importer.php @@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) { * @return void */ public function __construct() { - $this->import_page = 'sportspress_player_csv'; + $this->import_page = 'sp_player_csv'; $this->import_label = __( 'Import Players', 'sportspress' ); $this->columns = array( 'sp_number' => __( 'Number', 'sportspress' ), @@ -169,7 +169,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; echo '

' . sprintf( __( 'Players need to be defined with columns in a specific order (7 columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '

'; - wp_import_upload_form( 'admin.php?import=sportspress_player_csv&step=1' ); + wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' ); echo '
'; } } diff --git a/includes/admin/importers/class-sp-staff-importer.php b/includes/admin/importers/class-sp-staff-importer.php index 4d591838..e5d4a30b 100644 --- a/includes/admin/importers/class-sp-staff-importer.php +++ b/includes/admin/importers/class-sp-staff-importer.php @@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) { * @return void */ public function __construct() { - $this->import_page = 'sportspress_staff_csv'; + $this->import_page = 'sp_staff_csv'; $this->import_label = __( 'Import Staff', 'sportspress' ); $this->columns = array( 'post_title' => __( 'Name', 'sportspress' ), @@ -165,7 +165,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; echo '

' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '

'; - wp_import_upload_form( 'admin.php?import=sportspress_staff_csv&step=1' ); + wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' ); echo '
'; } } diff --git a/includes/admin/importers/class-sp-team-importer.php b/includes/admin/importers/class-sp-team-importer.php index 8d40d59d..aef1cb51 100644 --- a/includes/admin/importers/class-sp-team-importer.php +++ b/includes/admin/importers/class-sp-team-importer.php @@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) { * @return void */ public function __construct() { - $this->import_page = 'sportspress_team_csv'; + $this->import_page = 'sp_team_csv'; $this->import_label = __( 'Import Teams', 'sportspress' ); $this->columns = array( 'post_title' => __( 'Name', 'sportspress' ), @@ -124,7 +124,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; echo '

' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '

'; - wp_import_upload_form( 'admin.php?import=sportspress_team_csv&step=1' ); + wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' ); echo '
'; } }