File "official-details.php"
Full Path: /home/londdqdw/public_html/06/wp-content/plugins/sportspress/templates/official-details.php
File size: 4.57 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Official Details
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 2.7.9
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( get_option( 'sportspress_official_show_details', 'yes' ) === 'no' ) {
return;
}
if ( ! isset( $id ) ) {
$id = get_the_ID();
}
$defaults = array(
'show_number' => get_option( 'sportspress_official_show_number', 'no' ) == 'yes' ? true : false,
'show_name' => get_option( 'sportspress_official_show_name', 'no' ) == 'yes' ? true : false,
'show_nationality' => get_option( 'sportspress_official_show_nationality', 'yes' ) == 'yes' ? true : false,
'show_positions' => get_option( 'sportspress_official_show_positions', 'yes' ) == 'yes' ? true : false,
'show_current_teams' => get_option( 'sportspress_official_show_current_teams', 'yes' ) == 'yes' ? true : false,
'show_past_teams' => get_option( 'sportspress_official_show_past_teams', 'yes' ) == 'yes' ? true : false,
'show_leagues' => get_option( 'sportspress_official_show_leagues', 'no' ) == 'yes' ? true : false,
'show_seasons' => get_option( 'sportspress_official_show_seasons', 'no' ) == 'yes' ? true : false,
'show_nationality_flags' => get_option( 'sportspress_official_show_flags', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
);
extract( $defaults, EXTR_SKIP );
$countries = SP()->countries->countries;
$official = new SP_Official( $id );
$metrics_before = $official->metrics( true );
$metrics_after = $official->metrics( false );
$common = array();
if ( $show_number ) :
$common['#'] = $official->number;
endif;
if ( $show_name ) :
$common[ esc_attr__( 'Name', 'sportspress' ) ] = $official->post->post_title;
endif;
if ( $show_nationality ) :
$nationalities = $official->nationalities();
if ( $nationalities && is_array( $nationalities ) ) :
$values = array();
foreach ( $nationalities as $nationality ) :
$country_name = sp_array_value( $countries, $nationality, null );
$values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '—';
endforeach;
$common[ esc_attr__( 'Nationality', 'sportspress' ) ] = implode( '<br>', $values );
endif;
endif;
if ( $show_positions ) :
$positions = $official->positions();
if ( $positions && is_array( $positions ) ) :
$position_names = array();
foreach ( $positions as $position ) :
$position_names[] = $position->name;
endforeach;
$common[ esc_attr__( 'Position', 'sportspress' ) ] = implode( ', ', $position_names );
endif;
endif;
$data = array_merge( $metrics_before, $common, $metrics_after );
if ( $show_current_teams ) :
$current_teams = $official->current_teams();
if ( $current_teams ) :
$teams = array();
foreach ( $current_teams as $team ) :
$team_name = sp_team_short_name( $team );
if ( $link_teams ) {
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
}
$teams[] = $team_name;
endforeach;
$data[ esc_attr__( 'Current Team', 'sportspress' ) ] = implode( ', ', $teams );
endif;
endif;
if ( $show_past_teams ) :
$past_teams = $official->past_teams();
if ( $past_teams ) :
$teams = array();
foreach ( $past_teams as $team ) :
$team_name = sp_team_short_name( $team );
if ( $link_teams ) {
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
}
$teams[] = $team_name;
endforeach;
$data[ esc_attr__( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
endif;
endif;
if ( $show_leagues ) :
$leagues = $official->leagues();
if ( $leagues && ! is_wp_error( $leagues ) ) :
$terms = array();
foreach ( $leagues as $league ) {
$terms[] = $league->name;
}
$data[ esc_attr__( 'Leagues', 'sportspress' ) ] = implode( ', ', $terms );
endif;
endif;
if ( $show_seasons ) :
$seasons = $official->seasons();
if ( $seasons && ! is_wp_error( $seasons ) ) :
$terms = array();
foreach ( $seasons as $season ) {
$terms[] = $season->name;
}
$data[ esc_attr__( 'Seasons', 'sportspress' ) ] = implode( ', ', $terms );
endif;
endif;
$data = apply_filters( 'sportspress_official_details', $data, $id );
if ( empty( $data ) ) {
return;
}
$output = '<div class="sp-template sp-template-official-details sp-template-details"><div class="sp-list-wrapper"><dl class="sp-official-details">';
foreach ( $data as $label => $value ) :
$output .= '<dt>' . $label . '</dt><dd>' . $value . '</dd>';
endforeach;
$output .= '</dl></div></div>';
echo wp_kses_post( $output );