From bb15a05338cbd5a4d48548d812d3eff505c030ec Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 22 Jan 2014 17:33:25 +1100 Subject: [PATCH] Add views counter and style tweaks --- admin/hooks/admin-menu.php | 3 +- ...om-column.php => manage-posts-columns.php} | 9 ++ admin/hooks/the-content.php | 107 +++++++++--------- admin/post-types/calendar.php | 1 + admin/post-types/event.php | 3 +- admin/post-types/list.php | 1 + admin/post-types/player.php | 2 + admin/post-types/staff.php | 1 + admin/post-types/table.php | 1 + admin/post-types/team.php | 1 + admin/templates/league-table.php | 17 ++- admin/templates/player-metrics.php | 4 +- admin/terms/venue.php | 3 +- assets/css/sportspress.css | 6 - assets/js/sportspress.js | 5 +- functions.php | 37 +++--- readme.txt | 76 ++++++++++++- sportspress.php | 6 +- 18 files changed, 190 insertions(+), 93 deletions(-) rename admin/hooks/{manage-posts-custom-column.php => manage-posts-columns.php} (92%) diff --git a/admin/hooks/admin-menu.php b/admin/hooks/admin-menu.php index e6df9674..ba24fdab 100644 --- a/admin/hooks/admin-menu.php +++ b/admin/hooks/admin-menu.php @@ -17,8 +17,9 @@ function sportspress_admin_menu( $position ) { $menu[ $position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' ); endif; - // Remove "Positions" link from Media submenu + // Remove "Venues" and "Positions" link from Media submenu unset( $submenu['upload.php'][17] ); + unset( $submenu['upload.php'][18] ); // Remove "Leagues" link from Players submenu unset( $submenu['edit.php?post_type=sp_player'][15] ); diff --git a/admin/hooks/manage-posts-custom-column.php b/admin/hooks/manage-posts-columns.php similarity index 92% rename from admin/hooks/manage-posts-custom-column.php rename to admin/hooks/manage-posts-columns.php index 309b1d51..aec3038f 100644 --- a/admin/hooks/manage-posts-custom-column.php +++ b/admin/hooks/manage-posts-columns.php @@ -1,10 +1,19 @@ ID ); - $results = sportspress_event_results( $post->ID ); - $players = sportspress_event_players( $post->ID ); - $staff = sportspress_event_staff( $post->ID ); - - if ( ! empty( $results ) ): - $content = $results . $details . $players . $staff . $content; - else: - $venue = sportspress_event_venue( $post->ID ); - $content = $details . $venue . $players . $staff . $content; - endif; - + $content = apply_filters( 'sportspress_event_content', $content ); elseif ( is_singular( 'sp_calendar' ) && in_the_loop() ): - - global $post; - - $calendar = sportspress_events_calendar( $post->ID ); - - $content = $calendar . $content; - + $content = apply_filters( 'sportspress_calendar_content', $content ); elseif ( is_singular( 'sp_team' ) && in_the_loop() ): - - global $post; - - $columns = sportspress_team_columns( $post->ID ); - - $content = $columns . $content; - + $content = apply_filters( 'sportspress_team_content', $content ); elseif ( is_singular( 'sp_table' ) && in_the_loop() ): - - global $post; - - $table = sportspress_league_table( $post->ID ); - - $content = $table . $content; - + $content = apply_filters( 'sportspress_table_content', $content ); elseif ( is_singular( 'sp_list' ) && in_the_loop() ): - - global $post; - - $list = sportspress_player_list( $post->ID ); - - $content = $list . $content; - - + $content = apply_filters( 'sportspress_list_content', $content ); elseif ( is_singular( 'sp_player' ) && in_the_loop() ): - - global $post; - - $metrics = sportspress_player_metrics( $post->ID ); - $statistics = sportspress_player_statistics( $post->ID ); - - $content = $metrics . $statistics . $content; - + $content = apply_filters( 'sportspress_player_content', $content ); endif; return $content; } add_filter( 'the_content', 'sportspress_the_content' ); -add_filter( 'get_the_content', 'sportspress_the_content' ); \ No newline at end of file +add_filter( 'get_the_content', 'sportspress_the_content' ); + +function sportspress_default_event_content( $content ) { + $details = sportspress_event_details( get_the_ID() ); + $results = sportspress_event_results( get_the_ID() ); + $players = sportspress_event_players( get_the_ID() ); + $staff = sportspress_event_staff( get_the_ID() ); + if ( ! empty( $results ) ) + return $results . $details . $players . $staff . $content; + $venue = sportspress_event_venue( get_the_ID() ); + return $details . $venue . $players . $staff . $content; +} +add_filter( 'sportspress_event_content', 'sportspress_default_event_content' ); + +function sportspress_default_calendar_content( $content ) { + $calendar = sportspress_events_calendar( get_the_ID() ); + return $calendar . $content; +} +add_filter( 'sportspress_calendar_content', 'sportspress_default_calendar_content' ); + +function sportspress_default_team_content( $content ) { + $columns = sportspress_team_columns( get_the_ID() ); + return $columns . $content; +} +add_filter( 'sportspress_team_content', 'sportspress_default_team_content' ); + +function sportspress_default_table_content( $content ) { + $table = sportspress_league_table( get_the_ID() ); + $excerpt = has_excerpt() ? '

' . nl2br( get_the_excerpt() ) . '

' : ''; + return $table . $content . $excerpt; +} +add_filter( 'sportspress_table_content', 'sportspress_default_table_content' ); + +function sportspress_default_player_content( $content ) { + $metrics = sportspress_player_metrics( get_the_ID() ); + $statistics = sportspress_player_statistics( get_the_ID() ); + return $metrics . $statistics . $content; +} +add_filter( 'sportspress_player_content', 'sportspress_default_player_content' ); + +function sportspress_default_list_content( $content ) { + $list = sportspress_player_list( get_the_ID() ); + return $list . $content; +} +add_filter( 'sportspress_list_content', 'sportspress_default_list_content' ); diff --git a/admin/post-types/calendar.php b/admin/post-types/calendar.php index 95ac70d4..5c8ceb2f 100644 --- a/admin/post-types/calendar.php +++ b/admin/post-types/calendar.php @@ -27,6 +27,7 @@ function sportspress_calendar_edit_columns() { 'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_season' => __( 'Seasons', 'sportspress' ), 'sp_venue' => __( 'Venues', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), ); return $columns; } diff --git a/admin/post-types/event.php b/admin/post-types/event.php index cb12e27c..d3d127cb 100644 --- a/admin/post-types/event.php +++ b/admin/post-types/event.php @@ -196,7 +196,8 @@ function sportspress_event_edit_columns() { 'sp_league' => __( 'League', 'sportspress' ), 'sp_season' => __( 'Season', 'sportspress' ), 'sp_venue' => __( 'Venue', 'sportspress' ), - 'sp_kickoff' => __( 'Date/Time', 'sportspress' ) + 'sp_kickoff' => __( 'Date/Time', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), ); return $columns; } diff --git a/admin/post-types/list.php b/admin/post-types/list.php index bc9da73e..ca15babc 100644 --- a/admin/post-types/list.php +++ b/admin/post-types/list.php @@ -28,6 +28,7 @@ function sportspress_list_edit_columns() { 'sp_league' => __( 'League', 'sportspress' ), 'sp_season' => __( 'Season', 'sportspress' ), 'sp_team' => __( 'Team', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), ); return $columns; } diff --git a/admin/post-types/player.php b/admin/post-types/player.php index 7759169b..dcdd4529 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -28,6 +28,7 @@ function sportspress_player_edit_columns() { 'sp_team' => __( 'Teams', 'sportspress' ), 'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_season' => __( 'Seasons', 'sportspress' ), + 'sp_views' => __( 'Views', 'sportspress' ), ); return $columns; } @@ -80,6 +81,7 @@ function sportspress_player_details_meta( $post ) {