Add links to importers on post list screens
This commit is contained in:
@@ -28,10 +28,10 @@ class SP_Admin_Importers {
|
|||||||
* Add menu items
|
* Add menu items
|
||||||
*/
|
*/
|
||||||
public function register_importers() {
|
public function register_importers() {
|
||||||
register_importer( 'sportspress_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import <strong>events</strong> from a csv file.', 'sportspress'), array( $this, 'events_importer' ) );
|
register_importer( 'sp_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import <strong>events</strong> from a csv file.', 'sportspress'), array( $this, 'events_importer' ) );
|
||||||
register_importer( 'sportspress_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) );
|
register_importer( 'sp_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) );
|
||||||
register_importer( 'sportspress_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import <strong>players</strong> from a csv file.', 'sportspress'), array( $this, 'players_importer' ) );
|
register_importer( 'sp_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import <strong>players</strong> from a csv file.', 'sportspress'), array( $this, 'players_importer' ) );
|
||||||
register_importer( 'sportspress_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) );
|
register_importer( 'sp_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class SP_Admin {
|
|||||||
add_action( 'init', array( $this, 'includes' ) );
|
add_action( 'init', array( $this, 'includes' ) );
|
||||||
add_action( 'current_screen', array( $this, 'conditonal_includes' ) );
|
add_action( 'current_screen', array( $this, 'conditonal_includes' ) );
|
||||||
add_action( 'admin_init', array( $this, 'prevent_admin_access' ) );
|
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_settings_page', 'sp_review_link' );
|
||||||
add_action( 'sportspress_config_page', 'sp_review_link' );
|
add_action( 'sportspress_config_page', 'sp_review_link' );
|
||||||
add_action( 'sportspress_overview_page', 'sp_review_link' );
|
add_action( 'sportspress_overview_page', 'sp_review_link' );
|
||||||
@@ -86,6 +91,25 @@ class SP_Admin {
|
|||||||
exit;
|
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() ) ) {
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function($) {
|
||||||
|
$(".wrap h2 .add-new-h2:first-child").after(
|
||||||
|
" ",
|
||||||
|
$("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => $typenow . '_csv' ), 'admin.php' ) ) ); ?>\"><?php _e( 'Import', 'sportspress' ); ?></a>")
|
||||||
|
);
|
||||||
|
})(jQuery);
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SP_Admin();
|
return new SP_Admin();
|
||||||
@@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->import_page = 'sportspress_event_csv';
|
$this->import_page = 'sp_event_csv';
|
||||||
$this->import_label = __( 'Import Events', 'sportspress' );
|
$this->import_label = __( 'Import Events', 'sportspress' );
|
||||||
$this->columns = array(
|
$this->columns = array(
|
||||||
'post_date' => __( 'Date', 'sportspress' ),
|
'post_date' => __( 'Date', 'sportspress' ),
|
||||||
@@ -449,7 +449,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||||
echo '<p>' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '</p>';
|
||||||
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 '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->import_page = 'sportspress_player_csv';
|
$this->import_page = 'sp_player_csv';
|
||||||
$this->import_label = __( 'Import Players', 'sportspress' );
|
$this->import_label = __( 'Import Players', 'sportspress' );
|
||||||
$this->columns = array(
|
$this->columns = array(
|
||||||
'sp_number' => __( 'Number', 'sportspress' ),
|
'sp_number' => __( 'Number', 'sportspress' ),
|
||||||
@@ -169,7 +169,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||||
echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (7 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (7 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
|
||||||
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 '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->import_page = 'sportspress_staff_csv';
|
$this->import_page = 'sp_staff_csv';
|
||||||
$this->import_label = __( 'Import Staff', 'sportspress' );
|
$this->import_label = __( 'Import Staff', 'sportspress' );
|
||||||
$this->columns = array(
|
$this->columns = array(
|
||||||
'post_title' => __( 'Name', 'sportspress' ),
|
'post_title' => __( 'Name', 'sportspress' ),
|
||||||
@@ -165,7 +165,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||||
echo '<p>' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '</p>';
|
||||||
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 '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->import_page = 'sportspress_team_csv';
|
$this->import_page = 'sp_team_csv';
|
||||||
$this->import_label = __( 'Import Teams', 'sportspress' );
|
$this->import_label = __( 'Import Teams', 'sportspress' );
|
||||||
$this->columns = array(
|
$this->columns = array(
|
||||||
'post_title' => __( 'Name', 'sportspress' ),
|
'post_title' => __( 'Name', 'sportspress' ),
|
||||||
@@ -124,7 +124,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||||
echo '<p>' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '</p>';
|
||||||
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 '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user