diff --git a/includes/admin/importers/class-sp-player-importer.php b/includes/admin/importers/class-sp-player-importer.php index 8116ccd4..a43ee0d0 100644 --- a/includes/admin/importers/class-sp-player-importer.php +++ b/includes/admin/importers/class-sp-player-importer.php @@ -71,12 +71,20 @@ if ( class_exists( 'WP_Importer' ) ) { continue; endif; - $args = array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) ); + // Get or insert player + $player_object = get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ); + if ( $player_object ): + if ( $player_object->post_status != 'publish' ): + wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) ); + endif; + $id = $player_object->ID; + else: + $args = array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) ); + $id = wp_insert_post( $args ); - $id = wp_insert_post( $args ); - - // Flag as import - update_post_meta( $id, '_sp_import', 1 ); + // Flag as import + update_post_meta( $id, '_sp_import', 1 ); + endif; // Update number update_post_meta( $id, 'sp_number', sp_array_value( $meta, 'sp_number' ) ); @@ -172,5 +180,29 @@ if ( class_exists( 'WP_Importer' ) ) { wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' ); echo ''; } + + /** + * options function. + * + * @access public + * @return void + */ + function options() { + ?> + + + + + + +
+ +
+