mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-20 15:14:06 +09:00
Skeletal StyleTranslations class, CSS fixes
This commit is contained in:
@@ -115,7 +115,7 @@ class WPStrava_ActivityRenderer {
|
||||
}
|
||||
|
||||
return '
|
||||
<table id="activity-details-table">
|
||||
<table class="activity-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>' . __( 'Elapsed Time', 'wp-strava' ) . '</th>
|
||||
|
||||
@@ -122,7 +122,7 @@ class WPStrava_RouteShortcode {
|
||||
}
|
||||
|
||||
return '
|
||||
<table id="activity-details-table">
|
||||
<table class="activity-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>' . __( 'Est. Moving Time', 'wp-strava' ) . '</th>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class WPStrava_StyleTranslations {
|
||||
|
||||
/**
|
||||
* Translations indexed by class.
|
||||
* @var array
|
||||
*/
|
||||
private $style_translations = array();
|
||||
|
||||
/**
|
||||
* Hook into wp_head.
|
||||
*
|
||||
* @author Justin Foell <justin@foell.org>
|
||||
* @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 (<td>).
|
||||
* @param [type] $translation Text to add to column.
|
||||
* @author Justin Foell <justin@foell.org>
|
||||
* @since 2.4
|
||||
*/
|
||||
public function add_style_translation( $class, $translation ) {
|
||||
$this->style_translations[ $class ] = $translation;
|
||||
}
|
||||
/**
|
||||
* Print translatable strings as <style> in <head>.
|
||||
*
|
||||
* @author Justin Foell <justin@foell.org>
|
||||
* @since 2.4
|
||||
*/
|
||||
public function print_style_translations() {
|
||||
if ( empty( $this->style_translations ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$style = '';
|
||||
foreach ( $this->style_translations as $class => $translation ) {
|
||||
$style .= ".{$class}:before { content: \"{$translation}\"; }\n";
|
||||
}
|
||||
echo "<style>\n{$style}</style>";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user