Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -2,44 +2,74 @@
|
||||
/**
|
||||
* Event Performance Table
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 2.6.20
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 2.6.20
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
// Initialize totals
|
||||
$totals = array();
|
||||
|
||||
// Set null
|
||||
if ( ! isset( $section ) ) $section = -1;
|
||||
if ( ! isset( $section_label ) ) $section_label = null;
|
||||
if ( ! isset( $class ) ) $class = null;
|
||||
if ( ! isset( $section ) ) {
|
||||
$section = -1;
|
||||
}
|
||||
if ( ! isset( $section_label ) ) {
|
||||
$section_label = null;
|
||||
}
|
||||
if ( ! isset( $class ) ) {
|
||||
$class = null;
|
||||
}
|
||||
|
||||
// Initialize arrays
|
||||
if ( ! isset( $lineups ) ) $lineups = array();
|
||||
if ( ! isset( $subs ) ) $subs = array();
|
||||
if ( ! isset( $lineups ) ) {
|
||||
$lineups = array();
|
||||
}
|
||||
if ( ! isset( $subs ) ) {
|
||||
$subs = array();
|
||||
}
|
||||
|
||||
$responsive = get_option( 'sportspress_enable_responsive_tables', 'no' ) == 'yes' ? true : false;
|
||||
//Create a unique identifier based on the current time in microseconds
|
||||
// Create a unique identifier based on the current time in microseconds
|
||||
$identifier = uniqid( 'performance_' );
|
||||
// If responsive tables are enabled then load the inline css code
|
||||
if ( true == $responsive && $mode == 'values' ){
|
||||
//sportspress_responsive_tables_css( $identifier );
|
||||
if ( true == $responsive && $mode == 'values' ) {
|
||||
// sportspress_responsive_tables_css( $identifier );
|
||||
}
|
||||
$i = 0;
|
||||
?>
|
||||
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?><?php if ( isset( $class ) ) { echo ' ' . $class; } ?>">
|
||||
<?php if ( $caption ): ?>
|
||||
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?>
|
||||
<?php
|
||||
if ( isset( $class ) ) {
|
||||
echo ' ' . $class; }
|
||||
?>
|
||||
">
|
||||
<?php if ( $caption ) : ?>
|
||||
<h4 class="sp-table-caption"><?php echo $caption; ?></h4>
|
||||
<?php endif; ?>
|
||||
<div class="sp-table-wrapper">
|
||||
<table class="sp-event-performance sp-data-table<?php if ( $mode == 'values' ) { ?><?php if ( $scrollable ) { ?> sp-scrollable-table<?php }if ( $responsive ) { echo ' sp-responsive-table '.$identifier; } if ( $sortable ) { ?> sp-sortable-table<?php } ?><?php } ?>">
|
||||
<table class="sp-event-performance sp-data-table
|
||||
<?php
|
||||
if ( $mode == 'values' ) {
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( $scrollable ) {
|
||||
?>
|
||||
sp-scrollable-table
|
||||
<?php
|
||||
}if ( $responsive ) {
|
||||
echo ' sp-responsive-table ' . $identifier; } if ( $sortable ) {
|
||||
?>
|
||||
sp-sortable-table<?php } ?><?php } ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ( $mode == 'values' ): ?>
|
||||
<?php if ( $show_players ): ?>
|
||||
<?php if ( $mode == 'values' ) : ?>
|
||||
<?php if ( $show_players ) : ?>
|
||||
<?php if ( apply_filters( 'sportspress_event_performance_show_numbers', $show_numbers, $section ) ) { ?>
|
||||
<th class="data-number">#</th>
|
||||
<?php } ?>
|
||||
@@ -51,24 +81,25 @@ $i = 0;
|
||||
<?php } ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php foreach ( $labels as $key => $label ): ?>
|
||||
<?php foreach ( $labels as $key => $label ) : ?>
|
||||
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php if ( $show_players ): ?>
|
||||
<?php if ( $show_players ) : ?>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$lineups = array_filter( $data, array( $event, 'lineup_filter' ) );
|
||||
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
|
||||
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
|
||||
|
||||
$lineup_sub_relation = array();
|
||||
foreach ( $subs as $sub_id => $sub ):
|
||||
if ( ! $sub_id )
|
||||
foreach ( $subs as $sub_id => $sub ) :
|
||||
if ( ! $sub_id ) {
|
||||
continue;
|
||||
$i = sp_array_value( $sub, 'sub', 0 );
|
||||
}
|
||||
$i = sp_array_value( $sub, 'sub', 0 );
|
||||
$lineup_sub_relation[ $i ] = $sub_id;
|
||||
endforeach;
|
||||
|
||||
@@ -76,15 +107,17 @@ $i = 0;
|
||||
|
||||
$stars_type = get_option( 'sportspress_event_performance_stars_type', 0 );
|
||||
|
||||
foreach ( $data as $player_id => $row ):
|
||||
foreach ( $data as $player_id => $row ) :
|
||||
|
||||
if ( ! $player_id )
|
||||
if ( ! $player_id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = get_the_title( $player_id );
|
||||
|
||||
if ( ! $name )
|
||||
if ( ! $name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<tr class="' . sp_array_value( $row, 'status', 'lineup' ) . ' ' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
@@ -95,15 +128,15 @@ $i = 0;
|
||||
echo '<td class="data-number" data-label="#">' . $number . '</td>';
|
||||
}
|
||||
|
||||
if ( $link_posts ):
|
||||
if ( $link_posts ) :
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
if ( $stars_type ):
|
||||
if ( $stars_type ) :
|
||||
$player_stars = sp_array_value( $stars, $player_id, 0 );
|
||||
if ( $player_stars ):
|
||||
switch ( $stars_type ):
|
||||
if ( $player_stars ) :
|
||||
switch ( $stars_type ) :
|
||||
case 1:
|
||||
$name .= ' <span class="sp-event-stars"><i class="sp-event-star dashicons dashicons-star-filled" title="' . __( 'Player of the Match', 'sportspress' ) . '"></i></span>';
|
||||
break;
|
||||
@@ -117,88 +150,91 @@ $i = 0;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
|
||||
if ( array_key_exists( $player_id, $lineup_sub_relation ) ) :
|
||||
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . '</span>';
|
||||
elseif ( isset( $row['sub'] ) && $row['sub'] ):
|
||||
elseif ( isset( $row['sub'] ) && $row['sub'] ) :
|
||||
$subbed = (int) $row['sub'];
|
||||
$name .= ' <span class="sub-out" title="' . get_the_title( $row[ 'sub' ] ) . '">' . sp_array_value( sp_array_value( $data, $subbed, array() ), 'number', null ) . '</span>';
|
||||
$name .= ' <span class="sub-out" title="' . get_the_title( $row['sub'] ) . '">' . sp_array_value( sp_array_value( $data, $subbed, array() ), 'number', null ) . '</span>';
|
||||
endif;
|
||||
|
||||
$content = '';
|
||||
$content = '';
|
||||
$position = null;
|
||||
|
||||
foreach ( $labels as $key => $label ):
|
||||
if ( 'name' == $key )
|
||||
foreach ( $labels as $key => $label ) :
|
||||
if ( 'name' == $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$format = sp_array_value( $formats, $key, 'number' );
|
||||
$format = sp_array_value( $formats, $key, 'number' );
|
||||
$placeholder = sp_get_format_placeholder( $format );
|
||||
|
||||
if ( ! array_key_exists( $key, $totals ) ):
|
||||
if ( ! array_key_exists( $key, $totals ) ) :
|
||||
$totals[ $key ] = $placeholder;
|
||||
endif;
|
||||
|
||||
if ( 'time' === $format ):
|
||||
if ( 'time' === $format ) :
|
||||
$totals[ $key ] = ' ';
|
||||
endif;
|
||||
|
||||
|
||||
$value = '-';
|
||||
if ( $key == 'position' ):
|
||||
if ( $key == 'position' ) :
|
||||
$positions = array();
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ) :
|
||||
$position_ids = (array) $row[ $key ];
|
||||
else:
|
||||
else :
|
||||
$position_ids = (array) sp_get_the_term_id( $player_id, 'sp_position' );
|
||||
endif;
|
||||
|
||||
foreach ( $position_ids as $position_id ) {
|
||||
$player_position = get_term_by( 'id', $position_id, 'sp_position' );
|
||||
if ( $player_position ) $positions[] = $player_position->name;
|
||||
if ( $player_position ) {
|
||||
$positions[] = $player_position->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$positions = array_unique( $positions );
|
||||
|
||||
if ( sizeof( $positions ) ):
|
||||
if ( sizeof( $positions ) ) :
|
||||
$value = $position = implode( ', ', $positions );
|
||||
endif;
|
||||
else:
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] !== '' ):
|
||||
if ( 'checkbox' === $format ):
|
||||
else :
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] !== '' ) :
|
||||
if ( 'checkbox' === $format ) :
|
||||
$value = '<span class="sp-checkbox">' . $row[ $key ] . '</span>';
|
||||
else:
|
||||
else :
|
||||
$value = $row[ $key ];
|
||||
endif;
|
||||
else:
|
||||
else :
|
||||
$value = $placeholder;
|
||||
endif;
|
||||
|
||||
if ( 'number' === $format ):
|
||||
$add = apply_filters( 'sportspress_event_performance_add_value', floatval( $value ), $key );
|
||||
|
||||
if ( 'number' === $format ) :
|
||||
$add = apply_filters( 'sportspress_event_performance_add_value', floatval( $value ), $key );
|
||||
$totals[ $key ] += $add;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $mode == 'values' ):
|
||||
$content .= '<td class="data-' . $key . '" data-label="'.$labels[$key].'">' . $value . '</td>';
|
||||
elseif ( intval( $value ) && $mode == 'icons' ):
|
||||
if ( $mode == 'values' ) :
|
||||
$content .= '<td class="data-' . $key . '" data-label="' . $labels[ $key ] . '">' . $value . '</td>';
|
||||
elseif ( intval( $value ) && $mode == 'icons' ) :
|
||||
$performance_id = sp_array_value( $performance_ids, $key, null );
|
||||
$icons = '';
|
||||
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
|
||||
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $performance_id ) ) ) . ' ', intval($value) );
|
||||
$icons = '';
|
||||
if ( $performance_id && has_post_thumbnail( $performance_id ) ) :
|
||||
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $performance_id ) ) ) . ' ', intval( $value ) );
|
||||
endif;
|
||||
$content .= apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if ( isset( $position ) && $mode == 'icons' ):
|
||||
if ( isset( $position ) && $mode == 'icons' ) :
|
||||
$name .= ' <small class="sp-player-position">' . $position . '</small>';
|
||||
endif;
|
||||
|
||||
echo '<td class="data-name" data-label="' . ( isset( $section_label ) ? $section_label : __( 'Player', 'sportspress' ) ) .'">' . $name . '</td>';
|
||||
echo '<td class="data-name" data-label="' . ( isset( $section_label ) ? $section_label : __( 'Player', 'sportspress' ) ) . '">' . $name . '</td>';
|
||||
|
||||
if ( $mode == 'icons' ):
|
||||
if ( $mode == 'icons' ) :
|
||||
echo '<td class="sp-performance-icons">' . $content . '</td>';
|
||||
else:
|
||||
else :
|
||||
echo $content;
|
||||
endif;
|
||||
|
||||
@@ -208,17 +244,19 @@ $i = 0;
|
||||
|
||||
endforeach;
|
||||
|
||||
foreach ( $labels as $key => $label ):
|
||||
foreach ( $labels as $key => $label ) :
|
||||
$format = sp_array_value( $formats, $key, 'number' );
|
||||
if ( 'equation' === $format ):
|
||||
if ( 'equation' === $format ) :
|
||||
$post = get_page_by_path( $key, OBJECT, 'sp_performance' );
|
||||
if ( $post ) $totals[ $key ] = sp_solve( get_post_meta( $post->ID, 'sp_equation', true ), $totals, get_post_meta( $post->ID, 'sp_precision', true ) );
|
||||
if ( $post ) {
|
||||
$totals[ $key ] = sp_solve( get_post_meta( $post->ID, 'sp_equation', true ), $totals, get_post_meta( $post->ID, 'sp_precision', true ) );
|
||||
}
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
<?php endif; ?>
|
||||
<?php if ( apply_filters( 'sportspress_event_performance_show_footer', $show_total ) ): ?>
|
||||
<?php if ( apply_filters( 'sportspress_event_performance_show_footer', $show_total ) ) : ?>
|
||||
<<?php echo ( $show_players ? 'tfoot' : 'tbody' ); ?>>
|
||||
<?php
|
||||
do_action( 'sportspress_event_performance_table_footer', $data, $labels, $section, $performance_ids );
|
||||
@@ -226,52 +264,57 @@ $i = 0;
|
||||
?>
|
||||
<tr class="sp-total-row <?php echo ( $i % 2 == 0 ? 'odd' : 'even' ); ?>">
|
||||
<?php
|
||||
if ( $show_players ):
|
||||
if ( $show_players ) :
|
||||
if ( apply_filters( 'sportspress_event_performance_show_numbers', $show_numbers, $section ) ) {
|
||||
echo '<td class="data-number" data-label=" "> </td>';
|
||||
}
|
||||
if ( $mode == 'values' ):
|
||||
if ( $mode == 'values' ) :
|
||||
echo '<td class="data-name" data-label=" ">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$row = sp_array_value( $data, 0, array() );
|
||||
|
||||
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons" colspan="2">';
|
||||
if ( $mode == 'icons' ) {
|
||||
echo '<td class="sp-performance-icons" colspan="2">';
|
||||
}
|
||||
|
||||
foreach ( $labels as $key => $label ):
|
||||
foreach ( $labels as $key => $label ) :
|
||||
$format = sp_array_value( $formats, $key, 'number' );
|
||||
if ( 'name' == $key )
|
||||
if ( 'name' == $key ) {
|
||||
continue;
|
||||
if ( $key == 'position' ):
|
||||
}
|
||||
if ( $key == 'position' ) :
|
||||
$value = ' ';
|
||||
else:
|
||||
if ( $primary && $key !== $primary ):
|
||||
else :
|
||||
if ( $primary && $key !== $primary ) :
|
||||
$value = ' ';
|
||||
elseif ( 'equation' !== $format && array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
elseif ( 'equation' !== $format && array_key_exists( $key, $row ) && $row[ $key ] != '' ) :
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
else :
|
||||
$value = apply_filters( 'sportspress_event_performance_table_total_value', sp_array_value( $totals, $key, 0 ), $data, $key );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $mode == 'values' ):
|
||||
if ($key == 'position'){
|
||||
if ( $mode == 'values' ) :
|
||||
if ( $key == 'position' ) {
|
||||
echo '<td class="data-' . $key . '" data-label=" ">' . $value . '</td>';
|
||||
}else{
|
||||
echo '<td class="data-' . $key . '" data-label="'.$labels[$key].'">' . $value . '</td>';
|
||||
} else {
|
||||
echo '<td class="data-' . $key . '" data-label="' . $labels[ $key ] . '">' . $value . '</td>';
|
||||
}
|
||||
elseif ( intval( $value ) && $mode == 'icons' ):
|
||||
elseif ( intval( $value ) && $mode == 'icons' ) :
|
||||
$performance_id = sp_array_value( $performance_ids, $key, null );
|
||||
$icons = '';
|
||||
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
|
||||
$icons = '';
|
||||
if ( $performance_id && has_post_thumbnail( $performance_id ) ) :
|
||||
$icons = get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $performance_id ) ) );
|
||||
endif;
|
||||
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, 1 ) . $value . ' ';
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if ( $mode == 'icons' ) echo '</td>';
|
||||
if ( $mode == 'icons' ) {
|
||||
echo '</td>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@@ -279,10 +322,16 @@ $i = 0;
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php
|
||||
if ( isset( $show_staff ) ) {
|
||||
echo sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
|
||||
}
|
||||
if ( isset( $show_staff ) ) {
|
||||
echo sp_get_template(
|
||||
'event-staff.php',
|
||||
array(
|
||||
'id' => $id,
|
||||
'index' => $index,
|
||||
)
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php do_action( 'sportspress_after_event_performance_table', $data, $lineups, $subs, $class ); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user