Create players if not found during box score import

This commit is contained in:
Brian Miyaji
2017-11-15 23:10:55 +11:00
parent 6309e5b70b
commit 866d93b08a

View File

@@ -73,12 +73,20 @@ if ( class_exists( 'WP_Importer' ) ) {
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' ); $player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
if ( ! $player_object ): if ( $player_object ):
$this->skipped ++;
continue;
endif;
$player_id = $player_object->ID; // Get player ID
$player_id = $player_object->ID;
else:
// Insert player
$player_id = wp_insert_post( array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $player_name ) ) );
// Flag as import
update_post_meta( $player_id, '_sp_import', 1 );
endif;
$team_players[] = $player_id; $team_players[] = $player_id;
$player = array(); $player = array();