Add option to hide player/staff details close #144
This commit is contained in:
@@ -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' ),
|
||||
|
||||
@@ -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' ),
|
||||
|
||||
@@ -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 ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $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,7 +78,9 @@ endif;
|
||||
|
||||
$data = apply_filters( 'sportspress_player_details', $data, $id );
|
||||
|
||||
if ( sizeof( $data ) ) {
|
||||
if ( empty( $data ) )
|
||||
return;
|
||||
|
||||
$output = '<div class="sp-template sp-template-player-details sp-template-details"><div class="sp-list-wrapper"><dl class="sp-player-details">';
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
@@ -86,4 +92,3 @@ if ( sizeof( $data ) ) {
|
||||
$output .= '</dl></div></div>';
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
@@ -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 ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $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 = '<div class="sp-list-wrapper">' .
|
||||
'<dl class="sp-staff-details">';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user