Update schedule exporter and bump version to 0.1.9
Some checks failed
Release Plugin Zip / release (push) Has been cancelled
Some checks failed
Release Plugin Zip / release (push) Has been cancelled
This commit is contained in:
@@ -53,6 +53,7 @@ function tse_sp_event_export_get_column_definitions() {
|
||||
'away_team' => __( 'Away Team', 'tonys-sportspress-enhancements' ),
|
||||
'home_team' => __( 'Home Team', 'tonys-sportspress-enhancements' ),
|
||||
'field_name' => __( 'Field Name', 'tonys-sportspress-enhancements' ),
|
||||
'field_address' => __( 'Field Address', 'tonys-sportspress-enhancements' ),
|
||||
'officials' => __( 'Officials', 'tonys-sportspress-enhancements' ),
|
||||
),
|
||||
'team' => array(
|
||||
@@ -65,6 +66,7 @@ function tse_sp_event_export_get_column_definitions() {
|
||||
'opponent_name' => __( 'Opponent', 'tonys-sportspress-enhancements' ),
|
||||
'location_flag' => __( 'Home/Away', 'tonys-sportspress-enhancements' ),
|
||||
'field_name' => __( 'Field Name', 'tonys-sportspress-enhancements' ),
|
||||
'field_address' => __( 'Field Address', 'tonys-sportspress-enhancements' ),
|
||||
'field_abbreviation' => __( 'Field Abbreviation', 'tonys-sportspress-enhancements' ),
|
||||
'field_short_name' => __( 'Field Short Name', 'tonys-sportspress-enhancements' ),
|
||||
'officials' => __( 'Officials', 'tonys-sportspress-enhancements' ),
|
||||
@@ -332,6 +334,7 @@ function tse_sp_event_export_get_events( $filters ) {
|
||||
'home_team' => $home_id > 0 ? get_the_title( $home_id ) : '',
|
||||
'away_team' => $away_id > 0 ? get_the_title( $away_id ) : '',
|
||||
'field_name' => isset( $venue['name'] ) ? $venue['name'] : '',
|
||||
'field_address' => isset( $venue['address'] ) ? $venue['address'] : '',
|
||||
'field_abbreviation' => isset( $venue['abbreviation'] ) ? $venue['abbreviation'] : '',
|
||||
'field_short_name' => isset( $venue['short_name'] ) ? $venue['short_name'] : '',
|
||||
'season' => tse_sp_event_export_get_event_term_names( $event_id, 'sp_season' ),
|
||||
@@ -380,15 +383,18 @@ function tse_sp_event_export_get_primary_field( $event_id ) {
|
||||
if ( ! is_array( $venues ) || ! isset( $venues[0] ) || ! $venues[0] instanceof WP_Term ) {
|
||||
return array(
|
||||
'name' => '',
|
||||
'address' => '',
|
||||
'abbreviation' => '',
|
||||
'short_name' => '',
|
||||
);
|
||||
}
|
||||
|
||||
$venue = $venues[0];
|
||||
$meta = get_option( 'taxonomy_' . $venue->term_id );
|
||||
|
||||
return array(
|
||||
'name' => isset( $venue->name ) ? (string) $venue->name : '',
|
||||
'address' => is_array( $meta ) && isset( $meta['sp_address'] ) ? trim( (string) $meta['sp_address'] ) : '',
|
||||
'abbreviation' => trim( (string) get_term_meta( $venue->term_id, 'tse_abbreviation', true ) ),
|
||||
'short_name' => trim( (string) get_term_meta( $venue->term_id, 'tse_short_name', true ) ),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* SportsPress schedule exporter admin page.
|
||||
* SportsPress schedule exporter frontend and shared helpers.
|
||||
*
|
||||
* @package Tonys_Sportspress_Enhancements
|
||||
*/
|
||||
@@ -9,22 +9,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the schedule exporter admin page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tse_sp_schedule_exporter_add_admin_page() {
|
||||
add_submenu_page(
|
||||
'sportspress',
|
||||
__( 'Schedule Exporter', 'tonys-sportspress-enhancements' ),
|
||||
__( 'Schedule Exporter', 'tonys-sportspress-enhancements' ),
|
||||
'manage_sportspress',
|
||||
'tse-schedule-exporter',
|
||||
'tse_sp_schedule_exporter_render_admin_page'
|
||||
);
|
||||
}
|
||||
add_action( 'admin_menu', 'tse_sp_schedule_exporter_add_admin_page' );
|
||||
add_shortcode( 'tse_schedule_exporter', 'tse_sp_schedule_exporter_render_shortcode' );
|
||||
add_action( 'init', 'tse_sp_schedule_exporter_register_block' );
|
||||
|
||||
@@ -91,175 +75,6 @@ function tse_sp_schedule_exporter_register_block() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the schedule exporter page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tse_sp_schedule_exporter_render_admin_page() {
|
||||
if ( ! current_user_can( 'manage_sportspress' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$leagues = tse_sp_schedule_exporter_get_leagues();
|
||||
$league_id = tse_sp_schedule_exporter_resolve_league_id( $leagues );
|
||||
$seasons = tse_sp_schedule_exporter_get_seasons();
|
||||
$season_id = tse_sp_schedule_exporter_resolve_season_id( $seasons );
|
||||
$teams = tse_sp_schedule_exporter_get_teams( $league_id, $season_id );
|
||||
$team_id = tse_sp_schedule_exporter_resolve_team_id( $teams );
|
||||
$fields = tse_sp_schedule_exporter_get_fields();
|
||||
$field_id = tse_sp_schedule_exporter_resolve_field_id( $fields );
|
||||
$export_type = tse_sp_schedule_exporter_resolve_export_type();
|
||||
$subformat = tse_sp_schedule_exporter_resolve_subformat();
|
||||
|
||||
echo '<div class="wrap">';
|
||||
echo '<h1>' . esc_html__( 'Schedule Exporter', 'tonys-sportspress-enhancements' ) . '</h1>';
|
||||
echo '<p>' . esc_html__( 'Choose filters once, then generate the CSV feed, iCal link, or printable page URL from the same controls.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
|
||||
echo '<form method="get" action="' . esc_url( admin_url( 'admin.php' ) ) . '" class="tse-schedule-exporter-form" style="max-width:720px;margin:20px 0 28px;">';
|
||||
echo '<input type="hidden" name="page" value="tse-schedule-exporter" />';
|
||||
echo '<div>';
|
||||
|
||||
echo '<div style="margin-bottom:16px;">';
|
||||
echo '<label for="tse-schedule-exporter-export-type"><strong>' . esc_html__( 'Format', 'tonys-sportspress-enhancements' ) . '</strong></label><br />';
|
||||
echo '<select id="tse-schedule-exporter-export-type" name="export_type">';
|
||||
foreach ( tse_sp_schedule_exporter_get_export_types() as $type_key => $type_label ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( $type_key ),
|
||||
selected( $export_type, $type_key, false ),
|
||||
esc_html( $type_label )
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<p class="description">' . esc_html__( 'CSV builds a feed URL, iCal Link builds a subscription URL, and Printable opens the printable page.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div data-subformat-wrap="1" style="margin-bottom:16px;">';
|
||||
echo '<label for="tse-schedule-exporter-subformat"><strong>' . esc_html__( 'CSV Layout', 'tonys-sportspress-enhancements' ) . '</strong></label><br />';
|
||||
echo '<select id="tse-schedule-exporter-subformat" name="subformat">';
|
||||
foreach ( tse_sp_event_export_get_formats() as $format_key => $format_definition ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( $format_key ),
|
||||
selected( $subformat, $format_key, false ),
|
||||
esc_html( $format_definition['label'] )
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<p class="description">' . esc_html__( 'Matchup is away vs home. Team is opponent-based and requires one specific team.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div style="margin-bottom:16px;">';
|
||||
echo '<label for="tse-schedule-exporter-league"><strong>' . esc_html__( 'League', 'tonys-sportspress-enhancements' ) . '</strong></label><br />';
|
||||
echo '<select id="tse-schedule-exporter-league" name="league_id" data-auto-submit="1">';
|
||||
foreach ( $leagues as $league ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( (string) $league->term_id ),
|
||||
selected( $league_id, (int) $league->term_id, false ),
|
||||
esc_html( $league->name )
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div style="margin-bottom:16px;">';
|
||||
echo '<label for="tse-schedule-exporter-season"><strong>' . esc_html__( 'Season', 'tonys-sportspress-enhancements' ) . '</strong></label><br />';
|
||||
echo '<select id="tse-schedule-exporter-season" name="season_id" data-auto-submit="1">';
|
||||
echo '<option value="0">' . esc_html__( 'Current / All matching events', 'tonys-sportspress-enhancements' ) . '</option>';
|
||||
foreach ( $seasons as $season ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( (string) $season->term_id ),
|
||||
selected( $season_id, (int) $season->term_id, false ),
|
||||
esc_html( $season->name )
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div style="margin-bottom:16px;">';
|
||||
echo '<label for="tse-schedule-exporter-team"><strong>' . esc_html__( 'Team', 'tonys-sportspress-enhancements' ) . '</strong></label><br />';
|
||||
echo '<select id="tse-schedule-exporter-team" name="team_id">';
|
||||
echo '<option value="0">' . esc_html__( 'All teams', 'tonys-sportspress-enhancements' ) . '</option>';
|
||||
foreach ( $teams as $team ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( (string) $team->ID ),
|
||||
selected( $team_id, (int) $team->ID, false ),
|
||||
esc_html( $team->post_title )
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<p class="description">' . esc_html__( 'Teams are filtered by the selected league and season.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div style="margin-bottom:16px;">';
|
||||
echo '<label for="tse-schedule-exporter-field"><strong>' . esc_html__( 'Field', 'tonys-sportspress-enhancements' ) . '</strong></label><br />';
|
||||
echo '<select id="tse-schedule-exporter-field" name="field_id">';
|
||||
echo '<option value="0">' . esc_html__( 'All fields', 'tonys-sportspress-enhancements' ) . '</option>';
|
||||
foreach ( $fields as $field ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( (string) $field->term_id ),
|
||||
selected( $field_id, (int) $field->term_id, false ),
|
||||
esc_html( $field->name )
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<p class="description">' . esc_html__( 'Use the field filter to narrow the feed to a specific venue.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
if ( empty( $teams ) ) {
|
||||
echo '<div class="notice notice-warning inline"><p>' . esc_html__( 'No SportsPress teams match the selected league and season.', 'tonys-sportspress-enhancements' ) . '</p></div>';
|
||||
echo '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div style="max-width:960px;padding:20px 24px;border:1px solid #dcdcde;background:#fff;">';
|
||||
echo '<h2 style="margin-top:0;">' . esc_html__( 'Output URL', 'tonys-sportspress-enhancements' ) . '</h2>';
|
||||
echo '<p>' . esc_html__( 'The generated URL below updates from the shared controls above.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
|
||||
tse_sp_schedule_exporter_render_column_picker( 'matchup', 'admin', $subformat );
|
||||
tse_sp_schedule_exporter_render_column_picker( 'team', 'admin', $subformat );
|
||||
|
||||
$base_args = array(
|
||||
'league_id' => $league_id,
|
||||
'team_id' => $team_id,
|
||||
'season_id' => $season_id,
|
||||
'field_id' => $field_id,
|
||||
'format' => $subformat,
|
||||
);
|
||||
$csv_url = tse_sp_event_export_get_feed_url( $base_args, 'csv' );
|
||||
$ics_url = tse_sp_event_export_get_feed_url(
|
||||
array(
|
||||
'league_id' => $league_id,
|
||||
'team_id' => $team_id,
|
||||
'season_id' => $season_id,
|
||||
'field_id' => $field_id,
|
||||
),
|
||||
'ics'
|
||||
);
|
||||
$print_url = tse_sp_schedule_exporter_get_printable_url( $team_id, $season_id, 'letter', $league_id );
|
||||
$current_url = tse_sp_schedule_exporter_get_output_url( $export_type, $csv_url, $ics_url, $print_url );
|
||||
|
||||
echo '<div style="display:flex;align-items:center;gap:8px;max-width:100%;margin-top:16px;">';
|
||||
echo '<input type="text" class="large-text code tse-output-url" readonly="readonly" value="' . esc_attr( $current_url ) . '" />';
|
||||
echo '<button type="button" class="button tse-copy-link" title="' . esc_attr__( 'Copy URL', 'tonys-sportspress-enhancements' ) . '">' . esc_html__( 'Copy URL', 'tonys-sportspress-enhancements' ) . '</button>';
|
||||
echo '<button type="button" class="button button-primary tse-open-link" data-csv-url="' . esc_url( $csv_url ) . '" data-ics-url="' . esc_url( $ics_url ) . '" data-print-url="' . esc_url( $print_url ) . '" title="' . esc_attr__( 'Open URL in new tab', 'tonys-sportspress-enhancements' ) . '">' . esc_html__( 'Open URL in New Tab', 'tonys-sportspress-enhancements' ) . '</button>';
|
||||
echo '<button type="button" class="button button-primary tse-ics-ios-link" data-ics-url="' . esc_url( $ics_url ) . '" title="' . esc_attr__( 'Subscribe on iPhone or iPad', 'tonys-sportspress-enhancements' ) . '" style="display:none;">' . esc_html__( 'Subscribe on iPhone/iPad', 'tonys-sportspress-enhancements' ) . '</button>';
|
||||
echo '<button type="button" class="button tse-ics-android-link" data-ics-url="' . esc_url( $ics_url ) . '" title="' . esc_attr__( 'Subscribe on Android', 'tonys-sportspress-enhancements' ) . '" style="display:none;">' . esc_html__( 'Subscribe on Android', 'tonys-sportspress-enhancements' ) . '</button>';
|
||||
echo '</div>';
|
||||
echo '<p class="description tse-output-note">' . esc_html__( 'Use the buttons to copy the generated URL or open the right destination for this export type.', 'tonys-sportspress-enhancements' ) . '</p>';
|
||||
tse_sp_schedule_exporter_render_link_sync_script( true );
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the public shortcode.
|
||||
*
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
* Text Domain: tonys-sportspress-enhancements
|
||||
* Domain Path: /languages
|
||||
* Update URI: https://github.com/anthonyscorrea/tonys-sportspress-enhancements
|
||||
* Version: 0.1.8
|
||||
* Version: 0.1.9
|
||||
*
|
||||
* @package Tonys_Sportspress_Enhancements
|
||||
*/
|
||||
|
||||
if ( ! defined( 'TONY_SPORTSPRESS_ENHANCEMENTS_VERSION' ) ) {
|
||||
define( 'TONY_SPORTSPRESS_ENHANCEMENTS_VERSION', '0.1.8' );
|
||||
define( 'TONY_SPORTSPRESS_ENHANCEMENTS_VERSION', '0.1.9' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'TONY_SPORTSPRESS_ENHANCEMENTS_FILE' ) ) {
|
||||
|
||||
Reference in New Issue
Block a user