Clean up spaces, tabs, indentation, and bracket formatting

This commit is contained in:
Brian Miyaji
2021-11-10 15:41:40 +09:00
parent e58beb1201
commit 3dff686a00
285 changed files with 29638 additions and 24147 deletions

View File

@@ -2,23 +2,32 @@
/**
* Event Results
*
* @author ThemeBoy
* @package SportsPress/Templates
* @author ThemeBoy
* @package SportsPress/Templates
* @version 2.7.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_event_show_results', 'yes' ) === 'no' ) return;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( get_option( 'sportspress_event_show_results', 'yes' ) === 'no' ) {
return;
}
if ( ! isset( $id ) )
if ( ! isset( $id ) ) {
$id = get_the_ID();
}
$event = new SP_Event( $id );
$event = new SP_Event( $id );
$status = $event->status();
if ( 'results' != $status ) return;
if ( 'results' != $status ) {
return;
}
if ( ! isset( $caption ) ) $caption = __( 'Results', 'sportspress' );
if ( ! isset( $caption ) ) {
$caption = __( 'Results', 'sportspress' );
}
// Get event result data
$data = $event->results();
@@ -31,17 +40,18 @@ unset( $data[0] );
$data = array_filter( $data );
if ( empty( $data ) )
if ( empty( $data ) ) {
return false;
}
$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false;
$link_teams = get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false;
$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false;
$link_teams = get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false;
$show_outcomes = array_key_exists( 'outcome', $labels );
// Initialize
$output = '';
$output = '';
$table_rows = '';
$i = 0;
$i = 0;
// Reverse teams order if the option "Events > Teams > Order > Reverse order" is enabled.
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
@@ -49,16 +59,16 @@ if ( $reverse_teams ) {
$data = array_reverse( $data, true );
}
foreach( $data as $team_id => $result ):
if ( $show_outcomes ):
$outcomes = array();
foreach ( $data as $team_id => $result ) :
if ( $show_outcomes ) :
$outcomes = array();
$result_outcome = sp_array_value( $result, 'outcome' );
if ( ! is_array( $result_outcome ) ):
if ( ! is_array( $result_outcome ) ) :
$outcomes = array( '—' );
else:
foreach( $result_outcome as $outcome ):
else :
foreach ( $result_outcome as $outcome ) :
$the_outcome = get_page_by_path( $outcome, OBJECT, 'sp_outcome' );
if ( is_object( $the_outcome ) ):
if ( is_object( $the_outcome ) ) :
$outcomes[] = $the_outcome->post_title;
endif;
endforeach;
@@ -71,24 +81,25 @@ foreach( $data as $team_id => $result ):
$team_name = sp_team_short_name( $team_id );
if ( $link_teams && sp_post_exists( $team_id ) ):
if ( $link_teams && sp_post_exists( $team_id ) ) :
$team_name = '<a href="' . get_post_permalink( $team_id ) . '">' . $team_name . '</a>';
endif;
$table_rows .= '<td class="data-name">' . $team_name . '</td>';
foreach( $labels as $key => $label ):
if ( in_array( $key, array( 'name', 'outcome' ) ) )
foreach ( $labels as $key => $label ) :
if ( in_array( $key, array( 'name', 'outcome' ) ) ) {
continue;
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
}
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ) :
$value = $result[ $key ];
else:
else :
$value = apply_filters( 'sportspress_event_empty_result_string', '&mdash;' );
endif;
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
endforeach;
if ( $show_outcomes ):
if ( $show_outcomes ) :
$table_rows .= '<td class="data-outcome">' . implode( ', ', $outcomes ) . '</td>';
endif;
@@ -97,18 +108,18 @@ foreach( $data as $team_id => $result ):
$i++;
endforeach;
if ( empty( $table_rows ) ):
if ( empty( $table_rows ) ) :
return false;
else:
else :
$output .= '<h4 class="sp-table-caption">' . $caption . '</h4>';
$output .= '<div class="sp-table-wrapper">' .
'<table class="sp-event-results sp-data-table' . ( $scrollable ? ' sp-scrollable-table' : '' ) . '"><thead>' .
'<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
foreach( $labels as $key => $label ):
foreach ( $labels as $key => $label ) :
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
endforeach;
$output .= '</tr>' . '</thead>' . '<tbody>';