diff --git a/assets/print-calendar.css b/assets/print-calendar.css index a0146ad..a56321d 100644 --- a/assets/print-calendar.css +++ b/assets/print-calendar.css @@ -27,10 +27,7 @@ body { .print-shell { margin: 0; - width: calc(100% / var(--sheet-scale)); background: #fff; - transform-origin: top left; - transform: scale(var(--sheet-scale)); } .print-page { @@ -48,7 +45,10 @@ body { } body.print-preview .print-shell { + flex: 0 0 auto; box-shadow: 0 10px 30px rgba(17, 24, 39, 0.2); + transform-origin: top left; + transform: scale(var(--sheet-scale)); } body.print-preview .print-shell.letter { @@ -60,6 +60,104 @@ body { width: 11in; min-height: 17in; } + + body.print-preview.month-pages { + display: block; + overflow-x: auto; + } + + body.print-preview.month-pages .print-shell, + body.print-preview.month-pages .print-shell.letter, + body.print-preview.month-pages .print-shell.ledger { + width: auto; + min-height: auto; + background: transparent; + box-shadow: none; + transform: none; + } + + body.print-preview.month-pages .print-page { + padding: 0; + } + + body.print-preview.month-pages .month-page { + box-sizing: border-box; + width: 8.5in; + min-height: 11in; + margin-right: auto; + margin-left: auto; + padding: var(--pc-page-padding); + background: #fff; + box-shadow: 0 10px 30px rgba(17, 24, 39, 0.2); + } + + body.print-preview.month-pages.ledger .month-page { + width: 11in; + min-height: 17in; + } + + body.print-preview.month-pages .month-page + .month-page { + margin-top: 24px; + } + + body.print-preview.month-pages .month-page .header { + margin-bottom: 24px; + } + + body.print-preview.month-pages .month-page .footer-meta { + margin-top: 24px; + } + + body.print-preview.month-pages .sheet-grid { + display: block; + } + +body.print-preview.month-pages .month { + width: 100%; +} + +body.month-pages .month-title { + font-size: calc(26px * var(--month-font-scale)); + padding: 4px; +} + +body.month-pages .dow span { + font-size: calc(12px * var(--month-font-scale)); + padding: 4px 2px; +} + +body.month-pages .day-num { + font-size: calc(14px * var(--month-font-scale)); +} + +body.month-pages .event-name { + font-size: calc(13px * var(--month-font-scale)); + line-height: 0.98; +} + +body.month-pages .matchup-name { + font-size: calc(13px * var(--month-font-scale)); + line-height: 0.92; +} + +body.month-pages .event-time { + font-size: calc(14px * var(--month-font-scale)); +} + +body.month-pages .event.matchup .event-time { + font-size: calc(11px * var(--month-font-scale)); +} + +body.month-pages .event.matchup .event-venue { + font-size: calc(10px * var(--month-font-scale)); +} +} + +@media screen and (max-width: 900px) { + body.print-preview { + justify-content: flex-start; + overflow-x: auto; + } } .header { @@ -235,7 +333,7 @@ body { position: absolute; top: var(--corner-badge-offset); left: var(--corner-badge-offset); - z-index: 4; + z-index: 20; width: var(--corner-badge-size); height: var(--corner-badge-size); display: flex; @@ -252,12 +350,46 @@ body { color: var(--day-num-color, #fff); } +.day.has-matchups { + background: #fff; + border: 1px solid var(--pc-border); +} + +.day.has-matchups .day-num { + position: absolute; + z-index: 20; + background: #fff; + color: var(--team-ink, #111) !important; + text-shadow: none !important; + box-shadow: 0 0 0 1px var(--pc-border); +} + +body.month-pages .day .day-num { + top: 1px; + left: 1px; + width: var(--corner-badge-size); + height: var(--corner-badge-size); + border-radius: 0; + background: #fff; + color: var(--team-ink, #111); + text-shadow: none; +} + .events-stack { + position: relative; + z-index: 1; height: 100%; display: grid; grid-template-rows: repeat(var(--event-count), minmax(0, 1fr)); } +.day.has-matchups .events-stack { + box-sizing: border-box; + grid-template-rows: repeat(var(--event-count), minmax(0, 1fr)); + gap: 2px; + padding: 2px; +} + .event { --event-top-band: calc(var(--corner-badge-size, 11px) + var(--corner-badge-offset, 2px)); --event-bottom-band: 26px; @@ -275,6 +407,17 @@ body { --event-bg: var(--team-link-color, var(--team-secondary, #8b3f1f)); } +.event.matchup { + display: grid; + grid-template-columns: minmax(0, 1fr); + grid-template-rows: minmax(0, 1fr) auto; + gap: 1px; + min-height: 0; + padding: 2px 3px; + border-radius: 2px; + overflow: hidden; +} + .event-center { position: absolute; top: var(--event-top-band); @@ -293,6 +436,17 @@ body { text-align: center; } +.event.matchup .event-center { + position: relative; + top: auto; + left: auto; + right: auto; + bottom: auto; + min-height: 0; + align-items: center; + justify-content: center; +} + .event-center img { width: auto; height: var(--event-logo-height); @@ -315,6 +469,8 @@ body { hyphens: none; line-height: 1.05; font-weight: 700; + font-stretch: condensed; + font-variation-settings: "wdth" 42, "wght" 700; opacity: 0.85; } @@ -322,10 +478,38 @@ body { font-family: var(--pc-font-display); font-weight: 700; font-variation-settings: "wdth" 30, "wght" 700; - letter-spacing: -0.01em; text-transform: uppercase; } +.matchup-name { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 0; + padding: 0; + font-size: calc(8.5px * var(--month-font-scale)); + line-height: 0.98; + font-variation-settings: "wdth" 36, "wght" 800; + opacity: 1; +} + +.matchup-vs { + font-size: 0.66em; + font-weight: 900; + opacity: 0.78; +} + +.matchup-team { + display: block; + width: 100%; + overflow: hidden; + text-align: center; + text-overflow: clip; + white-space: nowrap; + font-stretch: condensed; +} + .ha-flag { position: absolute; top: var(--corner-badge-offset, 2px); @@ -341,7 +525,7 @@ body { font-weight: 900; font-variation-settings: "wdth" 84, "wght" 900; line-height: 1; - letter-spacing: -0.01em; + letter-spacing: 0; background: #111; color: #fff; } @@ -366,11 +550,26 @@ body { overflow: hidden; } +.event.matchup .event-meta { + position: relative; + left: auto; + right: auto; + bottom: auto; + display: grid; + grid-template-columns: minmax(0, auto) minmax(0, 1fr); + align-items: center; + justify-content: center; + column-gap: 3px; + padding: 0; +} + .event-time { order: 1; max-width: 100%; font-size: calc(12px * var(--month-font-scale)); font-weight: 800; + font-stretch: condensed; + font-variation-settings: "wdth" 56, "wght" 800; line-height: 1; text-transform: uppercase; text-align: center; @@ -381,11 +580,19 @@ body { opacity: 0.95; } +.event.matchup .event-time { + min-width: 0; + font-size: calc(7.5px * var(--month-font-scale)); + font-weight: 900; +} + .event-venue { order: 2; max-width: 100%; font-size: calc(8px * var(--month-font-scale)); font-weight: 700; + font-stretch: condensed; + font-variation-settings: "wdth" 50, "wght" 700; line-height: 1; text-align: center; text-transform: uppercase; @@ -395,6 +602,12 @@ body { opacity: 0.88; } +.event.matchup .event-venue { + min-width: 0; + font-size: calc(7px * var(--month-font-scale)); + text-align: left; +} + .empty { padding: 16px; border: 2px dashed #c8d2de; @@ -472,6 +685,100 @@ body { background: #fff; } +body.black-white .header, +body.black-white .month-title, +body.black-white .dow span, +body.black-white .day, +body.black-white .event, +body.black-white .empty, +body.black-white .footer-meta, +body.black-white .footer-qr-image { + border-color: #2f3337 !important; +} + +body.black-white .month-title, +body.black-white .ha-flag { + background: #1f2328 !important; + color: #fff !important; + text-shadow: none !important; +} + +body.black-white .dow span, +body.black-white .day, +body.black-white .day.muted, +body.black-white .day.no-events, +body.black-white .day.has-matchups, +body.black-white .empty, +body.black-white .legend-item, +body.black-white .event.a .ha-flag { + background: #f7f7f7 !important; + color: #111 !important; + text-shadow: none !important; +} + +body.black-white .dow span { + background: #e4e7eb !important; +} + +body.black-white .day, +body.black-white .day.has-matchups, +body.black-white .legend-item { + background: #fff !important; +} + +body.black-white .event, +body.black-white .event.h, +body.black-white .event.a, +body.black-white .event.matchup { + background: #e4e7eb !important; + color: #111 !important; + text-shadow: none !important; +} + +body.black-white .day.muted, +body.black-white .day.no-events { + background: #f2f3f5 !important; + color: #4b5563 !important; +} + +body.black-white .month-title, +body.black-white .dow span, +body.black-white .day, +body.black-white .event { + border: 1px solid #2f3337; +} + +body.black-white .day-num, +body.black-white .day.has-events .day-num, +body.black-white .day.has-matchups .day-num, +body.black-white.month-pages .day .day-num { + background: #fff !important; + color: #111 !important; + box-shadow: 0 0 0 1px #2f3337 !important; + text-shadow: none !important; +} + +body.black-white .ha-flag, +body.black-white .event.a .ha-flag { + box-shadow: 0 0 0 1px #2f3337; +} + +body.black-white .event-name, +body.black-white .event-time, +body.black-white .event-venue, +body.black-white .matchup-vs, +body.black-white .footer-qr-label, +body.black-white .footer-qr-link, +body.black-white .meta { + color: #111 !important; + opacity: 1 !important; +} + +body.black-white .meta, +body.black-white .footer-qr-label { + color: #374151 !important; +} + @media print { body, body.print-preview { @@ -487,6 +794,7 @@ body { width: auto; min-height: auto; box-shadow: none; + transform: none; } .print-page { @@ -500,4 +808,27 @@ body { .title { font-size: calc(26px * var(--month-font-scale)); } + + body.month-pages .sheet-grid { + display: block; + } + + body.month-pages .month-page { + break-after: page; + page-break-after: always; + } + + body.month-pages .month-page:last-child { + break-after: auto; + page-break-after: auto; + } + + body.month-pages .month { + width: 100%; + } + + body.month-pages .grid { + break-inside: avoid; + page-break-inside: avoid; + } } diff --git a/includes/sp-event-export.php b/includes/sp-event-export.php index 3e82472..851a683 100644 --- a/includes/sp-event-export.php +++ b/includes/sp-event-export.php @@ -62,7 +62,9 @@ function tse_sp_event_export_get_column_definitions() { 'time' => __( 'Time', 'tonys-sportspress-enhancements' ), 'season' => __( 'Season', 'tonys-sportspress-enhancements' ), 'league' => __( 'League', 'tonys-sportspress-enhancements' ), + 'title' => __( 'Title', 'tonys-sportspress-enhancements' ), 'team_name' => __( 'Team', 'tonys-sportspress-enhancements' ), + 'separator' => __( 'Separator', 'tonys-sportspress-enhancements' ), 'opponent_name' => __( 'Opponent', 'tonys-sportspress-enhancements' ), 'location_flag' => __( 'Home/Away', 'tonys-sportspress-enhancements' ), 'field_name' => __( 'Field Name', 'tonys-sportspress-enhancements' ), @@ -85,12 +87,33 @@ function tse_sp_event_export_get_column_definitions() { function tse_sp_event_export_get_default_columns( $format ) { $defaults = array( 'matchup' => array( 'date', 'time', 'season', 'league', 'away_team', 'home_team', 'field_name' ), - 'team' => array( 'label', 'date', 'time', 'season', 'league', 'opponent_name', 'location_flag', 'field_name' ), + 'team' => array( 'label', 'date', 'time', 'season', 'league', 'title', 'field_name' ), ); return isset( $defaults[ $format ] ) ? $defaults[ $format ] : $defaults['matchup']; } +/** + * Get supported event title formats. + * + * @return string[] + */ +function tse_sp_event_export_get_title_formats() { + return array( 'selected_first', 'matchup' ); +} + +/** + * Sanitize event title format. + * + * @param string $format Raw title format. + * @return string + */ +function tse_sp_event_export_sanitize_title_format( $format ) { + $format = sanitize_key( (string) $format ); + + return in_array( $format, tse_sp_event_export_get_title_formats(), true ) ? $format : 'selected_first'; +} + /** * Sanitize an export format. * @@ -173,24 +196,26 @@ function tse_sp_event_export_parse_id_list( $value ) { * @return array */ function tse_sp_event_export_normalize_request_args( $source = null ) { - $source = is_array( $source ) ? $source : $_GET; - $format = isset( $source['format'] ) ? tse_sp_event_export_sanitize_format( wp_unslash( $source['format'] ) ) : 'matchup'; - $team_ids = isset( $source['team_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['team_id'] ) ) : array(); - $season_ids = isset( $source['season_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['season_id'] ) ) : array(); - $league_ids = isset( $source['league_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['league_id'] ) ) : array(); - $field_ids = isset( $source['field_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['field_id'] ) ) : array(); + $source = is_array( $source ) ? $source : $_GET; + $format = isset( $source['format'] ) ? tse_sp_event_export_sanitize_format( wp_unslash( $source['format'] ) ) : 'matchup'; + $team_ids = isset( $source['team_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['team_id'] ) ) : array(); + $season_ids = isset( $source['season_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['season_id'] ) ) : array(); + $league_ids = isset( $source['league_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['league_id'] ) ) : array(); + $field_ids = isset( $source['field_id'] ) ? tse_sp_event_export_parse_id_list( wp_unslash( $source['field_id'] ) ) : array(); + $title_format = isset( $source['title_format'] ) ? tse_sp_event_export_sanitize_title_format( wp_unslash( $source['title_format'] ) ) : 'selected_first'; return array( - 'team_id' => isset( $team_ids[0] ) ? $team_ids[0] : 0, - 'team_ids' => $team_ids, - 'season_id' => isset( $season_ids[0] ) ? $season_ids[0] : 0, - 'season_ids'=> $season_ids, - 'league_id' => isset( $league_ids[0] ) ? $league_ids[0] : 0, - 'league_ids'=> $league_ids, - 'field_id' => isset( $field_ids[0] ) ? $field_ids[0] : 0, - 'field_ids' => $field_ids, - 'format' => $format, - 'columns' => isset( $source['columns'] ) ? tse_sp_event_export_sanitize_columns( $format, wp_unslash( $source['columns'] ) ) : tse_sp_event_export_get_default_columns( $format ), + 'team_id' => isset( $team_ids[0] ) ? $team_ids[0] : 0, + 'team_ids' => $team_ids, + 'season_id' => isset( $season_ids[0] ) ? $season_ids[0] : 0, + 'season_ids' => $season_ids, + 'league_id' => isset( $league_ids[0] ) ? $league_ids[0] : 0, + 'league_ids' => $league_ids, + 'field_id' => isset( $field_ids[0] ) ? $field_ids[0] : 0, + 'field_ids' => $field_ids, + 'format' => $format, + 'title_format' => $title_format, + 'columns' => isset( $source['columns'] ) ? tse_sp_event_export_sanitize_columns( $format, wp_unslash( $source['columns'] ) ) : tse_sp_event_export_get_default_columns( $format ), ); } @@ -212,9 +237,6 @@ function tse_sp_event_export_validate_filters( $filters ) { wp_die( esc_html__( 'Team format requires a team filter.', 'tonys-sportspress-enhancements' ), '', array( 'response' => 400 ) ); } - if ( count( $team_ids ) > 1 ) { - wp_die( esc_html__( 'Team format does not support multiple teams.', 'tonys-sportspress-enhancements' ), '', array( 'response' => 400 ) ); - } } /** @@ -294,11 +316,10 @@ function tse_sp_event_export_query_posts( $filters ) { * @return array */ function tse_sp_event_export_get_events( $filters ) { - $team_id = isset( $filters['team_id'] ) ? absint( $filters['team_id'] ) : 0; $selected_ids = isset( $filters['team_ids'] ) && is_array( $filters['team_ids'] ) ? array_values( array_filter( array_map( 'absint', $filters['team_ids'] ) ) ) : array(); - $query_posts = tse_sp_event_export_query_posts( $filters ); - $events = array(); - $team_name = $team_id > 0 ? get_the_title( $team_id ) : ''; + $title_format = tse_sp_event_export_sanitize_title_format( isset( $filters['title_format'] ) ? $filters['title_format'] : 'selected_first' ); + $query_posts = tse_sp_event_export_query_posts( $filters ); + $events = array(); foreach ( $query_posts as $event ) { $event_id = $event instanceof WP_Post ? (int) $event->ID : 0; @@ -314,21 +335,22 @@ function tse_sp_event_export_get_events( $filters ) { $home_id = isset( $teams[0] ) ? (int) $teams[0] : 0; $away_id = isset( $teams[1] ) ? (int) $teams[1] : 0; $venue = tse_sp_event_export_get_primary_field( $event_id ); + $context = tse_sp_event_export_get_team_context( $home_id, $away_id, $selected_ids ); - if ( $team_id > 0 ) { - $location_flag = $home_id === $team_id ? 'Home' : 'Away'; - $opponent_id = $home_id === $team_id ? $away_id : $home_id; - } else { - $location_flag = ''; - $opponent_id = 0; - } + $context_team_id = isset( $context['team_id'] ) ? (int) $context['team_id'] : 0; + $opponent_id = isset( $context['opponent_id'] ) ? (int) $context['opponent_id'] : 0; + $separator = isset( $context['separator'] ) ? (string) $context['separator'] : ''; + $location_flag = isset( $context['location_flag'] ) ? (string) $context['location_flag'] : ''; + $title = tse_sp_event_export_get_event_title_value( $home_id, $away_id, $selected_ids, $title_format ); $events[] = array( 'event_id' => $event_id, 'label' => '', 'date' => get_post_time( 'm/d/Y', false, $event_id, true ), 'time' => strtoupper( (string) ( function_exists( 'sp_get_time' ) ? sp_get_time( $event_id ) : get_post_time( get_option( 'time_format' ), false, $event_id, true ) ) ), - 'team_name' => is_string( $team_name ) ? $team_name : '', + 'title' => $title, + 'team_name' => $context_team_id > 0 ? get_the_title( $context_team_id ) : '', + 'separator' => $separator, 'opponent_name' => $opponent_id > 0 ? get_the_title( $opponent_id ) : '', 'location_flag' => $location_flag, 'home_team' => $home_id > 0 ? get_the_title( $home_id ) : '', @@ -352,6 +374,100 @@ function tse_sp_event_export_get_events( $filters ) { return $events; } +/** + * Resolve a display title for a schedule event. + * + * @param int $home_id Home team ID. + * @param int $away_id Away team ID. + * @param int[] $selected_ids Selected team IDs. + * @param string $title_format Title format. + * @return string + */ +function tse_sp_event_export_get_event_title_value( $home_id, $away_id, $selected_ids, $title_format ) { + $home_id = absint( $home_id ); + $away_id = absint( $away_id ); + $selected_ids = array_values( array_filter( array_map( 'absint', (array) $selected_ids ) ) ); + $title_format = tse_sp_event_export_sanitize_title_format( $title_format ); + + if ( 'matchup' === $title_format ) { + return tse_sp_event_export_join_title_parts( $away_id, 'at', $home_id ); + } + + $context = tse_sp_event_export_get_team_context( $home_id, $away_id, $selected_ids ); + if ( empty( $context['team_id'] ) ) { + return ''; + } + + if ( 1 === count( $selected_ids ) ) { + $opponent_id = isset( $context['opponent_id'] ) ? (int) $context['opponent_id'] : 0; + return $opponent_id > 0 ? get_the_title( $opponent_id ) : ''; + } + + return tse_sp_event_export_join_title_parts( + isset( $context['team_id'] ) ? (int) $context['team_id'] : 0, + isset( $context['separator'] ) ? (string) $context['separator'] : '', + isset( $context['opponent_id'] ) ? (int) $context['opponent_id'] : 0 + ); +} + +/** + * Join two team names with a title separator. + * + * @param int $first_id First team ID. + * @param string $separator Separator. + * @param int $second_id Second team ID. + * @return string + */ +function tse_sp_event_export_join_title_parts( $first_id, $separator, $second_id ) { + $first_name = $first_id > 0 ? get_the_title( $first_id ) : ''; + $second_name = $second_id > 0 ? get_the_title( $second_id ) : ''; + $parts = array_values( array_filter( array( $first_name, trim( $separator ), $second_name ), 'strlen' ) ); + + return implode( ' ', $parts ); +} + +/** + * Resolve the team-layout perspective for an event. + * + * The selected team is always first. If both selected teams are in the game, + * use the away team first and the home team second. + * + * @param int $home_id Home team ID. + * @param int $away_id Away team ID. + * @param int[] $selected_ids Selected team IDs. + * @return array + */ +function tse_sp_event_export_get_team_context( $home_id, $away_id, $selected_ids ) { + $home_id = absint( $home_id ); + $away_id = absint( $away_id ); + $selected_ids = array_values( array_filter( array_map( 'absint', (array) $selected_ids ) ) ); + + if ( $away_id > 0 && in_array( $away_id, $selected_ids, true ) ) { + return array( + 'team_id' => $away_id, + 'opponent_id' => $home_id, + 'separator' => 'at', + 'location_flag' => 'Away', + ); + } + + if ( $home_id > 0 && in_array( $home_id, $selected_ids, true ) ) { + return array( + 'team_id' => $home_id, + 'opponent_id' => $away_id, + 'separator' => 'vs', + 'location_flag' => 'Home', + ); + } + + return array( + 'team_id' => 0, + 'opponent_id' => 0, + 'separator' => '', + 'location_flag' => '', + ); +} + /** * Get event term names as a semicolon-delimited string. * @@ -476,25 +592,22 @@ function tse_sp_event_export_fold_ical_line( $line ) { * @return string */ function tse_sp_event_export_get_ical_summary( $event, $filters ) { - $format = tse_sp_event_export_sanitize_format( isset( $filters['format'] ) ? $filters['format'] : 'matchup' ); - $team_ids = isset( $filters['team_ids'] ) && is_array( $filters['team_ids'] ) ? array_values( array_filter( array_map( 'absint', $filters['team_ids'] ) ) ) : array(); - $team_id = isset( $team_ids[0] ) ? $team_ids[0] : 0; + $format = tse_sp_event_export_sanitize_format( isset( $filters['format'] ) ? $filters['format'] : 'matchup' ); + $team_ids = isset( $filters['team_ids'] ) && is_array( $filters['team_ids'] ) ? array_values( array_filter( array_map( 'absint', $filters['team_ids'] ) ) ) : array(); + $title_format = tse_sp_event_export_sanitize_title_format( isset( $filters['title_format'] ) ? $filters['title_format'] : 'selected_first' ); + $team_id = isset( $team_ids[0] ) ? $team_ids[0] : 0; if ( 'team' === $format && $team_id > 0 ) { $teams = array_values( array_unique( array_map( 'intval', get_post_meta( $event->ID, 'sp_team', false ) ) ) ); $home_id = isset( $teams[0] ) ? (int) $teams[0] : 0; $away_id = isset( $teams[1] ) ? (int) $teams[1] : 0; + $context = tse_sp_event_export_get_team_context( $home_id, $away_id, $team_ids ); - if ( in_array( $team_id, $teams, true ) ) { - $is_home = $home_id === $team_id; - $opponent_id = $is_home ? $away_id : $home_id; - $opponent = $opponent_id > 0 ? get_the_title( $opponent_id ) : __( 'TBD', 'tonys-sportspress-enhancements' ); - $summary = sprintf( - /* translators: 1: preposition, 2: opponent name. */ - __( '%1$s %2$s', 'tonys-sportspress-enhancements' ), - $is_home ? 'vs' : 'at', - $opponent - ); + if ( ! empty( $context['team_id'] ) ) { + $summary = tse_sp_event_export_get_event_title_value( $home_id, $away_id, $team_ids, $title_format ); + if ( '' === $summary ) { + $summary = $event->post_title; + } return apply_filters( 'sportspress_ical_feed_summary', $summary, $event ); } @@ -915,13 +1028,14 @@ function tse_sp_event_export_get_feed_url( $args = array(), $feed_type = 'csv' ) $filters = tse_sp_event_export_normalize_request_args( $args ); $feed = 'ics' === sanitize_key( $feed_type ) ? 'sp-ics' : 'sp-csv'; $query = array( - 'feed' => $feed, - 'format' => $filters['format'], - 'team_id' => ! empty( $filters['team_ids'] ) ? implode( ',', $filters['team_ids'] ) : '', - 'season_id' => ! empty( $filters['season_ids'] ) ? implode( ',', $filters['season_ids'] ) : '', - 'league_id' => ! empty( $filters['league_ids'] ) ? implode( ',', $filters['league_ids'] ) : '', - 'field_id' => ! empty( $filters['field_ids'] ) ? implode( ',', $filters['field_ids'] ) : '', - 'columns' => implode( ',', $filters['columns'] ), + 'feed' => $feed, + 'format' => $filters['format'], + 'team_id' => ! empty( $filters['team_ids'] ) ? implode( ',', $filters['team_ids'] ) : '', + 'season_id' => ! empty( $filters['season_ids'] ) ? implode( ',', $filters['season_ids'] ) : '', + 'league_id' => ! empty( $filters['league_ids'] ) ? implode( ',', $filters['league_ids'] ) : '', + 'field_id' => ! empty( $filters['field_ids'] ) ? implode( ',', $filters['field_ids'] ) : '', + 'title_format' => isset( $filters['title_format'] ) ? tse_sp_event_export_sanitize_title_format( $filters['title_format'] ) : 'selected_first', + 'columns' => implode( ',', $filters['columns'] ), ); return add_query_arg( array_filter( $query, 'strlen' ), home_url( '/' ) ); diff --git a/includes/sp-printable-calendars.php b/includes/sp-printable-calendars.php index a0dc180..73b3a82 100644 --- a/includes/sp-printable-calendars.php +++ b/includes/sp-printable-calendars.php @@ -146,8 +146,14 @@ if ( ! class_exists( 'Tony_Sportspress_Printable_Calendars' ) ) { $vars[] = 'sp_team'; $vars[] = 'sp_season'; $vars[] = 'sp_league'; + $vars[] = 'sp_field'; + $vars[] = 'team_label'; + $vars[] = 'field_label'; + $vars[] = 'title_format'; $vars[] = 'paper'; $vars[] = 'autoprint'; + $vars[] = 'month_pages'; + $vars[] = 'black_white'; return $vars; } @@ -221,16 +227,24 @@ if ( ! class_exists( 'Tony_Sportspress_Printable_Calendars' ) ) { $this->default_settings() ); - $current = wp_parse_args( - is_array( $input ) ? $input : array(), - $existing - ); + $current = is_array( $input ) ? $input : array(); + $active_season_id = isset( $current['active_season_id'] ) ? absint( (string) $current['active_season_id'] ) : 0; return array( 'calendar_feed_url' => isset( $existing['calendar_feed_url'] ) && is_string( $existing['calendar_feed_url'] ) ? $existing['calendar_feed_url'] : '', 'sync_interval_minutes' => isset( $existing['sync_interval_minutes'] ) ? absint( (string) $existing['sync_interval_minutes'] ) : 60, - 'venue_color_overrides' => $this->sanitize_venue_color_overrides( isset( $current['venue_color_overrides'] ) ? $current['venue_color_overrides'] : array() ), - 'venue_use_team_primary' => $this->sanitize_venue_primary_flags( isset( $current['venue_use_team_primary'] ) ? $current['venue_use_team_primary'] : array() ), + 'venue_color_overrides' => $this->merge_sanitized_season_settings( + isset( $existing['venue_color_overrides'] ) && is_array( $existing['venue_color_overrides'] ) ? $existing['venue_color_overrides'] : array(), + $this->sanitize_venue_color_overrides( isset( $current['venue_color_overrides'] ) ? $current['venue_color_overrides'] : array() ), + $active_season_id, + true + ), + 'venue_use_team_primary' => $this->merge_sanitized_season_settings( + isset( $existing['venue_use_team_primary'] ) && is_array( $existing['venue_use_team_primary'] ) ? $existing['venue_use_team_primary'] : array(), + $this->sanitize_venue_primary_flags( isset( $current['venue_use_team_primary'] ) ? $current['venue_use_team_primary'] : array() ), + $active_season_id, + false + ), 'printable_venue_label_mode' => $this->sanitize_venue_label_mode( isset( $current['printable_venue_label_mode'] ) ? $current['printable_venue_label_mode'] : '' ), ); } @@ -322,6 +336,7 @@ if ( ! class_exists( 'Tony_Sportspress_Printable_Calendars' ) ) { echo '