diff --git a/actions.php b/actions.php index 27f05645..bf0d720f 100644 --- a/actions.php +++ b/actions.php @@ -16,25 +16,28 @@ function sp_manage_posts_custom_column( $column, $post_id ) { the_post_thumbnail( 'sp_icon' ); break; case 'sp_position': - get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : print '—'; + echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—'; break; case 'sp_team': - get_post_meta ( $post_id, 'sp_team' ) ? sp_the_posts( $post_id, 'sp_team', '', '
' ) : print '—'; + echo get_post_meta ( $post_id, 'sp_team' ) ? sp_the_posts( $post_id, 'sp_team', '', '
' ) : '—'; + break; + case 'sp_event': + echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—'; break; case 'sp_league': - get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : print '—'; + echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—'; break; case 'sp_season': - get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : print '—'; + echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; break; case 'sp_sponsor': - get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : print '—'; + echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—'; break; case 'sp_kickoff': echo get_the_date ( get_option ( 'date_format' ) ) . '
' . get_the_time ( get_option ( 'time_format' ) ); break; case 'sp_address': - echo get_post_meta( $post_id, 'sp_address', true ); + echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—'; break; endswitch; } @@ -43,63 +46,56 @@ add_action( 'manage_pages_custom_column', 'sp_manage_posts_custom_column', 10, 2 function sp_restrict_manage_posts() { global $typenow, $wp_query; - switch ( $typenow ): - case 'sp_player': - - // Teams - $selected = isset( $_REQUEST['sp_team'] ) ? $_REQUEST['sp_team'] : null; - $args = array( - 'show_option_none' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), - 'post_type' => 'sp_team', - 'name' => 'sp_team', - 'selected' => $selected - ); - wp_dropdown_pages( $args ); - - // Positions - $selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ), - 'taxonomy' => 'sp_position', - 'name' => 'sp_position', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Leagues - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Seasons - $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Sponsors - $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ), - 'taxonomy' => 'sp_sponsor', - 'name' => 'sp_sponsor', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - - endswitch; + if ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_calendar', 'sp_tournament' ) ) ): + $selected = isset( $_REQUEST['sp_team'] ) ? $_REQUEST['sp_team'] : null; + $args = array( + 'show_option_none' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), + 'post_type' => 'sp_team', + 'name' => 'sp_team', + 'selected' => $selected + ); + wp_dropdown_pages( $args ); + endif; + if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ): + $selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null; + $args = array( + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ), + 'taxonomy' => 'sp_position', + 'name' => 'sp_position', + 'selected' => $selected + ); + sp_dropdown_taxonomies( $args ); + endif; + if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_calendar' ) ) ): + $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; + $args = array( + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), + 'taxonomy' => 'sp_league', + 'name' => 'sp_league', + 'selected' => $selected + ); + sp_dropdown_taxonomies( $args ); + endif; + if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_calendar' ) ) ): + $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; + $args = array( + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', + 'selected' => $selected + ); + sp_dropdown_taxonomies( $args ); + endif; + if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_tournament', 'sp_venue' ) ) ): + $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; + $args = array( + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ), + 'taxonomy' => 'sp_sponsor', + 'name' => 'sp_sponsor', + 'selected' => $selected + ); + sp_dropdown_taxonomies( $args ); + endif; } add_action( 'restrict_manage_posts', 'sp_restrict_manage_posts' ); diff --git a/calendar.php b/calendar.php index 70c3b1d7..9ec9f564 100644 --- a/calendar.php +++ b/calendar.php @@ -15,7 +15,7 @@ function sp_calendar_cpt_init() { } add_action( 'init', 'sp_calendar_cpt_init' ); -function sp_calendar_edit_columns( $columns ) { +function sp_calendar_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Title' ), @@ -26,34 +26,4 @@ function sp_calendar_edit_columns( $columns ) { return $columns; } add_filter( 'manage_edit-sp_calendar_columns', 'sp_calendar_edit_columns' ); - -function sp_calendar_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_calendar' ) { - - // Leagues - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Seasons - $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - } -} -add_action( 'restrict_manage_posts', 'sp_calendar_request_filter_dropdowns' ); ?> \ No newline at end of file diff --git a/event.php b/event.php index 113f54b9..365e6722 100644 --- a/event.php +++ b/event.php @@ -32,143 +32,25 @@ function sp_event_meta_init() { add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' ); } -function sp_event_team_meta( $post, $metabox ) { - global $post_id; +function sp_event_team_meta( $post ) { $limit = get_option( 'sp_event_team_count' ); for ( $i = 0; $i < $limit; $i++ ): - $selected = array_pad( array_slice( (array)get_post_meta( $post_id, 'sp_team', false ), 0, $limit ), $limit, 0); + $selected = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0); $args = array( 'post_type' => 'sp_team', 'name' => 'sportspress[sp_team][]', 'selected' => $selected[ $i ] ); wp_dropdown_pages( $args ); - echo '
' . PHP_EOL; - /* - $players = unserialize( get_post_meta( $post_id, 'sp_players', true ) ); - ?> -
- -
- -
- -
-
-

- -
- -
- -
-
- - post_content, 'content' ); } -function sp_event_edit_columns( $columns ) { +function sp_event_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Event', 'sportspress' ), @@ -187,44 +69,4 @@ function sp_event_edit_sortable_columns( $columns ) { return $columns; } add_filter( 'manage_edit-sp_event_sortable_columns', 'sp_event_edit_sortable_columns' ); - -function sp_event_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_event' ) { - - // Leagues - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Seasons - $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Sponsors - $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ), - 'taxonomy' => 'sp_sponsor', - 'name' => 'sp_sponsor', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - - } -} -add_action( 'restrict_manage_posts', 'sp_event_request_filter_dropdowns' ); ?> \ No newline at end of file diff --git a/staff.php b/staff.php index 60377e69..27c86ed8 100644 --- a/staff.php +++ b/staff.php @@ -24,17 +24,16 @@ function sp_staff_meta_init() { add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_staff_team_meta', 'sp_staff', 'side', 'high' ); add_meta_box( 'sp_profilediv', __( 'Profile' ), 'sp_staff_profile_meta', 'sp_staff', 'normal', 'high' ); } -function sp_staff_team_meta( $post, $metabox ) { - global $post_id; - sp_post_checklist( $post_id, 'sp_team', true ); +function sp_staff_team_meta( $post ) { + sp_post_checklist( $post->ID, 'sp_team', true ); sp_nonce(); } -function sp_staff_profile_meta( $post, $metabox ) { +function sp_staff_profile_meta( $post ) { wp_editor( $post->post_content, 'content' ); } -function sp_staff_edit_columns( $columns ) { +function sp_staff_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Name', 'sportspress' ), @@ -46,45 +45,4 @@ function sp_staff_edit_columns( $columns ) { return $columns; } add_filter( 'manage_edit-sp_staff_columns', 'sp_staff_edit_columns' ); - -function sp_staff_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_staff' ) { - - // Positions - $selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ), - 'taxonomy' => 'sp_position', - 'name' => 'sp_position', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Leagues - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Seasons - $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - } -} -add_action( 'restrict_manage_posts', 'sp_staff_request_filter_dropdowns' ); ?> \ No newline at end of file diff --git a/table.php b/table.php index 4c61a36f..91749a6d 100644 --- a/table.php +++ b/table.php @@ -15,7 +15,7 @@ function sp_table_cpt_init() { } add_action( 'init', 'sp_table_cpt_init' ); -function sp_table_edit_columns( $columns ) { +function sp_table_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Title' ), @@ -26,34 +26,4 @@ function sp_table_edit_columns( $columns ) { return $columns; } add_filter( 'manage_edit-sp_table_columns', 'sp_table_edit_columns' ); - -function sp_table_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_table' ) { - - // Leagues - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Seasons - $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - } -} -add_action( 'restrict_manage_posts', 'sp_table_request_filter_dropdowns' ); ?> \ No newline at end of file diff --git a/team.php b/team.php index b77bb679..1b8fb295 100644 --- a/team.php +++ b/team.php @@ -23,7 +23,7 @@ function sp_team_meta_init() { add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' ); } -function sp_team_edit_columns($columns) { +function sp_team_edit_columns() { $columns = array( 'cb' => '', 'sp_icon' => ' ', @@ -35,44 +35,4 @@ function sp_team_edit_columns($columns) { return $columns; } add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' ); - -function sp_team_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_team' ) { - - // Leagues - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Seasons - $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - // Sponsors - $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ), - 'taxonomy' => 'sp_sponsor', - 'name' => 'sp_sponsor', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - - } -} -add_action( 'restrict_manage_posts', 'sp_team_request_filter_dropdowns' ); ?> \ No newline at end of file diff --git a/tournament.php b/tournament.php index e8b34767..330c5e47 100644 --- a/tournament.php +++ b/tournament.php @@ -15,7 +15,7 @@ function sp_tournament_cpt_init() { } add_action( 'init', 'sp_tournament_cpt_init' ); -function sp_tournament_edit_columns( $columns ) { +function sp_tournament_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Title' ), @@ -26,44 +26,4 @@ function sp_tournament_edit_columns( $columns ) { return $columns; } add_filter( 'manage_edit-sp_tournament_columns', 'sp_tournament_edit_columns' ); - -function sp_tournament_custom_columns( $column ) { - global $post, $post_id, $typenow; - if ( $typenow == 'sp_tournament' ): - switch ($column): - case 'sp_team': - echo 'TEAMS'; - break; - case 'sp_event': - echo 'EVENTS'; - break; - case 'sp_sponsor': - if ( get_the_terms ( $post_id, 'sp_sponsor' ) ) - the_terms( $post_id, 'sp_sponsor' ); - else - echo '—'; - break; - endswitch; - endif; -} -add_action( 'manage_pages_custom_column', 'sp_tournament_custom_columns' ); - -function sp_tournament_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_tournament' ) { - - // Sponsors - $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), - 'taxonomy' => 'sp_sponsor', - 'name' => 'sp_sponsor', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - echo PHP_EOL; - - } -} -add_action( 'restrict_manage_posts', 'sp_tournament_request_filter_dropdowns' ); ?> \ No newline at end of file diff --git a/venue.php b/venue.php index 48d68686..990dcf9b 100644 --- a/venue.php +++ b/venue.php @@ -15,7 +15,7 @@ function sp_venue_cpt_init() { } add_action( 'init', 'sp_venue_cpt_init' ); -function sp_venue_edit_columns( $columns ) { +function sp_venue_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Venue', 'sportspress' ), @@ -25,22 +25,4 @@ function sp_venue_edit_columns( $columns ) { return $columns; } add_filter( 'manage_edit-sp_venue_columns', 'sp_venue_edit_columns' ); - -function sp_venue_request_filter_dropdowns() { - global $typenow, $wp_query; - if ( $typenow == 'sp_venue' ) { - - // Sponsors - $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; - $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ), - 'taxonomy' => 'sp_sponsor', - 'name' => 'sp_sponsor', - 'selected' => $selected - ); - sp_dropdown_taxonomies( $args ); - - } -} -add_action( 'restrict_manage_posts', 'sp_venue_request_filter_dropdowns' ); ?> \ No newline at end of file