Adding function prefix and extra table class

1) Add sportspress_ prefix to the function name.
2) Insert a new class selector to the responsive tables (sp-responsive-table) for future use.
This commit is contained in:
savvasha
2017-11-30 19:22:53 +02:00
parent bc0ee7a295
commit a7ff15ff59
5 changed files with 18 additions and 35 deletions

View File

@@ -507,7 +507,7 @@ function sportspress_output_br_tag() {
<br>
<?php
}
if ( ! function_exists( 'responsive_tables_css' ) ) {
if ( ! function_exists( 'sportspress_responsive_tables_css' ) ) {
/**
* Output the inlince css code for responsive tables.
@@ -516,7 +516,7 @@ if ( ! function_exists( 'responsive_tables_css' ) ) {
* @subpackage Responsive
* @return void
*/
function responsive_tables_css($vars) {
function sportspress_responsive_tables_css($vars) {
$custom_css = '/*
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
@@ -527,12 +527,12 @@ if ( ! function_exists( 'responsive_tables_css' ) ) {
(min-device-width: 768px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
table.sp-responsive-table, table.sp-responsive-table thead, table.sp-responsive-table tbody, table.sp-responsive-table th, table.sp-responsive-table td, table.sp-responsive-table tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
table.sp-responsive-table thead tr {
position: absolute;
top: -9999px;
left: -9999px;
@@ -545,9 +545,9 @@ if ( ! function_exists( 'responsive_tables_css' ) ) {
text-align: center !important;
}
tr { border: 1px solid #ccc; }
table.sp-responsive-table tr { border: 1px solid #ccc; }
td {
table.sp-responsive-table td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
@@ -555,7 +555,7 @@ if ( ! function_exists( 'responsive_tables_css' ) ) {
padding-left: 50%;
}
td:before {
table.sp-responsive-table td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
@@ -566,7 +566,7 @@ if ( ! function_exists( 'responsive_tables_css' ) ) {
white-space: nowrap;
}
/* Zebra striping */
tr:nth-of-type(odd) {
table.sp-responsive-table tr:nth-of-type(odd) {
background: #eee !important;
}
@@ -575,28 +575,11 @@ if ( ! function_exists( 'responsive_tables_css' ) ) {
*/';
$k=1;
foreach ($vars as $label) {
$custom_css .= 'td:nth-of-type('.$k.'):before { content: "'.$label.'"; }';
$custom_css .= 'table.sp-responsive-table td:nth-of-type('.$k.'):before { content: "'.$label.'"; }';
$k++;
}
$custom_css .= '
}
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
body {
padding: 0;
margin: 0;
width: 320px; }
}
/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
body {
width: 495px;
}
}';
wp_register_style( 'sportspress-style-inline', false );
wp_enqueue_style( 'sportspress-style-inline' );
wp_add_inline_style( 'sportspress-style-inline', $custom_css );

View File

@@ -99,7 +99,7 @@ $labels = array();
<h4 class="sp-table-caption"><?php echo $title; ?></h4>
<?php } ?>
<div class="sp-table-wrapper">
<table class="sp-event-list sp-event-list-format-<?php echo $title_format; ?> sp-data-table<?php if ( $paginated ) { ?> sp-paginated-table<?php } if ( $sortable ) { ?> sp-sortable-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>" data-sp-rows="<?php echo $rows; ?>">
<table class="sp-event-list sp-event-list-format-<?php echo $title_format; ?> sp-data-table<?php if ( $paginated ) { ?> sp-paginated-table<?php } if ( $sortable ) { ?> sp-sortable-table<?php } if ( $responsive ) { ?> sp-responsive-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>" data-sp-rows="<?php echo $rows; ?>">
<thead>
<tr>
<?php
@@ -451,7 +451,7 @@ $labels = array();
//var_dump($labels);
// If responsive tables are enabled then load the inline css code
if ($responsive == true){
responsive_tables_css($labels);
sportspress_responsive_tables_css($labels);
}
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>';

View File

@@ -28,7 +28,7 @@ $rlabels = array();
<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 } ?><?php 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 ) { ?> sp-responsive-table<?php } ?><?php if ( $sortable ) { ?> sp-sortable-table<?php } ?><?php } ?>">
<thead>
<tr>
<?php if ( $mode == 'values' ): ?>
@@ -266,5 +266,5 @@ $rlabels = array();
<?php
// If responsive tables are enabled then load the inline css code
if ($responsive == true && $mode == 'values'){
responsive_tables_css($rlabels);
sportspress_responsive_tables_css($rlabels);
}

View File

@@ -55,7 +55,7 @@ if ( $title )
$output .= '<div class="sp-table-wrapper">';
$output .= '<table class="sp-league-table sp-data-table' . ( $sortable ? ' sp-sortable-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' : '' ). ( $scrollable ? ' sp-scrollable-table' : '' ) . ( $paginated ? ' sp-paginated-table' : '' ) . '" data-sp-rows="' . $rows . '">' . '<thead>' . '<tr>';
$data = $table->data();
@@ -63,7 +63,7 @@ $data = $table->data();
$labels = $data[0];
// If responsive tables are enabled then load the inline css code
if ($responsive == true){
responsive_tables_css($labels);
sportspress_responsive_tables_css($labels);
}
// Remove the first row to leave us with the actual data
unset( $data[0] );

View File

@@ -58,7 +58,7 @@ $data = $list->data();
$labels = $data[0];
// If responsive tables are enabled then load the inline css code
if ($responsive == true){
responsive_tables_css($labels);
sportspress_responsive_tables_css($labels);
}
// Remove the first row to leave us with the actual data
unset( $data[0] );
@@ -211,7 +211,7 @@ foreach ( $groups as $group ):
endif;
$output .= '<div class="sp-table-wrapper">' .
'<table class="sp-player-list sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ) . ( $scrollable ? ' sp-scrollable-table' : '' ) . ( $paginated ? ' sp-paginated-table' : '' ) . '" data-sp-rows="' . $rows . '">' . '<thead>' . '<tr>';
'<table class="sp-player-list 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>';
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ):
if ( in_array( $orderby, array( 'number', 'name' ) ) ):