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 );