Simplify css inline code

This commit is contained in:
savvasha
2017-12-19 14:41:42 +02:00
parent 7d08b40f9e
commit cb52599d17
5 changed files with 54 additions and 78 deletions

View File

@@ -516,7 +516,7 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) {
* @subpackage Responsive * @subpackage Responsive
* @return void * @return void
*/ */
function sportspress_responsive_tables_css( $vars, $identity ) { function sportspress_responsive_tables_css( $identity ) {
$custom_css = '/* $custom_css = '/*
Max width before this PARTICULAR table gets nasty Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px This query will take effect for any screen smaller than 760px
@@ -526,7 +526,7 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) {
only screen and (max-width: 800px) { only screen and (max-width: 800px) {
/* Force table to not be like tables anymore */ /* Force table to not be like tables anymore */
table.'.$identity.', table.'.$identity.' thead, table.'.$identity.' tbody, table.'.$identity.' th, table.'.$identity.' td, table.'.$identity.' tr { table.'.$identity.', table.'.$identity.' thead, table.'.$identity.' tfoot, table.'.$identity.' tbody, table.'.$identity.' th, table.'.$identity.' td, table.'.$identity.' tr {
display: block; display: block;
} }
@@ -556,6 +556,8 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) {
table.'.$identity.' td:before { table.'.$identity.' td:before {
/* Now like a table header */ /* Now like a table header */
position: absolute; position: absolute;
/* Label the data */
content: attr(data-label);
/* Top/left values mimic padding */ /* Top/left values mimic padding */
top: 6px; top: 6px;
left: 6px; left: 6px;
@@ -563,19 +565,8 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) {
padding-right: 10px; padding-right: 10px;
white-space: nowrap; white-space: nowrap;
} }
/*
Label the data
*/
';
$k=1;
foreach ( $vars as $label ) {
$custom_css .= 'table.'.$identity.' td:nth-of-type('.$k.'):before { content: "'.$label.'"; }
';
$k++;
} }
';
$custom_css .= ' } ';
$dummystyle = 'sportspress-style-inline-'.$identity; $dummystyle = 'sportspress-style-inline-'.$identity;
wp_register_style( $dummystyle, false ); wp_register_style( $dummystyle, false );

View File

@@ -106,13 +106,11 @@ $identifier = uniqid( 'eventlist_' );
<tr> <tr>
<?php <?php
echo '<th class="data-date">' . __( 'Date', 'sportspress' ) . '</th>'; echo '<th class="data-date">' . __( 'Date', 'sportspress' ) . '</th>';
$labels[] = __( 'Date', 'sportspress' );
switch ( $title_format ) { switch ( $title_format ) {
case 'homeaway': case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
echo '<th class="data-home">' . __( 'Home', 'sportspress' ) . '</th>'; echo '<th class="data-home">' . __( 'Home', 'sportspress' ) . '</th>';
$labels[] = __( 'Home', 'sportspress' );
} }
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) { if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
@@ -120,74 +118,59 @@ $identifier = uniqid( 'eventlist_' );
$labels[] = __( 'Time/Results', 'sportspress' ); $labels[] = __( 'Time/Results', 'sportspress' );
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) { } elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>'; echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
$labels[] = __( 'Results', 'sportspress' );
} }
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
echo '<th class="data-away">' . __( 'Away', 'sportspress' ) . '</th>'; echo '<th class="data-away">' . __( 'Away', 'sportspress' ) . '</th>';
$labels[] = __( 'Away', 'sportspress' );
} }
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) { if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
$labels[] = __( 'Time', 'sportspress' );
} }
break; break;
default: default:
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' ){ if ( $title_format == 'teams' ){
echo '<th class="data-teams">' . __( 'Teams', 'sportspress' ) . '</th>'; echo '<th class="data-teams">' . __( 'Teams', 'sportspress' ) . '</th>';
$labels[] = __( 'Teams', 'sportspress' );
}else{ }else{
echo '<th class="data-event">' . __( 'Event', 'sportspress' ) . '</th>'; echo '<th class="data-event">' . __( 'Event', 'sportspress' ) . '</th>';
$labels[] = __( 'Event', 'sportspress' );}
} }
switch ( $time_format ) { switch ( $time_format ) {
case 'separate': case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) ) if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
$labels[] = __( 'Time', 'sportspress' );
if ( sp_column_active( $usecolumns, 'results' ) ) if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>'; echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
$labels[] = __( 'Results', 'sportspress' );
break; break;
case 'time': case 'time':
if ( sp_column_active( $usecolumns, 'time' ) ) if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
$labels[] = __( 'Time', 'sportspress' );
break; break;
case 'results': case 'results':
if ( sp_column_active( $usecolumns, 'results' ) ) if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>'; echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
$labels[] = __( 'Results', 'sportspress' );
break; break;
default: default:
if ( sp_column_active( $usecolumns, 'time' ) ) if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>';
$labels[] = __( 'Time/Results', 'sportspress' );
} }
} }
if ( sp_column_active( $usecolumns, 'league' ) ) if ( sp_column_active( $usecolumns, 'league' ) )
echo '<th class="data-league">' . __( 'League', 'sportspress' ) . '</th>'; echo '<th class="data-league">' . __( 'League', 'sportspress' ) . '</th>';
$labels[] = __( 'League', 'sportspress' );
if ( sp_column_active( $usecolumns, 'season' ) ) if ( sp_column_active( $usecolumns, 'season' ) )
echo '<th class="data-season">' . __( 'Season', 'sportspress' ) . '</th>'; echo '<th class="data-season">' . __( 'Season', 'sportspress' ) . '</th>';
$labels[] = __( 'Season', 'sportspress' );
if ( sp_column_active( $usecolumns, 'venue' ) ) if ( sp_column_active( $usecolumns, 'venue' ) )
echo '<th class="data-venue">' . __( 'Venue', 'sportspress' ) . '</th>'; echo '<th class="data-venue">' . __( 'Venue', 'sportspress' ) . '</th>';
$labels[] = __( 'Venue', 'sportspress' );
if ( sp_column_active( $usecolumns, 'article' ) ) if ( sp_column_active( $usecolumns, 'article' ) )
echo '<th class="data-article">' . __( 'Article', 'sportspress' ) . '</th>'; echo '<th class="data-article">' . __( 'Article', 'sportspress' ) . '</th>';
$labels[] = __( 'Article', 'sportspress' );
if ( sp_column_active( $usecolumns, 'day' ) ) if ( sp_column_active( $usecolumns, 'day' ) )
echo '<th class="data-day">' . __( 'Match Day', 'sportspress' ) . '</th>'; echo '<th class="data-day">' . __( 'Match Day', 'sportspress' ) . '</th>';
$labels[] = __( 'Match Day', 'sportspress' );
do_action( 'sportspress_event_list_head_row', $usecolumns ); do_action( 'sportspress_event_list_head_row', $usecolumns );
?> ?>
@@ -263,17 +246,17 @@ $identifier = uniqid( 'eventlist_' );
if ( $link_events ) $date_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">' . $date_html . '</a>'; if ( $link_events ) $date_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">' . $date_html . '</a>';
echo '<td class="data-date" itemprop="startDate" content="' . mysql2date( 'Y-m-d\TH:iP', $event->post_date ) . '">' . $date_html . '</td>'; echo '<td class="data-date" itemprop="startDate" content="' . mysql2date( 'Y-m-d\TH:iP', $event->post_date ) . '" data-label="'.__( 'Date', 'sportspress' ).'">' . $date_html . '</td>';
switch ( $title_format ) { switch ( $title_format ) {
case 'homeaway': case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
$team = array_shift( $teams_array ); $team = array_shift( $teams_array );
echo '<td class="data-home' . $team_class . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam">' . $team . '</td>'; echo '<td class="data-home' . $team_class . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam" data-label="'.__( 'Home', 'sportspress' ).'">' . $team . '</td>';
} }
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) { if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">'; echo '<td class="data-time" data-label="'.__( 'Time/Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( ! empty( $main_results ) ): if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results ); echo implode( ' - ', $main_results );
@@ -283,7 +266,7 @@ $identifier = uniqid( 'eventlist_' );
if ( $link_events ) echo '</a>'; if ( $link_events ) echo '</a>';
echo '</td>'; echo '</td>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) { } elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results">'; echo '<td class="data-results" data-label="'.__( 'Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( ! empty( $main_results ) ): if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results ); echo implode( ' - ', $main_results );
@@ -296,11 +279,11 @@ $identifier = uniqid( 'eventlist_' );
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
$team = array_shift( $teams_array ); $team = array_shift( $teams_array );
echo '<td class="data-away' . $team_class . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam">' . $team . '</td>'; echo '<td class="data-away' . $team_class . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam" data-label="'.__( 'Away', 'sportspress' ).'">' . $team . '</td>';
} }
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) { if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">'; echo '<td class="data-time" data-label="'.__( 'Time', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID ); echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
if ( $link_events ) echo '</a>'; if ( $link_events ) echo '</a>';
@@ -310,25 +293,25 @@ $identifier = uniqid( 'eventlist_' );
default: default:
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' ) { if ( $title_format == 'teams' ) {
echo '<td class="data-event data-teams">' . $teams_output . '</td>'; echo '<td class="data-event data-teams" data-label="'.__( 'Teams', 'sportspress' ).'">' . $teams_output . '</td>';
} else { } else {
$title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title; $title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title;
if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">' . $title_html . '</a>'; if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">' . $title_html . '</a>';
echo '<td class="data-event">' . $title_html . '</td>'; echo '<td class="data-event" data-label="'.__( 'Event', 'sportspress' ).'">' . $title_html . '</td>';
} }
} }
switch ( $time_format ) { switch ( $time_format ) {
case 'separate': case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) ) { if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">'; echo '<td class="data-time" data-label="'.__( 'Time', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID ); echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
if ( $link_events ) echo '</a>'; if ( $link_events ) echo '</a>';
echo '</td>'; echo '</td>';
} }
if ( sp_column_active( $usecolumns, 'results' ) ) { if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results">'; echo '<td class="data-results" data-label="'.__( 'Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( ! empty( $main_results ) ): if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results ); echo implode( ' - ', $main_results );
@@ -341,7 +324,7 @@ $identifier = uniqid( 'eventlist_' );
break; break;
case 'time': case 'time':
if ( sp_column_active( $usecolumns, 'time' ) ) { if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">'; echo '<td class="data-time" data-label="'.__( 'Time', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID ); echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
if ( $link_events ) echo '</a>'; if ( $link_events ) echo '</a>';
@@ -350,7 +333,7 @@ $identifier = uniqid( 'eventlist_' );
break; break;
case 'results': case 'results':
if ( sp_column_active( $usecolumns, 'results' ) ) { if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results">'; echo '<td class="data-results" data-label="'.__( 'Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( ! empty( $main_results ) ): if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results ); echo implode( ' - ', $main_results );
@@ -363,7 +346,7 @@ $identifier = uniqid( 'eventlist_' );
break; break;
default: default:
if ( sp_column_active( $usecolumns, 'time' ) ) { if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">'; echo '<td class="data-time" data-label="'.__( 'Time/Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( ! empty( $main_results ) ): if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results ); echo implode( ' - ', $main_results );
@@ -377,7 +360,7 @@ $identifier = uniqid( 'eventlist_' );
} }
if ( sp_column_active( $usecolumns, 'league' ) ): if ( sp_column_active( $usecolumns, 'league' ) ):
echo '<td class="data-league">'; echo '<td class="data-league" data-label="'.__( 'League', 'sportspress' ).'">';
$leagues = get_the_terms( $event->ID, 'sp_league' ); $leagues = get_the_terms( $event->ID, 'sp_league' );
if ( $leagues ): foreach ( $leagues as $league ): if ( $leagues ): foreach ( $leagues as $league ):
echo $league->name; echo $league->name;
@@ -386,7 +369,7 @@ $identifier = uniqid( 'eventlist_' );
endif; endif;
if ( sp_column_active( $usecolumns, 'season' ) ): if ( sp_column_active( $usecolumns, 'season' ) ):
echo '<td class="data-season">'; echo '<td class="data-season" data-label="'.__( 'Season', 'sportspress' ).'">';
$seasons = get_the_terms( $event->ID, 'sp_season' ); $seasons = get_the_terms( $event->ID, 'sp_season' );
if ( $seasons ): foreach ( $seasons as $season ): if ( $seasons ): foreach ( $seasons as $season ):
echo $season->name; echo $season->name;
@@ -395,7 +378,7 @@ $identifier = uniqid( 'eventlist_' );
endif; endif;
if ( sp_column_active( $usecolumns, 'venue' ) ): if ( sp_column_active( $usecolumns, 'venue' ) ):
echo '<td class="data-venue">'; echo '<td class="data-venue" data-label="'.__( 'Venue', 'sportspress' ).'">';
if ( $link_venues ): if ( $link_venues ):
the_terms( $event->ID, 'sp_venue' ); the_terms( $event->ID, 'sp_venue' );
else: else:
@@ -408,7 +391,7 @@ $identifier = uniqid( 'eventlist_' );
endif; endif;
if ( sp_column_active( $usecolumns, 'article' ) ): if ( sp_column_active( $usecolumns, 'article' ) ):
echo '<td class="data-article">'; echo '<td class="data-article" data-label="'.__( 'Article', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">'; if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( $video ): if ( $video ):
@@ -429,7 +412,7 @@ $identifier = uniqid( 'eventlist_' );
endif; endif;
if ( sp_column_active( $usecolumns, 'day' ) ): if ( sp_column_active( $usecolumns, 'day' ) ):
echo '<td class="data-day">'; echo '<td class="data-day" data-label="'.__( 'Match Day', 'sportspress' ).'">';
$day = get_post_meta( $event->ID, 'sp_day', true ); $day = get_post_meta( $event->ID, 'sp_day', true );
if ( '' == $day ) { if ( '' == $day ) {
echo '-'; echo '-';
@@ -452,7 +435,7 @@ $identifier = uniqid( 'eventlist_' );
<?php <?php
// If responsive tables are enabled then load the inline css code // If responsive tables are enabled then load the inline css code
if ( true == $responsive ){ if ( true == $responsive ){
sportspress_responsive_tables_css( $labels, $identifier ); sportspress_responsive_tables_css( $identifier );
} }
if ( $id && $show_all_events_link ) if ( $id && $show_all_events_link )
echo '<div class="sp-calendar-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a></div>'; echo '<div class="sp-calendar-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a></div>';

View File

@@ -20,10 +20,14 @@ if ( ! isset( $class ) ) $class = null;
// Initialize arrays // Initialize arrays
if ( ! isset( $lineups ) ) $lineups = array(); if ( ! isset( $lineups ) ) $lineups = array();
if ( ! isset( $subs ) ) $subs = array(); if ( ! isset( $subs ) ) $subs = array();
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; $responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
$rlabels = array();
//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_' ); $identifier = uniqid( 'performance_' );
// If responsive tables are enabled then load the inline css code
if ( true == $responsive && $mode == 'values' ){
sportspress_responsive_tables_css( $identifier );
}
?> ?>
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?><?php if ( isset( $class ) ) { echo ' ' . $class; } ?>"> <div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?><?php if ( isset( $class ) ) { echo ' ' . $class; } ?>">
<?php if ( $caption ): ?> <?php if ( $caption ): ?>
@@ -37,21 +41,19 @@ $identifier = uniqid( 'performance_' );
<?php if ( $show_players ): ?> <?php if ( $show_players ): ?>
<?php if ( apply_filters( 'sportspress_event_performance_show_numbers', $show_numbers, $section ) ) { ?> <?php if ( apply_filters( 'sportspress_event_performance_show_numbers', $show_numbers, $section ) ) { ?>
<th class="data-number">#</th> <th class="data-number">#</th>
<?php $rlabels[] = '#'; ?>
<?php } ?> <?php } ?>
<th class="data-name"> <th class="data-name">
<?php if ( isset( $section_label ) ) { ?> <?php if ( isset( $section_label ) ) { ?>
<?php echo $section_label; ?> <?php echo $section_label; ?>
<?php $rlabels[] = $section_label; ?> <?php $player_title = $section_label; ?>
<?php } else { ?> <?php } else { ?>
<?php _e( 'Player', 'sportspress' ); ?> <?php _e( 'Player', 'sportspress' ); ?>
<?php $rlabels[] = __( 'Player', 'sportspress' ); ?> <?php $player_title = __( 'Player', 'sportspress' ); ?>
<?php } ?> <?php } ?>
</th> </th>
<?php endif; ?> <?php endif; ?>
<?php foreach ( $labels as $key => $label ): ?> <?php foreach ( $labels as $key => $label ): ?>
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th> <th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
<?php $rlabels[] = $label; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
</tr> </tr>
@@ -92,7 +94,7 @@ $identifier = uniqid( 'performance_' );
$number = sp_array_value( $row, 'number', '&nbsp;' ); $number = sp_array_value( $row, 'number', '&nbsp;' );
// Player number // Player number
echo '<td class="data-number">' . $number . '</td>'; echo '<td class="data-number" data-label="#">' . $number . '</td>';
} }
if ( $link_posts ): if ( $link_posts ):
@@ -175,7 +177,7 @@ $identifier = uniqid( 'performance_' );
endif; endif;
if ( $mode == 'values' ): if ( $mode == 'values' ):
$content .= '<td class="data-' . $key . '">' . $value . '</td>'; $content .= '<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 ); $performance_id = sp_array_value( $performance_ids, $key, null );
$icons = ''; $icons = '';
@@ -190,7 +192,7 @@ $identifier = uniqid( 'performance_' );
$name .= ' <small class="sp-player-position">' . $position . '</small>'; $name .= ' <small class="sp-player-position">' . $position . '</small>';
endif; endif;
echo '<td class="data-name">' . $name . '</td>'; echo '<td class="data-name" data-label="'.$player_title.'">' . $name . '</td>';
if ( $mode == 'icons' ): if ( $mode == 'icons' ):
echo '<td class="sp-performance-icons">' . $content . '</td>'; echo '<td class="sp-performance-icons">' . $content . '</td>';
@@ -216,10 +218,10 @@ $identifier = uniqid( 'performance_' );
<?php <?php
if ( $show_players ): if ( $show_players ):
if ( apply_filters( 'sportspress_event_performance_show_numbers', $show_numbers, $section ) ) { if ( apply_filters( 'sportspress_event_performance_show_numbers', $show_numbers, $section ) ) {
echo '<td class="data-number">&nbsp;</td>'; echo '<td class="data-number" data-label="&nbsp;">&nbsp;</td>';
} }
if ( $mode == 'values' ): if ( $mode == 'values' ):
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>'; echo '<td class="data-name" data-label="&nbsp;">' . __( 'Total', 'sportspress' ) . '</td>';
endif; endif;
endif; endif;
@@ -243,7 +245,11 @@ $identifier = uniqid( 'performance_' );
endif; endif;
if ( $mode == 'values' ): if ( $mode == 'values' ):
echo '<td class="data-' . $key . '">' . $value . '</td>'; if ($key == 'position'){
echo '<td class="data-' . $key . '" data-label="&nbsp;">' . $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 ); $performance_id = sp_array_value( $performance_ids, $key, null );
$icons = ''; $icons = '';
@@ -265,8 +271,3 @@ $identifier = uniqid( 'performance_' );
<?php do_action( 'sportspress_after_event_performance_table', $data, $lineups, $subs, $class ); ?> <?php do_action( 'sportspress_after_event_performance_table', $data, $lineups, $subs, $class ); ?>
</div> </div>
<?php
// If responsive tables are enabled then load the inline css code
if ( true == $responsive && $mode == 'values' ){
sportspress_responsive_tables_css( $rlabels, $identifier );
}

View File

@@ -66,7 +66,7 @@ $data = $table->data();
$labels = $data[0]; $labels = $data[0];
// If responsive tables are enabled then load the inline css code // If responsive tables are enabled then load the inline css code
if ( true == $responsive ){ if ( true == $responsive ){
sportspress_responsive_tables_css( $labels, $identifier ); sportspress_responsive_tables_css( $identifier );
} }
// Remove the first row to leave us with the actual data // Remove the first row to leave us with the actual data
unset( $data[0] ); unset( $data[0] );
@@ -139,7 +139,7 @@ foreach ( $data as $team_id => $row ):
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . $tr_class . ' sp-row-no-' . $i . '">'; $output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . $tr_class . ' sp-row-no-' . $i . '">';
// Rank // Rank
$output .= '<td class="data-rank' . $td_class . '">' . sp_array_value( $row, 'pos' ) . '</td>'; $output .= '<td class="data-rank' . $td_class . '" data-label="'.$labels['pos'].'">' . sp_array_value( $row, 'pos' ) . '</td>';
$name_class = ''; $name_class = '';
@@ -156,13 +156,13 @@ foreach ( $data as $team_id => $row ):
$name = '<a href="' . $permalink . '">' . $name . '</a>'; $name = '<a href="' . $permalink . '">' . $name . '</a>';
endif; endif;
$output .= '<td class="data-name' . $name_class . $td_class . '">' . $name . '</td>'; $output .= '<td class="data-name' . $name_class . $td_class . '" data-label="'.$labels['name'].'">' . $name . '</td>';
foreach( $labels as $key => $value ): foreach( $labels as $key => $value ):
if ( in_array( $key, array( 'pos', 'name' ) ) ) if ( in_array( $key, array( 'pos', 'name' ) ) )
continue; continue;
if ( ! is_array( $columns ) || in_array( $key, $columns ) ) if ( ! is_array( $columns ) || in_array( $key, $columns ) )
$output .= '<td class="data-' . $key . $td_class . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>'; $output .= '<td class="data-' . $key . $td_class . '" data-label="'.$labels[$key].'">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach; endforeach;
$output .= '</tr>'; $output .= '</tr>';

View File

@@ -56,11 +56,12 @@ $data = $list->data();
// The first row should be column labels // The first row should be column labels
$labels = $data[0]; $labels = $data[0];
//Create a unique identifier based on the current time in microseconds //Create a unique identifier based on the current time in microseconds
$identifier = uniqid( 'playerlist_' ); $identifier = uniqid( 'playerlist_' );
// If responsive tables are enabled then load the inline css code // If responsive tables are enabled then load the inline css code
if ( true == $responsive ){ if ( true == $responsive ){
sportspress_responsive_tables_css( $labels, $identifier ); sportspress_responsive_tables_css( $identifier );
} }
// Remove the first row to leave us with the actual data // Remove the first row to leave us with the actual data
unset( $data[0] ); unset( $data[0] );
@@ -136,9 +137,9 @@ foreach ( $groups as $group ):
// Rank or number // Rank or number
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ): if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ):
if ( isset( $orderby ) && $orderby != 'number' ): if ( isset( $orderby ) && $orderby != 'number' ):
$tbody .= '<td class="data-rank">' . ( $i + 1 ) . '</td>'; $tbody .= '<td class="data-rank" data-label="'.$labels['number'].'">' . ( $i + 1 ) . '</td>';
else: else:
$tbody .= '<td class="data-number">' . sp_array_value( $row, 'number', '&nbsp;' ) . '</td>'; $tbody .= '<td class="data-number" data-label="'.$labels['number'].'">' . sp_array_value( $row, 'number', '&nbsp;' ) . '</td>';
endif; endif;
endif; endif;
@@ -168,7 +169,7 @@ foreach ( $groups as $group ):
$name = '<a href="' . $permalink . '">' . $name . '</a>'; $name = '<a href="' . $permalink . '">' . $name . '</a>';
endif; endif;
$tbody .= '<td class="data-name' . $name_class . '">' . $name . '</td>'; $tbody .= '<td class="data-name' . $name_class . '" data-label="'.$labels['name'].'">' . $name . '</td>';
if ( array_key_exists( 'team', $labels ) ): if ( array_key_exists( 'team', $labels ) ):
$team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) ); $team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) );
@@ -176,7 +177,7 @@ foreach ( $groups as $group ):
if ( $link_teams && false !== get_post_status( $team ) ): if ( $link_teams && false !== get_post_status( $team ) ):
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>'; $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
endif; endif;
$tbody .= '<td class="data-team">' . $team_name . '</td>'; $tbody .= '<td class="data-team" data-label="'.$labels['team'].'">' . $team_name . '</td>';
endif; endif;
if ( array_key_exists( 'position', $labels ) ): if ( array_key_exists( 'position', $labels ) ):
@@ -187,14 +188,14 @@ foreach ( $groups as $group ):
$position_term = get_term_by( 'id', $position, 'sp_position', ARRAY_A ); $position_term = get_term_by( 'id', $position, 'sp_position', ARRAY_A );
$positions = sp_array_value( $position_term, 'name', '&mdash;' ); $positions = sp_array_value( $position_term, 'name', '&mdash;' );
endif; endif;
$tbody .= '<td class="data-position">' . $positions . '</td>'; $tbody .= '<td class="data-position" data-label="'.$labels['position'].'">' . $positions . '</td>';
endif; endif;
foreach( $labels as $key => $value ): foreach( $labels as $key => $value ):
if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) ) if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) )
continue; continue;
if ( ! is_array( $columns ) || in_array( $key, $columns ) ) if ( ! is_array( $columns ) || in_array( $key, $columns ) )
$tbody .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>'; $tbody .= '<td class="data-' . $key . '" data-label="'.$labels[$key].'">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach; endforeach;
$tbody .= '</tr>'; $tbody .= '</tr>';