From 13cb8cbada5912547b703fcb4b190311de29192b Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 22 Oct 2014 18:51:25 +1100 Subject: [PATCH] Add options to toggle individual templates per post type --- .../settings/class-sp-settings-events.php | 90 +++-- .../settings/class-sp-settings-players.php | 17 + .../settings/class-sp-settings-staff.php | 17 + .../settings/class-sp-settings-teams.php | 33 ++ includes/sp-template-functions.php | 60 ++- includes/sp-template-hooks.php | 24 +- templates/event-details.php | 1 + templates/event-logos.php | 31 +- templates/event-performance.php | 344 +++++++++--------- templates/event-results.php | 1 + templates/event-venue.php | 1 + templates/player-details.php | 10 +- templates/staff-details.php | 7 +- templates/team-link.php | 1 + 14 files changed, 404 insertions(+), 233 deletions(-) diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php index df131b8b..8fd71e03 100644 --- a/includes/admin/settings/class-sp-settings-events.php +++ b/includes/admin/settings/class-sp-settings-events.php @@ -47,13 +47,61 @@ class SP_Settings_Events extends SP_Settings_Page { 'id' => 'sportspress_link_events', 'default' => 'yes', 'type' => 'checkbox', + ), + + array( + 'title' => __( 'Display', 'sportspress' ), + 'desc' => __( 'Logos', 'sportspress' ), + 'id' => 'sportspress_event_show_logos', + 'default' => 'yes', + 'type' => 'checkbox', 'checkboxgroup' => 'start', ), array( - 'desc' => __( 'Link venues', 'sportspress' ), - 'id' => 'sportspress_link_venues', - 'default' => 'no', + 'desc' => __( 'Results', 'sportspress' ), + 'id' => 'sportspress_event_show_results', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Details', 'sportspress' ), + 'id' => 'sportspress_event_show_details', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Venue', 'sportspress' ), + 'id' => 'sportspress_event_show_venue', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Players', 'sportspress' ), + 'id' => 'sportspress_event_show_players', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Staff', 'sportspress' ), + 'id' => 'sportspress_event_show_staff', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Total', 'sportspress' ), + 'id' => 'sportspress_event_show_total', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end', ), @@ -73,31 +121,6 @@ class SP_Settings_Events extends SP_Settings_Page { array( 'type' => 'delimiter' ), - array( - 'title' => __( 'Teams', 'sportspress' ), - 'desc' => __( 'Display logos', 'sportspress' ), - 'id' => 'sportspress_event_show_logos', - 'default' => 'yes', - 'type' => 'checkbox', - 'checkboxgroup' => 'start', - ), - - array( - 'desc' => __( 'Display players', 'sportspress' ), - 'id' => 'sportspress_event_show_players', - 'default' => 'yes', - 'type' => 'checkbox', - 'checkboxgroup' => '', - ), - - array( - 'desc' => __( 'Display total', 'sportspress' ), - 'id' => 'sportspress_event_show_total', - 'default' => 'no', - 'type' => 'checkbox', - 'checkboxgroup' => 'end', - ), - array( 'title' => __( 'Player Performance', 'sportspress' ), 'id' => 'sportspress_event_performance_mode', @@ -110,7 +133,7 @@ class SP_Settings_Events extends SP_Settings_Page { ), array( - 'title' => __( 'Venue', 'sportspress' ), + 'title' => __( 'Venues', 'sportspress' ), 'desc' => __( 'Display maps', 'sportspress' ), 'id' => 'sportspress_event_show_maps', 'default' => 'yes', @@ -119,12 +142,11 @@ class SP_Settings_Events extends SP_Settings_Page { ), array( - 'title' => __( 'Staff', 'sportspress' ), - 'desc' => __( 'Display staff', 'sportspress' ), - 'id' => 'sportspress_event_show_staff', - 'default' => 'yes', + 'desc' => __( 'Link venues', 'sportspress' ), + 'id' => 'sportspress_link_venues', + 'default' => 'no', 'type' => 'checkbox', - 'checkboxgroup' => 'start', + 'checkboxgroup' => 'end', ), array( diff --git a/includes/admin/settings/class-sp-settings-players.php b/includes/admin/settings/class-sp-settings-players.php index d02fd922..5aa1a225 100644 --- a/includes/admin/settings/class-sp-settings-players.php +++ b/includes/admin/settings/class-sp-settings-players.php @@ -46,6 +46,23 @@ class SP_Settings_Players extends SP_Settings_Page { 'type' => 'checkbox', ), + array( + 'title' => __( 'Display', 'sportspress' ), + 'desc' => __( 'Photo', 'sportspress' ), + 'id' => 'sportspress_player_show_photo', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + ), + + array( + 'desc' => __( 'Details', 'sportspress' ), + 'id' => 'sportspress_player_show_details', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + ), + array( 'title' => __( 'Nationality', 'sportspress' ), 'desc' => __( 'Display national flags', 'sportspress' ), diff --git a/includes/admin/settings/class-sp-settings-staff.php b/includes/admin/settings/class-sp-settings-staff.php index 195cf5ee..8dfc45d3 100644 --- a/includes/admin/settings/class-sp-settings-staff.php +++ b/includes/admin/settings/class-sp-settings-staff.php @@ -48,6 +48,23 @@ class SP_Settings_Staff extends SP_Settings_Page { 'type' => 'checkbox', ), + array( + 'title' => __( 'Display', 'sportspress' ), + 'desc' => __( 'Photo', 'sportspress' ), + 'id' => 'sportspress_staff_show_photo', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + ), + + array( + 'desc' => __( 'Details', 'sportspress' ), + 'id' => 'sportspress_staff_show_details', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + ), + array( 'title' => __( 'Nationality', 'sportspress' ), 'desc' => __( 'Display national flags', 'sportspress' ), diff --git a/includes/admin/settings/class-sp-settings-teams.php b/includes/admin/settings/class-sp-settings-teams.php index 2456fb7b..fb9ef40b 100644 --- a/includes/admin/settings/class-sp-settings-teams.php +++ b/includes/admin/settings/class-sp-settings-teams.php @@ -48,6 +48,39 @@ class SP_Settings_Teams extends SP_Settings_Page { 'type' => 'checkbox', ), + array( + 'title' => __( 'Display', 'sportspress' ), + 'desc' => __( 'Logo', 'sportspress' ), + 'id' => 'sportspress_team_show_logo', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + ), + + array( + 'desc' => __( 'Details', 'sportspress' ), + 'id' => 'sportspress_team_show_details', + 'default' => 'no', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Visit Site', 'sportspress' ), + 'id' => 'sportspress_team_show_link', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + ), + + array( + 'title' => __( 'Venue', 'sportspress' ), + 'desc' => __( 'Link venues', 'sportspress' ), + 'id' => 'sportspress_team_link_venues', + 'default' => 'no', + 'type' => 'checkbox', + ), + array( 'title' => __( 'Abbreviation', 'sportspress' ), 'desc' => __( 'Abbreviate team names', 'sportspress' ), diff --git a/includes/sp-template-functions.php b/includes/sp-template-functions.php index 465e59f1..59a89f05 100644 --- a/includes/sp-template-functions.php +++ b/includes/sp-template-functions.php @@ -186,6 +186,32 @@ if ( ! function_exists( 'sportspress_output_team_link' ) ) { sp_get_template( 'team-link.php' ); } } +if ( ! function_exists( 'sportspress_output_team_logo' ) ) { + + /** + * Output the team logo. + * + * @access public + * @subpackage Team/Logo + * @return void + */ + function sportspress_output_team_logo() { + sp_get_template( 'team-logo.php' ); + } +} +if ( ! function_exists( 'sportspress_output_team_details' ) ) { + + /** + * Output the team details. + * + * @access public + * @subpackage Team/Details + * @return void + */ + function sportspress_output_team_details() { + sp_get_template( 'team-details.php' ); + } +} if ( ! function_exists( 'sportspress_output_team_tables' ) ) { /** @@ -231,13 +257,26 @@ if ( ! function_exists( 'sportspress_output_league_table' ) ) { /** Single Player ********************************************************/ +if ( ! function_exists( 'sportspress_output_player_photo' ) ) { + + /** + * Output the player photo. + * + * @access public + * @subpackage Player/Photo + * @return void + */ + function sportspress_output_player_photo() { + sp_get_template( 'player-photo.php' ); + } +} if ( ! function_exists( 'sportspress_output_player_details' ) ) { /** - * Output the player metrics. + * Output the player details. * * @access public - * @subpackage Player/Metrics + * @subpackage Player/Details * @return void */ function sportspress_output_player_details() { @@ -281,13 +320,26 @@ if ( ! function_exists( 'sportspress_output_player_list' ) ) { /** Single Staff ********************************************************/ +if ( ! function_exists( 'sportspress_output_staff_photo' ) ) { + + /** + * Output the staff photo. + * + * @access public + * @subpackage Staff/Photo + * @return void + */ + function sportspress_output_staff_photo() { + sp_get_template( 'staff-photo.php' ); + } +} if ( ! function_exists( 'sportspress_output_staff_details' ) ) { /** - * Output the staff metrics. + * Output the staff details. * * @access public - * @subpackage Staff/Metrics + * @subpackage Staff/Details * @return void */ function sportspress_output_staff_details() { diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index e4c013ee..f0a5f98d 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -30,8 +30,9 @@ add_action( 'get_the_generator_xhtml', 'sp_generator_tag', 10, 2 ); * @see sportspress_output_event_details() * @see sportspress_output_event_venue() * @see sportspress_output_event_performance() + * @see sportspress_output_br_tag() */ -add_action( 'sportspress_single_event_content', 'sportspress_output_event_logos', 5 ); +add_action( 'sportspress_single_event_content', 'sportspress_output_event_logos', 0 ); add_action( 'sportspress_single_event_content', 'sportspress_output_event_video', 10 ); add_action( 'sportspress_single_event_content', 'sportspress_output_event_results', 20 ); add_action( 'sportspress_single_event_content', 'sportspress_output_event_details', 30 ); @@ -43,6 +44,7 @@ add_action( 'sportspress_single_event_content', 'sportspress_output_br_tag', 100 * Single Calendar Content * * @see sportspress_output_calendar() + * @see sportspress_output_br_tag() */ add_action( 'sportspress_single_calendar_content', 'sportspress_output_calendar', 10 ); add_action( 'sportspress_single_calendar_content', 'sportspress_output_br_tag', 100 ); @@ -50,20 +52,29 @@ add_action( 'sportspress_single_calendar_content', 'sportspress_output_br_tag', /** * Single Team Content * - * @see sportspress_output_team_link() - * @see sportspress_output_team_tables() + * @see sportspress_output_team_logo() + * @see sportspress_output_team_details() * @see sportspress_output_team_lists() + * @see sportspress_output_team_tables() + * @see sportspress_output_br_tag() */ +add_action( 'sportspress_single_team_content', 'sportspress_output_team_logo', 0 ); +add_action( 'sportspress_single_team_content', 'sportspress_output_team_details', 10 ); add_action( 'sportspress_single_team_content', 'sportspress_output_team_lists', 20 ); add_action( 'sportspress_single_team_content', 'sportspress_output_team_tables', 30 ); add_action( 'sportspress_single_team_content', 'sportspress_output_br_tag', 100 ); +/** + * After Single Team + * @see sportspress_output_team_link() + */ add_action( 'sportspress_after_single_team', 'sportspress_output_team_link', 10 ); /** * Single Table Content * * @see sportspress_output_league_table() + * @see sportspress_output_br_tag() */ add_action( 'sportspress_single_table_content', 'sportspress_output_league_table', 10 ); add_action( 'sportspress_single_table_content', 'sportspress_output_br_tag', 100 ); @@ -71,9 +82,12 @@ add_action( 'sportspress_single_table_content', 'sportspress_output_br_tag', 100 /** * Single Player Content * + * @see sportspress_output_player_photo() * @see sportspress_output_player_details() * @see sportspress_output_player_statistics() + * @see sportspress_output_br_tag() */ +add_action( 'sportspress_single_player_content', 'sportspress_output_player_photo', 0 ); add_action( 'sportspress_single_player_content', 'sportspress_output_player_details', 10 ); add_action( 'sportspress_single_player_content', 'sportspress_output_player_statistics', 20 ); add_action( 'sportspress_single_player_content', 'sportspress_output_br_tag', 100 ); @@ -82,6 +96,7 @@ add_action( 'sportspress_single_player_content', 'sportspress_output_br_tag', 10 * Single List Content * * @see sportspress_output_player_list() + * @see sportspress_output_br_tag() */ add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 ); add_action( 'sportspress_single_list_content', 'sportspress_output_br_tag', 100 ); @@ -89,8 +104,11 @@ add_action( 'sportspress_single_list_content', 'sportspress_output_br_tag', 100 /** * Single Staff Content * + * @see sportspress_output_staff_photo() * @see sportspress_output_staff_details() + * @see sportspress_output_br_tag() */ +add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_photo', 0 ); add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_details', 10 ); add_action( 'sportspress_single_staff_content', 'sportspress_output_br_tag', 100 ); diff --git a/templates/event-details.php b/templates/event-details.php index 251a337a..11abcb40 100644 --- a/templates/event-details.php +++ b/templates/event-details.php @@ -8,6 +8,7 @@ */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( get_option( 'sportspress_event_show_details', 'yes' ) === 'no' ) return; if ( ! isset( $id ) ) $id = get_the_ID(); diff --git a/templates/event-logos.php b/templates/event-logos.php index 77225bb4..875f390c 100644 --- a/templates/event-logos.php +++ b/templates/event-logos.php @@ -8,24 +8,25 @@ */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( get_option( 'sportspress_event_show_logos', 'yes' ) === 'no' ) return; if ( ! isset( $id ) ) $id = get_the_ID(); -if ( get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ): - $teams = get_post_meta( $id, 'sp_team' ); - $teams = array_filter( $teams ); - if ( $teams ): - $team_logos = array(); - foreach ( $teams as $team ): - $team_logos[] = get_the_post_thumbnail( $team, 'sportspress-fit-icon' ); - endforeach; - $team_logos = array_filter( $team_logos ); - if ( ! empty( $team_logos ) ): - echo '
'; - $delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' ); - echo implode( ' ' . $delimiter . ' ', $team_logos ); - echo '
'; - endif; +$teams = get_post_meta( $id, 'sp_team' ); +$teams = array_filter( $teams ); +if ( $teams ): + $team_logos = array(); + foreach ( $teams as $team ): + $logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' ); + if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ) $logo = '' . $logo . ''; + $team_logos[] = $logo; + endforeach; + $team_logos = array_filter( $team_logos ); + if ( ! empty( $team_logos ) ): + echo '
'; + $delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' ); + echo implode( ' ' . $delimiter . ' ', $team_logos ); + echo '
'; endif; endif; \ No newline at end of file diff --git a/templates/event-performance.php b/templates/event-performance.php index f7da6f0c..458c59db 100644 --- a/templates/event-performance.php +++ b/templates/event-performance.php @@ -9,39 +9,46 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +$show_players = get_option( 'sportspress_event_show_players', 'yes' ) === 'yes' ? true : false; +$show_staff = get_option( 'sportspress_event_show_staff', 'yes' ) === 'yes' ? true : false; +$show_total = get_option( 'sportspress_event_show_total', 'yes' ) === 'yes' ? true : false; + +if ( ! $show_players && ! $show_staff && ! $show_total ) return; + if ( ! isset( $id ) ) $id = get_the_ID(); -$event = new SP_Event( $id ); -$performance = $event->performance(); - -// The first row should be column labels -$labels = $performance[0]; - -// Remove the first row to leave us with the actual data -unset( $performance[0] ); - -$performance = array_filter( $performance ); - $teams = get_post_meta( $id, 'sp_team', false ); -$status = $event->status(); - -$show_players = get_option( 'sportspress_event_show_players', 'yes' ) == 'yes' ? true : false; -$link_posts = get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false; -$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false; -$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; -$mode = get_option( 'sportspress_event_performance_mode', 'values' ); - -// Get performance ids for icons -if ( $mode == 'icons' ): - $performance_ids = array(); - $performance_posts = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'sp_performance' ) ); - foreach ( $performance_posts as $post ): - $performance_ids[ $post->post_name ] = $post->ID; - endforeach; -endif; if ( is_array( $teams ) ): + + $event = new SP_Event( $id ); + $performance = $event->performance(); + + // The first row should be column labels + $labels = $performance[0]; + + // Remove the first row to leave us with the actual data + unset( $performance[0] ); + + $performance = array_filter( $performance ); + + $status = $event->status(); + + $link_posts = get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false; + $scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false; + $responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; + $mode = get_option( 'sportspress_event_performance_mode', 'values' ); + + // Get performance ids for icons + if ( $mode == 'icons' ): + $performance_ids = array(); + $performance_posts = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'sp_performance' ) ); + foreach ( $performance_posts as $post ): + $performance_ids[ $post->post_name ] = $post->ID; + endforeach; + endif; + foreach( $teams as $index => $team_id ): if ( ! $team_id ) continue; @@ -49,10 +56,7 @@ if ( is_array( $teams ) ): $players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index ); $has_players = sizeof( $players ) > 1; - if ( ! $has_players ): - if ( $status != 'results' ) continue; - elseif ( get_option( 'sportspress_event_show_total', 'yes' ) != 'yes' ) continue; - endif; + $show_players = $show_players && $has_players; $totals = array(); @@ -62,157 +66,159 @@ if ( is_array( $teams ) ):

$id, 'index' => $index ) ); endif; ?> -
- - - - - - - - $label ): ?> - - - - - - - - - +
+
# 
+ + + + + + + $label ): ?> + + + + + + + + + $sub ): - if ( ! $sub_id ) - continue; - $lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id; - endforeach; - - $i = 0; - foreach( $data as $player_id => $row ): - - if ( ! $player_id ) - continue; - - $name = get_the_title( $player_id ); - - if ( ! $name ) - continue; - - echo ''; - - $number = sp_array_value( $row, 'number', ' ' ); - - // Player number - echo ''; - - if ( $link_posts ): - $permalink = get_post_permalink( $player_id ); - $name = '' . $name . ''; - if ( isset( $row['status'] ) && $row['status'] == 'sub' ): - $name = '(' . $name . ')'; - endif; - endif; - - if ( array_key_exists( $player_id, $lineup_sub_relation ) ): - $name .= ' ' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . ''; - elseif ( isset( $row['sub'] ) && $row['sub'] ): - $name .= ' ' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . ''; - endif; - - echo ''; - - if ( $mode == 'icons' ) echo ''; + + $number = sp_array_value( $row, 'number', ' ' ); + + // Player number + echo ''; + + if ( $link_posts ): + $permalink = get_post_permalink( $player_id ); + $name = '' . $name . ''; + if ( isset( $row['status'] ) && $row['status'] == 'sub' ): + $name = '(' . $name . ')'; endif; - else: - if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + endif; + + if ( array_key_exists( $player_id, $lineup_sub_relation ) ): + $name .= ' ' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . ''; + elseif ( isset( $row['sub'] ) && $row['sub'] ): + $name .= ' ' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . ''; + endif; + + echo ''; + + if ( $mode == 'icons' ) echo ''; + elseif ( intval( $value ) && $mode == 'icons' ): + $performance_id = sp_array_value( $performance_ids, $key, null ); + if ( $performance_id && has_post_thumbnail( $performance_id ) ): + echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); + endif; + endif; + endforeach; + + if ( $mode == 'icons' ) echo ''; + + echo ''; + + $i++; + + endforeach; + ?> + + + + <> + +  '; + echo ''; + endif; + + $row = $data[0]; + + if ( $mode == 'icons' ) echo ''; - elseif ( intval( $value ) && $mode == 'icons' ): - $performance_id = sp_array_value( $performance_ids, $key, null ); - if ( $performance_id && has_post_thumbnail( $performance_id ) ): - echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); + if ( $mode == 'values' ): + echo ''; + elseif ( intval( $value ) && $mode == 'icons' ): + $performance_id = sp_array_value( $performance_ids, $key, null ); + if ( $performance_id && has_post_thumbnail( $performance_id ) ): + echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); + endif; endif; - endif; - endforeach; - - if ( $mode == 'icons' ) echo ''; + endforeach; - echo ''; - - $i++; - - endforeach; - ?> - - - - <> - -  '; - echo ''; - endif; - - $row = $data[0]; - - if ( $mode == 'icons' ) echo ''; - elseif ( intval( $value ) && $mode == 'icons' ): - $performance_id = sp_array_value( $performance_ids, $key, null ); - if ( $performance_id && has_post_thumbnail( $performance_id ) ): - echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); - endif; - endif; - endforeach; - - if ( $mode == 'icons' ) echo ''; - ?> - - > - -
# 
' . $number . '' . $name . ''; - - foreach( $labels as $key => $label ): - if ( $key == 'name' ) + $lineup_sub_relation = array(); + foreach ( $subs as $sub_id => $sub ): + if ( ! $sub_id ) continue; - $value = '—'; - if ( $key == 'position' ): - if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $position = get_term_by( 'id', $row[ $key ], 'sp_position' ); - if ( $position ) $value = $position->name; + $lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id; + endforeach; + + $i = 0; + foreach( $data as $player_id => $row ): + + if ( ! $player_id ) + continue; + + $name = get_the_title( $player_id ); + + if ( ! $name ) + continue; + + echo '
' . $number . '' . $name . ''; + + foreach( $labels as $key => $label ): + if ( $key == 'name' ) + continue; + $value = '—'; + if ( $key == 'position' ): + if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $position = get_term_by( 'id', $row[ $key ], 'sp_position' ); + if ( $position ) $value = $position->name; + endif; + else: + if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $value = $row[ $key ]; + else: + $value = 0; + endif; + endif; + if ( ! array_key_exists( $key, $totals ) ): + $totals[ $key ] = 0; + endif; + $totals[ $key ] += $value; + + if ( $mode == 'values' ): + echo '' . $value . '
' . __( 'Total', 'sportspress' ) . ''; + + foreach( $labels as $key => $label ): + if ( $key == 'name' ) + continue; + if ( $key == 'position' ): + $value = '—'; + elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): $value = $row[ $key ]; else: - $value = 0; + $value = sp_array_value( $totals, $key, 0 ); endif; - endif; - if ( ! array_key_exists( $key, $totals ) ): - $totals[ $key ] = 0; - endif; - $totals[ $key ] += $value; - if ( $mode == 'values' ): - echo '' . $value . '' . $value . '
' . __( 'Total', 'sportspress' ) . ''; - - foreach( $labels as $key => $label ): - if ( $key == 'name' ) - continue; - if ( $key == 'position' ): - $value = '—'; - elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $value = $row[ $key ]; - else: - $value = sp_array_value( $totals, $key, 0 ); - endif; - - if ( $mode == 'values' ): - echo '' . $value . '
-
+ if ( $mode == 'icons' ) echo ''; + ?> + + > + + +
+ ' . - '
'; +$output = '
'; foreach( $data as $label => $value ): - $output .= '
' . $label . '
' . $value . '
'; + $output .= '
' . $label . '
' . $value . '
'; endforeach; -$output .= '
'; +$output .= '
'; echo $output; diff --git a/templates/staff-details.php b/templates/staff-details.php index 2b139737..4013b08b 100644 --- a/templates/staff-details.php +++ b/templates/staff-details.php @@ -4,10 +4,11 @@ * * @author ThemeBoy * @package SportsPress/Templates - * @version 0.8 + * @version 1.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( get_option( 'sportspress_staff_show_details', 'yes' ) === 'no' ) return; if ( ! isset( $id ) ) $id = get_the_ID(); @@ -48,12 +49,12 @@ $output = '
' . foreach( $data as $label => $value ): - $output .= '
' . $label . '
' . $value . '
'; + $output .= '
' . $label . '
' . $value . '
'; endforeach; $output .= '
'; ?> -
+
\ No newline at end of file diff --git a/templates/team-link.php b/templates/team-link.php index e4c138d6..24f893a4 100644 --- a/templates/team-link.php +++ b/templates/team-link.php @@ -8,6 +8,7 @@ */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( get_option( 'sportspress_team_show_link', 'yes' ) === 'no' ) return; if ( ! isset( $id ) ) $id = get_the_ID();