diff --git a/includes/admin/settings/class-sp-settings-players.php b/includes/admin/settings/class-sp-settings-players.php index d152eaf4..f645fdd2 100644 --- a/includes/admin/settings/class-sp-settings-players.php +++ b/includes/admin/settings/class-sp-settings-players.php @@ -76,6 +76,39 @@ class SP_Settings_Players extends SP_Settings_Page { 'checkboxgroup' => 'end', ), + array( + 'title' => __( 'Details', 'sportspress' ), + 'desc' => __( 'Nationality', 'sportspress' ), + 'id' => 'sportspress_player_show_nationality', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + ), + + array( + 'desc' => __( 'Position', 'sportspress' ), + 'id' => 'sportspress_player_show_positions', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Current Team', 'sportspress' ), + 'id' => 'sportspress_player_show_current_teams', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Past Teams', 'sportspress' ), + 'id' => 'sportspress_player_show_past_teams', + '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 61fd7233..b636753c 100644 --- a/includes/admin/settings/class-sp-settings-staff.php +++ b/includes/admin/settings/class-sp-settings-staff.php @@ -67,6 +67,31 @@ class SP_Settings_Staff extends SP_Settings_Page { 'checkboxgroup' => 'end', ), + array( + 'title' => __( 'Details', 'sportspress' ), + 'desc' => __( 'Nationality', 'sportspress' ), + 'id' => 'sportspress_staff_show_nationality', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + ), + + array( + 'desc' => __( 'Current Team', 'sportspress' ), + 'id' => 'sportspress_staff_show_current_teams', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Past Teams', 'sportspress' ), + 'id' => 'sportspress_staff_show_past_teams', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + ), + array( 'title' => __( 'Nationality', 'sportspress' ), 'desc' => __( 'Display national flags', 'sportspress' ), diff --git a/templates/player-details.php b/templates/player-details.php index 22f76c3e..7ed18d18 100644 --- a/templates/player-details.php +++ b/templates/player-details.php @@ -14,6 +14,10 @@ if ( ! isset( $id ) ) $id = get_the_ID(); $defaults = array( + 'show_nationality' => get_option( 'sportspress_player_show_nationality', 'yes' ) == 'yes' ? true : false, + 'show_positions' => get_option( 'sportspress_player_show_positions', 'yes' ) == 'yes' ? true : false, + 'show_current_teams' => get_option( 'sportspress_player_show_current_teams', 'yes' ) == 'yes' ? true : false, + 'show_past_teams' => get_option( 'sportspress_player_show_past_teams', 'yes' ) == 'yes' ? true : false, 'show_nationality_flags' => get_option( 'sportspress_player_show_flags', 'yes' ) == 'yes' ? true : false, 'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false, ); @@ -32,7 +36,7 @@ $metrics_before = $player->metrics( true ); $metrics_after = $player->metrics( false ); $common = array(); -if ( $nationality ): +if ( $show_nationality && $nationality ): if ( 2 == strlen( $nationality ) ): $legacy = SP()->countries->legacy; $nationality = strtolower( $nationality ); @@ -42,7 +46,7 @@ if ( $nationality ): $common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flags ? '' . $nationality . ' ' : '' ) . $country_name : '—'; endif; -if ( $positions ): +if ( $show_positions && $positions ): $position_names = array(); foreach ( $positions as $position ): $position_names[] = $position->name; @@ -52,7 +56,7 @@ endif; $data = array_merge( $metrics_before, $common, $metrics_after ); -if ( $current_teams ): +if ( $show_current_teams && $current_teams ): $teams = array(); foreach ( $current_teams as $team ): $team_name = get_the_title( $team ); @@ -62,7 +66,7 @@ if ( $current_teams ): $data[ __( 'Current Team', 'sportspress' ) ] = implode( ', ', $teams ); endif; -if ( $past_teams ): +if ( $show_past_teams && $past_teams ): $teams = array(); foreach ( $past_teams as $team ): $team_name = get_the_title( $team ); @@ -74,16 +78,17 @@ endif; $data = apply_filters( 'sportspress_player_details', $data, $id ); -if ( sizeof( $data ) ) { - $output = '
'; +if ( empty( $data ) ) + return; - foreach( $data as $label => $value ): +$output = '
'; - $output .= '
' . $label . '
' . $value . '
'; +foreach( $data as $label => $value ): - endforeach; + $output .= '
' . $label . '
' . $value . '
'; - $output .= '
'; +endforeach; - echo $output; -} +$output .= '
'; + +echo $output; diff --git a/templates/staff-details.php b/templates/staff-details.php index 315244be..ea182249 100644 --- a/templates/staff-details.php +++ b/templates/staff-details.php @@ -14,6 +14,9 @@ if ( ! isset( $id ) ) $id = get_the_ID(); $defaults = array( + 'show_nationality' => get_option( 'sportspress_staff_show_nationality', 'yes' ) == 'yes' ? true : false, + 'show_current_teams' => get_option( 'sportspress_staff_show_current_teams', 'yes' ) == 'yes' ? true : false, + 'show_past_teams' => get_option( 'sportspress_staff_show_past_teams', 'yes' ) == 'yes' ? true : false, 'show_nationality_flags' => get_option( 'sportspress_staff_show_flags', 'yes' ) == 'yes' ? true : false, 'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false, ); @@ -29,7 +32,7 @@ $current_teams = $staff->current_teams(); $past_teams = $staff->past_teams(); $data = array(); -if ( $nationality ): +if ( $show_nationality && $nationality ): if ( 2 == strlen( $nationality ) ): $legacy = SP()->countries->legacy; $nationality = strtolower( $nationality ); @@ -39,7 +42,7 @@ if ( $nationality ): $data[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flags ? '' . $nationality . ' ' : '' ) . $country_name : '—'; endif; -if ( $current_teams ): +if ( $show_current_teams && $current_teams ): $teams = array(); foreach ( $current_teams as $team ): $team_name = get_the_title( $team ); @@ -49,7 +52,7 @@ if ( $current_teams ): $data[ __( 'Current Team', 'sportspress' ) ] = implode( ', ', $teams ); endif; -if ( $past_teams ): +if ( $show_past_teams && $past_teams ): $teams = array(); foreach ( $past_teams as $team ): $team_name = get_the_title( $team ); @@ -61,6 +64,9 @@ endif; $data = apply_filters( 'sportspress_staff_details', $data, $id ); +if ( empty( $data ) ) + return; + $output = '
' . '
';