Update main league and current season during setup

This commit is contained in:
Brian Miyaji
2018-01-22 11:31:58 +11:00
parent e78a259065
commit cc553f88e2

View File

@@ -334,14 +334,20 @@ class SP_Admin_Setup_Wizard {
if ( ! is_string( $league ) || empty( $league ) ) { if ( ! is_string( $league ) || empty( $league ) ) {
$league = _x( 'Primary League', 'example', 'sportspress' ); $league = _x( 'Primary League', 'example', 'sportspress' );
} }
wp_insert_term( $league, 'sp_league' ); $inserted = wp_insert_term( $league, 'sp_league' );
if ( ! is_wp_error( $inserted ) ) {
update_option( 'sportspress_league', sp_array_value( $inserted, 'term_id', null ) );
}
// Insert season // Insert season
$season = sanitize_text_field( $_POST['season'] ); $season = sanitize_text_field( $_POST['season'] );
if ( ! is_string( $season ) || empty( $season ) ) { if ( ! is_string( $season ) || empty( $season ) ) {
$season = date( 'Y' ); $season = date( 'Y' );
} }
wp_insert_term( $season, 'sp_season' ); $inserted = wp_insert_term( $season, 'sp_season' );
if ( ! is_wp_error( $inserted ) ) {
update_option( 'sportspress_season', sp_array_value( $inserted, 'term_id', null ) );
}
wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit; exit;