diff --git a/includes/class-sp-staff.php b/includes/class-sp-staff.php new file mode 100644 index 00000000..173035c9 --- /dev/null +++ b/includes/class-sp-staff.php @@ -0,0 +1,24 @@ +ID, 'sp_past_team', false ); + } +} diff --git a/includes/sp-template-functions.php b/includes/sp-template-functions.php index 914a3175..50e45ff7 100644 --- a/includes/sp-template-functions.php +++ b/includes/sp-template-functions.php @@ -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 ********************************************************/ function sportspress_output_venue_map( $query ) { diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index 9aff1072..39fdb1e1 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -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 ); +/** + * Single Staff Content + * + * @see sportspress_output_staff_details() + */ +add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_details', 10 ); + /** * Venue Archive Content */ @@ -89,7 +96,7 @@ function sportspress_the_title( $title, $id ) { elseif ( is_singular( 'sp_staff' ) ): $role = get_post_meta( $id, 'sp_role', true ); if ( $role != null ): - $title = $title . '
' . $role . ''; + $title = '' . $role . ' ' . $title; endif; endif; endif; diff --git a/templates/staff-details.php b/templates/staff-details.php new file mode 100644 index 00000000..55e30c3a --- /dev/null +++ b/templates/staff-details.php @@ -0,0 +1,57 @@ + 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 ? '' . $nationality . ' ' : '' ) . $country_name : '—'; +endif; + +if ( $current_team ) + $data[ SP()->text->string('Current Team') ] = '' . get_the_title( $current_team ) . ''; + +if ( $past_teams ): + $teams = array(); + foreach ( $past_teams as $team ): + $teams[] = '' . get_the_title( $team ) . ''; + endforeach; + $data[ SP()->text->string('Past Teams') ] = implode( ', ', $teams ); +endif; + +$output = '
' . + '
'; + +foreach( $data as $label => $value ): + + $output .= '
' . $label . '
' . $value . '
'; + +endforeach; + +$output .= '
'; + +echo apply_filters( 'sportspress_staff_details', $output );