Display staff profiles close #19
This commit is contained in:
24
includes/class-sp-staff.php
Normal file
24
includes/class-sp-staff.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Staff Class
|
||||||
|
*
|
||||||
|
* The SportsPress staff class handles individual staff data.
|
||||||
|
*
|
||||||
|
* @class SP_Staff
|
||||||
|
* @version 0.8
|
||||||
|
* @package SportsPress/Classes
|
||||||
|
* @category Class
|
||||||
|
* @author ThemeBoy
|
||||||
|
*/
|
||||||
|
class SP_Staff extends SP_Custom_Post {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns past teams
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function past_teams() {
|
||||||
|
return get_post_meta( $this->ID, 'sp_past_team', false );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -248,6 +248,22 @@ if ( ! function_exists( 'sportspress_output_player_list' ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Single Staff ********************************************************/
|
||||||
|
|
||||||
|
if ( ! function_exists( 'sportspress_output_staff_details' ) ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the staff metrics.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @subpackage Staff/Metrics
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function sportspress_output_staff_details() {
|
||||||
|
sp_get_template( 'staff-details.php' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Venue Archive ********************************************************/
|
/** Venue Archive ********************************************************/
|
||||||
|
|
||||||
function sportspress_output_venue_map( $query ) {
|
function sportspress_output_venue_map( $query ) {
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ add_action( 'sportspress_single_player_content', 'sportspress_output_player_stat
|
|||||||
*/
|
*/
|
||||||
add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 );
|
add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single Staff Content
|
||||||
|
*
|
||||||
|
* @see sportspress_output_staff_details()
|
||||||
|
*/
|
||||||
|
add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_details', 10 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Venue Archive Content
|
* Venue Archive Content
|
||||||
*/
|
*/
|
||||||
@@ -89,7 +96,7 @@ function sportspress_the_title( $title, $id ) {
|
|||||||
elseif ( is_singular( 'sp_staff' ) ):
|
elseif ( is_singular( 'sp_staff' ) ):
|
||||||
$role = get_post_meta( $id, 'sp_role', true );
|
$role = get_post_meta( $id, 'sp_role', true );
|
||||||
if ( $role != null ):
|
if ( $role != null ):
|
||||||
$title = $title . '<br><small><strong>' . $role . '</strong></small>';
|
$title = '<strong>' . $role . '</strong> ' . $title;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
57
templates/staff-details.php
Normal file
57
templates/staff-details.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Staff Details
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @package SportsPress/Templates
|
||||||
|
* @version 0.8
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
if ( ! isset( $id ) )
|
||||||
|
$id = get_the_ID();
|
||||||
|
|
||||||
|
$defaults = array(
|
||||||
|
'show_nationality_flags' => get_option( 'sportspress_staff_show_flags', 'yes' ) == 'yes' ? true : false,
|
||||||
|
);
|
||||||
|
|
||||||
|
extract( $defaults, EXTR_SKIP );
|
||||||
|
|
||||||
|
$countries = SP()->countries->countries;
|
||||||
|
|
||||||
|
$staff = new SP_Staff( $id );
|
||||||
|
|
||||||
|
$nationality = $staff->nationality;
|
||||||
|
$current_team = $staff->current_team;
|
||||||
|
$past_teams = $staff->past_teams();
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
if ( $nationality ):
|
||||||
|
$country_name = sp_array_value( $countries, $nationality, null );
|
||||||
|
$data[ SP()->text->string('Nationality') ] = $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_team )
|
||||||
|
$data[ SP()->text->string('Current Team') ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||||
|
|
||||||
|
if ( $past_teams ):
|
||||||
|
$teams = array();
|
||||||
|
foreach ( $past_teams as $team ):
|
||||||
|
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||||
|
endforeach;
|
||||||
|
$data[ SP()->text->string('Past Teams') ] = implode( ', ', $teams );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$output = '<div class="sp-list-wrapper">' .
|
||||||
|
'<dl class="sp-staff-details">';
|
||||||
|
|
||||||
|
foreach( $data as $label => $value ):
|
||||||
|
|
||||||
|
$output .= '<dt>' . $label . '<dd>' . $value . '</dd>';
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</dl></div>';
|
||||||
|
|
||||||
|
echo apply_filters( 'sportspress_staff_details', $output );
|
||||||
Reference in New Issue
Block a user