From b617842c844986e1beaefa8b96aee90235c20881 Mon Sep 17 00:00:00 2001 From: Justin Foell <630830+jrfoell@users.noreply.github.com> Date: Mon, 2 Nov 2020 10:53:53 -0600 Subject: [PATCH] Skeletal StyleTranslations class, CSS fixes --- css/wp-strava.css | 6 ++-- src/WPStrava.php | 10 +++++- src/WPStrava/ActivityRenderer.php | 2 +- src/WPStrava/RouteShortcode.php | 2 +- src/WPStrava/StyleTranslations.php | 50 ++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 src/WPStrava/StyleTranslations.php diff --git a/css/wp-strava.css b/css/wp-strava.css index 03574ac..7c1aea6 100755 --- a/css/wp-strava.css +++ b/css/wp-strava.css @@ -12,15 +12,15 @@ display: table; margin: 0 auto; } -#activity-details-table tr td { +.activity-details-table tr td { padding: 5px; } -#activity-details-table th { +.activity-details-table th { padding: 5px; text-align: center; font-size: 0.8em; } -#activity-details-table td { +.activity-details-table td { text-align: center; border: 1px solid #e7e7e7; } diff --git a/src/WPStrava.php b/src/WPStrava.php index 5b8c18b..c15be54 100644 --- a/src/WPStrava.php +++ b/src/WPStrava.php @@ -41,6 +41,12 @@ class WPStrava { */ private $routes = null; + /** + * Style Translation object for responsive tables. + * @var WPStrava_StyleTranslations + */ + private $style_translations = null; + /** * Private constructor (singleton). */ @@ -78,7 +84,9 @@ class WPStrava { if ( is_admin() ) { $this->settings->hook(); - } else { + } else { // Front-end. + $this->style_translations = new WPStrava_StyleTranslations(); + $this->style_translations->hook(); add_action( 'init', array( $this, 'register_shortcodes' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); } diff --git a/src/WPStrava/ActivityRenderer.php b/src/WPStrava/ActivityRenderer.php index a286606..6a94040 100644 --- a/src/WPStrava/ActivityRenderer.php +++ b/src/WPStrava/ActivityRenderer.php @@ -115,7 +115,7 @@ class WPStrava_ActivityRenderer { } return ' - +
diff --git a/src/WPStrava/RouteShortcode.php b/src/WPStrava/RouteShortcode.php index 65ee859..1c62cfd 100644 --- a/src/WPStrava/RouteShortcode.php +++ b/src/WPStrava/RouteShortcode.php @@ -122,7 +122,7 @@ class WPStrava_RouteShortcode { } return ' -
' . __( 'Elapsed Time', 'wp-strava' ) . '
+
diff --git a/src/WPStrava/StyleTranslations.php b/src/WPStrava/StyleTranslations.php new file mode 100644 index 0000000..3bab331 --- /dev/null +++ b/src/WPStrava/StyleTranslations.php @@ -0,0 +1,50 @@ + + * @since 2.4 + */ + public function hook() { + add_action( 'wp_head', array( $this, 'print_style_translations' ) ); + } + + /** + * Add translation text to column header, identified by class. + * + * @param [type] $class CSS class for table data (
' . __( 'Est. Moving Time', 'wp-strava' ) . '). + * @param [type] $translation Text to add to column. + * @author Justin Foell + * @since 2.4 + */ + public function add_style_translation( $class, $translation ) { + $this->style_translations[ $class ] = $translation; + } + /** + * Print translatable strings as "; + } + +}