diff --git a/includes/sp-template-functions.php b/includes/sp-template-functions.php index dba4907e..71bb7064 100644 --- a/includes/sp-template-functions.php +++ b/includes/sp-template-functions.php @@ -516,7 +516,7 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) { * @subpackage Responsive * @return void */ - function sportspress_responsive_tables_css( $vars, $identity ) { + function sportspress_responsive_tables_css( $identity ) { $custom_css = '/* Max width before this PARTICULAR table gets nasty 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) { /* 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; } @@ -556,6 +556,8 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) { table.'.$identity.' td:before { /* Now like a table header */ position: absolute; + /* Label the data */ + content: attr(data-label); /* Top/left values mimic padding */ top: 6px; left: 6px; @@ -563,19 +565,8 @@ if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) { padding-right: 10px; 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; wp_register_style( $dummystyle, false ); diff --git a/templates/event-list.php b/templates/event-list.php index baf8029a..7cd81a84 100644 --- a/templates/event-list.php +++ b/templates/event-list.php @@ -106,13 +106,11 @@ $identifier = uniqid( 'eventlist_' ); ' . __( 'Date', 'sportspress' ) . ''; - $labels[] = __( 'Date', 'sportspress' ); switch ( $title_format ) { case 'homeaway': if ( sp_column_active( $usecolumns, 'event' ) ) { echo '' . __( 'Home', 'sportspress' ) . ''; - $labels[] = __( 'Home', 'sportspress' ); } if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) { @@ -120,74 +118,59 @@ $identifier = uniqid( 'eventlist_' ); $labels[] = __( 'Time/Results', 'sportspress' ); } elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) { echo '' . __( 'Results', 'sportspress' ) . ''; - $labels[] = __( 'Results', 'sportspress' ); } if ( sp_column_active( $usecolumns, 'event' ) ) { echo '' . __( 'Away', 'sportspress' ) . ''; - $labels[] = __( 'Away', 'sportspress' ); } if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) { echo '' . __( 'Time', 'sportspress' ) . ''; - $labels[] = __( 'Time', 'sportspress' ); } break; default: if ( sp_column_active( $usecolumns, 'event' ) ) { if ( $title_format == 'teams' ){ echo '' . __( 'Teams', 'sportspress' ) . ''; - $labels[] = __( 'Teams', 'sportspress' ); }else{ echo '' . __( 'Event', 'sportspress' ) . ''; - $labels[] = __( 'Event', 'sportspress' );} } switch ( $time_format ) { case 'separate': if ( sp_column_active( $usecolumns, 'time' ) ) echo '' . __( 'Time', 'sportspress' ) . ''; - $labels[] = __( 'Time', 'sportspress' ); if ( sp_column_active( $usecolumns, 'results' ) ) echo '' . __( 'Results', 'sportspress' ) . ''; - $labels[] = __( 'Results', 'sportspress' ); break; case 'time': if ( sp_column_active( $usecolumns, 'time' ) ) echo '' . __( 'Time', 'sportspress' ) . ''; - $labels[] = __( 'Time', 'sportspress' ); break; case 'results': if ( sp_column_active( $usecolumns, 'results' ) ) echo '' . __( 'Results', 'sportspress' ) . ''; - $labels[] = __( 'Results', 'sportspress' ); break; default: if ( sp_column_active( $usecolumns, 'time' ) ) echo '' . __( 'Time/Results', 'sportspress' ) . ''; - $labels[] = __( 'Time/Results', 'sportspress' ); } } if ( sp_column_active( $usecolumns, 'league' ) ) echo '' . __( 'League', 'sportspress' ) . ''; - $labels[] = __( 'League', 'sportspress' ); if ( sp_column_active( $usecolumns, 'season' ) ) echo '' . __( 'Season', 'sportspress' ) . ''; - $labels[] = __( 'Season', 'sportspress' ); if ( sp_column_active( $usecolumns, 'venue' ) ) echo '' . __( 'Venue', 'sportspress' ) . ''; - $labels[] = __( 'Venue', 'sportspress' ); if ( sp_column_active( $usecolumns, 'article' ) ) echo '' . __( 'Article', 'sportspress' ) . ''; - $labels[] = __( 'Article', 'sportspress' ); if ( sp_column_active( $usecolumns, 'day' ) ) echo '' . __( 'Match Day', 'sportspress' ) . ''; - $labels[] = __( 'Match Day', 'sportspress' ); do_action( 'sportspress_event_list_head_row', $usecolumns ); ?> @@ -263,17 +246,17 @@ $identifier = uniqid( 'eventlist_' ); if ( $link_events ) $date_html = ''; - echo '' . $date_html . ''; + echo '' . $date_html . ''; switch ( $title_format ) { case 'homeaway': if ( sp_column_active( $usecolumns, 'event' ) ) { $team = array_shift( $teams_array ); - echo '' . $team . ''; + echo '' . $team . ''; } if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) { - echo ''; + echo ''; if ( $link_events ) echo ''; echo ''; } elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) { - echo ''; + echo ''; if ( $link_events ) echo ''; @@ -310,25 +293,25 @@ $identifier = uniqid( 'eventlist_' ); default: if ( sp_column_active( $usecolumns, 'event' ) ) { if ( $title_format == 'teams' ) { - echo '' . $teams_output . ''; + echo '' . $teams_output . ''; } else { $title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title; if ( $link_events ) $title_html = ''; - echo '' . $title_html . ''; + echo '' . $title_html . ''; } } switch ( $time_format ) { case 'separate': if ( sp_column_active( $usecolumns, 'time' ) ) { - echo ''; + echo ''; if ( $link_events ) echo ''; echo ''; } if ( sp_column_active( $usecolumns, 'results' ) ) { - echo ''; + echo ''; if ( $link_events ) echo ''; @@ -350,7 +333,7 @@ $identifier = uniqid( 'eventlist_' ); break; case 'results': if ( sp_column_active( $usecolumns, 'results' ) ) { - echo ''; + echo ''; if ( $link_events ) echo '' . __( 'View all events', 'sportspress' ) . ''; diff --git a/templates/event-performance-table.php b/templates/event-performance-table.php index 228f9bb5..d6deafbe 100644 --- a/templates/event-performance-table.php +++ b/templates/event-performance-table.php @@ -20,10 +20,14 @@ if ( ! isset( $class ) ) $class = null; // Initialize arrays if ( ! isset( $lineups ) ) $lineups = array(); if ( ! isset( $subs ) ) $subs = array(); + $responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; -$rlabels = array(); //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 ); +} ?>
@@ -37,21 +41,19 @@ $identifier = uniqid( 'performance_' ); # - - + - + $label ): ?> - @@ -92,7 +94,7 @@ $identifier = uniqid( 'performance_' ); $number = sp_array_value( $row, 'number', ' ' ); // Player number - echo '' . $number . ''; + echo '' . $number . ''; } if ( $link_posts ): @@ -175,7 +177,7 @@ $identifier = uniqid( 'performance_' ); endif; if ( $mode == 'values' ): - $content .= '' . $value . ''; + $content .= '' . $value . ''; elseif ( intval( $value ) && $mode == 'icons' ): $performance_id = sp_array_value( $performance_ids, $key, null ); $icons = ''; @@ -190,7 +192,7 @@ $identifier = uniqid( 'performance_' ); $name .= ' ' . $position . ''; endif; - echo '' . $name . ''; + echo '' . $name . ''; if ( $mode == 'icons' ): echo '' . $content . ''; @@ -216,10 +218,10 @@ $identifier = uniqid( 'performance_' );  '; + echo ' '; } if ( $mode == 'values' ): - echo '' . __( 'Total', 'sportspress' ) . ''; + echo '' . __( 'Total', 'sportspress' ) . ''; endif; endif; @@ -243,7 +245,11 @@ $identifier = uniqid( 'performance_' ); endif; if ( $mode == 'values' ): - echo '' . $value . ''; + if ($key == 'position'){ + echo '' . $value . ''; + }else{ + echo '' . $value . ''; + } elseif ( intval( $value ) && $mode == 'icons' ): $performance_id = sp_array_value( $performance_ids, $key, null ); $icons = ''; @@ -264,9 +270,4 @@ $identifier = uniqid( 'performance_' );
- - \ No newline at end of file diff --git a/templates/league-table.php b/templates/league-table.php index f2499ce3..499a97fc 100644 --- a/templates/league-table.php +++ b/templates/league-table.php @@ -66,7 +66,7 @@ $data = $table->data(); $labels = $data[0]; // If responsive tables are enabled then load the inline css code 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 unset( $data[0] ); @@ -139,7 +139,7 @@ foreach ( $data as $team_id => $row ): $output .= ''; // Rank - $output .= '' . sp_array_value( $row, 'pos' ) . ''; + $output .= '' . sp_array_value( $row, 'pos' ) . ''; $name_class = ''; @@ -156,13 +156,13 @@ foreach ( $data as $team_id => $row ): $name = '' . $name . ''; endif; - $output .= '' . $name . ''; + $output .= '' . $name . ''; foreach( $labels as $key => $value ): if ( in_array( $key, array( 'pos', 'name' ) ) ) continue; if ( ! is_array( $columns ) || in_array( $key, $columns ) ) - $output .= '' . sp_array_value( $row, $key, '—' ) . ''; + $output .= '' . sp_array_value( $row, $key, '—' ) . ''; endforeach; $output .= ''; diff --git a/templates/player-list.php b/templates/player-list.php index d0fdb791..fc72d42e 100644 --- a/templates/player-list.php +++ b/templates/player-list.php @@ -56,11 +56,12 @@ $data = $list->data(); // The first row should be column labels $labels = $data[0]; + //Create a unique identifier based on the current time in microseconds $identifier = uniqid( 'playerlist_' ); // If responsive tables are enabled then load the inline css code 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 unset( $data[0] ); @@ -136,9 +137,9 @@ foreach ( $groups as $group ): // Rank or number if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ): if ( isset( $orderby ) && $orderby != 'number' ): - $tbody .= '' . ( $i + 1 ) . ''; + $tbody .= '' . ( $i + 1 ) . ''; else: - $tbody .= '' . sp_array_value( $row, 'number', ' ' ) . ''; + $tbody .= '' . sp_array_value( $row, 'number', ' ' ) . ''; endif; endif; @@ -168,7 +169,7 @@ foreach ( $groups as $group ): $name = '' . $name . ''; endif; - $tbody .= '' . $name . ''; + $tbody .= '' . $name . ''; if ( array_key_exists( 'team', $labels ) ): $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 ) ): $team_name = '' . $team_name . ''; endif; - $tbody .= '' . $team_name . ''; + $tbody .= '' . $team_name . ''; endif; 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 ); $positions = sp_array_value( $position_term, 'name', '—' ); endif; - $tbody .= '' . $positions . ''; + $tbody .= '' . $positions . ''; endif; foreach( $labels as $key => $value ): if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) ) continue; if ( ! is_array( $columns ) || in_array( $key, $columns ) ) - $tbody .= '' . sp_array_value( $row, $key, '—' ) . ''; + $tbody .= '' . sp_array_value( $row, $key, '—' ) . ''; endforeach; $tbody .= '';