Mark subs in event performance

This commit is contained in:
Brian Miyaji
2014-04-30 11:47:35 +10:00
parent 32ad30a7e5
commit 2240cbeccf
3 changed files with 39 additions and 1 deletions

View File

@@ -61,13 +61,29 @@
text-align: center; text-align: center;
} }
/* League table */ /* League Table */
.sp-league-table .team-logo { .sp-league-table .team-logo {
vertical-align: middle; vertical-align: middle;
height: 2.5em; height: 2.5em;
width: auto; width: auto;
} }
/* Event Performance */
.sp-event-performance .sub-in,
.sp-event-performance .sub-out {
cursor: default;
}
.sp-event-performance .sub-in:before,
.sp-event-performance .sub-out:before {
font-family: dashicons;
}
.sp-event-performance .sub-in:before {
content: "\f140";
}
.sp-event-performance .sub-out:before {
content: "\f142";
}
/* Event Calendar */ /* Event Calendar */
.sp-event-calendar tbody td, .sp-event-calendar thead th { .sp-event-calendar tbody td, .sp-event-calendar thead th {
text-align: center; text-align: center;

View File

@@ -56,6 +56,7 @@ class SP_Frontend_Scripts {
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ), 'previous' => __( 'Previous', 'sportspress' ), 'next' => __( 'Next', 'sportspress' ) ) ); wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ), 'previous' => __( 'Previous', 'sportspress' ), 'next' => __( 'Next', 'sportspress' ) ) );
// CSS Styles // CSS Styles
wp_enqueue_style( 'dashicons' );
$enqueue_styles = $this->get_styles(); $enqueue_styles = $this->get_styles();
if ( $enqueue_styles ): if ( $enqueue_styles ):

View File

@@ -12,6 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();
$event = new SP_Event( $id );
$teams = (array)get_post_meta( $id, 'sp_team', false ); $teams = (array)get_post_meta( $id, 'sp_team', false );
$staff = (array)get_post_meta( $id, 'sp_staff', false ); $staff = (array)get_post_meta( $id, 'sp_staff', false );
$stats = (array)get_post_meta( $id, 'sp_players', true ); $stats = (array)get_post_meta( $id, 'sp_players', true );
@@ -47,6 +49,17 @@ foreach( $teams as $key => $team_id ):
<?php if ( $has_players ): ?> <?php if ( $has_players ): ?>
<tbody> <tbody>
<?php <?php
$lineups = array_filter( $data, array( $event, 'lineup_filter' ) );
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
$lineup_sub_relation = array();
foreach ( $subs as $sub_id => $sub ):
if ( ! $sub_id )
continue;
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
endforeach;
$i = 0; $i = 0;
foreach( $data as $player_id => $row ): foreach( $data as $player_id => $row ):
@@ -68,6 +81,14 @@ foreach( $teams as $key => $team_id ):
if ( $link_posts ): if ( $link_posts ):
$permalink = get_post_permalink( $player_id ); $permalink = get_post_permalink( $player_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>'; $name = '<a href="' . $permalink . '">' . $name . '</a>';
if ( isset( $row['status'] ) && $row['status'] == 'sub' ):
$name = '(' . $name . ')';
endif;
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . get_post_meta( $lineup_sub_relation[ $player_id ], 'sp_number', true ) . '</span>';
elseif ( isset( $row['sub'] ) && $row['sub'] ):
$name .= ' <span class="sub-out" title="' . get_the_title( $row[ 'sub' ] ) . '">' . get_post_meta( $row['sub'], 'sp_number', true ) . '</span>';
endif;
endif; endif;
echo '<td class="data-name">' . $name . '</td>'; echo '<td class="data-name">' . $name . '</td>';