isset( $_POST['season_id'] ) && '' !== $_POST['season_id'] ? sanitize_text_field( wp_unslash( $_POST['season_id'] ) ) : wp_generate_uuid4(), 'name' => isset( $_POST['season_name'] ) ? sanitize_text_field( wp_unslash( $_POST['season_name'] ) ) : '', 'start_date' => isset( $_POST['season_start_date'] ) ? sanitize_text_field( wp_unslash( $_POST['season_start_date'] ) ) : '', 'end_date' => isset( $_POST['season_end_date'] ) ? sanitize_text_field( wp_unslash( $_POST['season_end_date'] ) ) : '', 'modifier' => isset( $_POST['season_modifier'] ) ? floatval( $_POST['season_modifier'] ) : 1.0, 'priority' => isset( $_POST['season_priority'] ) ? absint( $_POST['season_priority'] ) : 0, 'active' => isset( $_POST['season_active'] ), ); $season = new Season( $data ); Season::save( $season ); $is_edit = isset( $_POST['season_id'] ) && '' !== $_POST['season_id']; $message = $is_edit ? 'updated' : 'created'; wp_safe_redirect( admin_url( 'admin.php?page=wp-bnb-seasons&' . $message . '=1' ) ); exit; } /** * Render the admin page. * * @return void */ public static function render_page(): void { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display only. $action = isset( $_GET['action'] ) ? sanitize_key( $_GET['action'] ) : 'list'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display only. $season_id = isset( $_GET['season_id'] ) ? sanitize_text_field( wp_unslash( $_GET['season_id'] ) ) : ''; ?>
' . esc_html__( 'Season deleted successfully.', 'wp-bnb' ) . '
'; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display only. if ( isset( $_GET['created'] ) ) { echo '' . esc_html__( 'Season created successfully.', 'wp-bnb' ) . '
' . esc_html__( 'Season updated successfully.', 'wp-bnb' ) . '
' . esc_html__( 'Default seasons created successfully.', 'wp-bnb' ) . '
| name ); ?> | start_date, $season->end_date ) ); ?> | getModifierLabel() ); ?> modifier !== 1.0 ) : ?> (modifier, 2 ) ); ?>x) | priority ); ?> | active ) : ?> |
' . esc_html__( 'Season not found.', 'wp-bnb' ) . '
'; return; } ?> __( 'Jan', 'wp-bnb' ), '02' => __( 'Feb', 'wp-bnb' ), '03' => __( 'Mar', 'wp-bnb' ), '04' => __( 'Apr', 'wp-bnb' ), '05' => __( 'May', 'wp-bnb' ), '06' => __( 'Jun', 'wp-bnb' ), '07' => __( 'Jul', 'wp-bnb' ), '08' => __( 'Aug', 'wp-bnb' ), '09' => __( 'Sep', 'wp-bnb' ), '10' => __( 'Oct', 'wp-bnb' ), '11' => __( 'Nov', 'wp-bnb' ), '12' => __( 'Dec', 'wp-bnb' ), ); $format_date = function ( string $date ) use ( $months ): string { $parts = explode( '-', $date ); if ( count( $parts ) !== 2 ) { return $date; } $month = $months[ $parts[0] ] ?? $parts[0]; $day = ltrim( $parts[1], '0' ); return $month . ' ' . $day; }; return $format_date( $start ) . ' - ' . $format_date( $end ); } }