diff --git a/admin/globals/formats.php b/admin/globals/formats.php index de1cf000..6e3e97e7 100644 --- a/admin/globals/formats.php +++ b/admin/globals/formats.php @@ -7,6 +7,9 @@ function sportspress_define_formats_global() { $sportspress_formats['event']['league'] = __( 'League', 'sportspress' ); $sportspress_formats['event']['friendly'] = __( 'Friendly', 'sportspress' ); + $sportspress_formats['calendar']['calendar'] = __( 'Calendar', 'sportspress' ); + $sportspress_formats['calendar']['list'] = __( 'List', 'sportspress' ); + $sportspress_formats['list']['list'] = __( 'List', 'sportspress' ); $sportspress_formats['list']['gallery'] = __( 'Gallery', 'sportspress' ); } diff --git a/admin/hooks/save-post.php b/admin/hooks/save-post.php index 996f7633..eb473994 100644 --- a/admin/hooks/save-post.php +++ b/admin/hooks/save-post.php @@ -5,6 +5,7 @@ function sportspress_save_post( $post_id ) { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], SPORTSPRESS_PLUGIN_BASENAME ) ) return $post_id; switch ( $_POST['post_type'] ): + case ( 'sp_team' ): // Update leagues seasons to show @@ -50,6 +51,25 @@ function sportspress_save_post( $post_id ) { break; + case ( 'sp_calendar' ): + + // Update format + update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'calendar' ) ); + + // Update league taxonomy + wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' ); + + // Update season taxonomy + wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); + + // Update venue taxonomy + wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' ); + + // Update team + update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', 0 ) ); + + break; + case ( 'sp_result' ): // Delete posts with duplicate key diff --git a/admin/post-types/calendar.php b/admin/post-types/calendar.php new file mode 100644 index 00000000..407a5676 --- /dev/null +++ b/admin/post-types/calendar.php @@ -0,0 +1,156 @@ + __( 'Calendars', 'sportspress' ), + 'singular_name' => __( 'Calendar', 'sportspress' ), + 'add_new_item' => __( 'Add New Calendar', 'sportspress' ), + 'edit_item' => __( 'Edit Calendar', 'sportspress' ), + 'new_item' => __( 'New', 'sportspress' ), + 'view_item' => __( 'View', 'sportspress' ), + 'search_items' => __( 'Search', 'sportspress' ), + 'not_found' => __( 'No results found.', 'sportspress' ), + 'not_found_in_trash' => __( 'No results found.', 'sportspress' ), + ); + $args = array( + 'label' => __( 'Calendars', 'sportspress' ), + 'labels' => $labels, + 'public' => true, + 'has_archive' => false, + 'hierarchical' => false, + 'supports' => array( 'title', 'author', 'thumbnail' ), + 'register_meta_box_cb' => 'sportspress_calendar_meta_init', + 'rewrite' => array( 'slug' => get_option( 'sp_calendar_slug', 'calendar' ) ), + 'show_in_menu' => 'edit.php?post_type=sp_event', + 'show_in_admin_bar' => true, + 'capability_type' => 'sp_calendar' + ); + register_post_type( 'sp_calendar', $args ); +} +add_action( 'init', 'sportspress_calendar_post_init' ); + +function sportspress_calendar_edit_columns() { + $columns = array( + 'cb' => '', + 'title' => __( 'Title', 'sportspress' ), + 'sp_league' => __( 'League', 'sportspress' ), + 'sp_season' => __( 'Season', 'sportspress' ), + 'sp_venue' => __( 'Venue', 'sportspress' ), + 'sp_team' => __( 'Teams', 'sportspress' ), + 'sp_events' => __( 'Events', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), + ); + return $columns; +} +add_filter( 'manage_edit-sp_calendar_columns', 'sportspress_calendar_edit_columns' ); + +function sportspress_calendar_meta_init( $post ) { + $teams = (array)get_post_meta( $post->ID, 'sp_team', false ); + + remove_meta_box( 'sp_seasondiv', 'sp_calendar', 'side' ); + remove_meta_box( 'sp_leaguediv', 'sp_calendar', 'side' ); + remove_meta_box( 'sp_venuediv', 'sp_calendar', 'side' ); + add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'sportspress_calendar_format_meta', 'sp_calendar', 'side', 'high' ); + add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_calendar_details_meta', 'sp_calendar', 'side', 'default' ); + add_meta_box( 'sp_columnsdiv', __( 'Events', 'sportspress' ), 'sportspress_calendar_events_meta', 'sp_calendar', 'normal', 'high' ); + add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'sportspress_calendar_description_meta', 'sp_calendar', 'normal', 'high' ); +} + +function sportspress_calendar_format_meta( $post ) { + global $sportspress_formats; + $the_format = get_post_meta( $post->ID, 'sp_format', true ); + ?> +
+
+ __( 'All', 'sportspress' ), + 'taxonomy' => 'sp_league', + 'name' => 'sp_league', + 'selected' => $league_id, + 'values' => 'term_id' + ); + if ( ! sportspress_dropdown_taxonomies( $args ) ): + sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) ); + endif; + ?> +
++
+ __( 'All', 'sportspress' ), + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', + 'selected' => $season_id, + 'values' => 'term_id' + ); + if ( ! sportspress_dropdown_taxonomies( $args ) ): + sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) ); + endif; + ?> +
++
+ __( 'All', 'sportspress' ), + 'taxonomy' => 'sp_venue', + 'name' => 'sp_venue', + 'selected' => $venue_id, + 'values' => 'term_id' + ); + if ( ! sportspress_dropdown_taxonomies( $args ) ): + sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) ); + endif; + ?> +
++
+ __( 'All', 'sportspress' ), + 'post_type' => 'sp_team', + 'name' => 'sp_team', + 'selected' => $team_id, + 'values' => 'ID' + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) ); + endif; + ?> +
+| + | + | + | + |
|---|---|---|---|
| + | post_title; ?> | ++ | + + + + ID ) ): ?> + + + post_content == null ): + _e( 'None', 'sportspress' ); + elseif ( $event->post_status == 'publish' ): + _e( 'Recap', 'sportspress' ); + else: + _e( 'Preview', 'sportspress' ); + endif; + ?> + + | +
| + + | +|||
| # | @@ -1013,11 +1076,11 @@ if ( !function_exists( 'sportspress_edit_event_results_table' ) ) {
|---|
| - - | + | + $label ): ?> + | - | + |
|---|