Target specific tables by adding a unique class name

Using the uniqid function of PHP (http://www.php.net/manual/en/function.uniqid.php)
This commit is contained in:
savvasha
2017-11-30 19:43:50 +02:00
parent a7ff15ff59
commit 8d2b504fb8
5 changed files with 29 additions and 20 deletions

View File

@@ -48,6 +48,9 @@ if ( $show_title && false === $title && $id ):
$title = get_the_title( $id );
endif;
//Create a unique identifier based on the current time in microseconds
$identifier = uniqid('table_');
$output = '';
if ( $title )
@@ -55,7 +58,7 @@ if ( $title )
$output .= '<div class="sp-table-wrapper">';
$output .= '<table class="sp-league-table sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ) . ( $responsive ? ' sp-responsive-table' : '' ). ( $scrollable ? ' sp-scrollable-table' : '' ) . ( $paginated ? ' sp-paginated-table' : '' ) . '" data-sp-rows="' . $rows . '">' . '<thead>' . '<tr>';
$output .= '<table class="sp-league-table sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ) . ( $responsive ? ' sp-responsive-table '.$identifier : '' ). ( $scrollable ? ' sp-scrollable-table' : '' ) . ( $paginated ? ' sp-paginated-table' : '' ) . '" data-sp-rows="' . $rows . '">' . '<thead>' . '<tr>';
$data = $table->data();
@@ -63,7 +66,7 @@ $data = $table->data();
$labels = $data[0];
// If responsive tables are enabled then load the inline css code
if ($responsive == true){
sportspress_responsive_tables_css($labels);
sportspress_responsive_tables_css($labels,$identifier);
}
// Remove the first row to leave us with the actual data
unset( $data[0] );