-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from cmanon/feature/14-responsive-tables
Feature/14 responsive tables
- Loading branch information
Showing
9 changed files
with
119 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ public function get_html( $atts ) { | |
/** | ||
* The the activity details in in HTML table. | ||
* | ||
* @param string $activity_details Activity details from the activity class. | ||
* @param stdClass $activity_details Activity details from the activity class. | ||
* @param string $som System of measure (english/metric). | ||
* @return string HTML Table of activity details. | ||
* @author Justin Foell <[email protected]> | ||
|
@@ -80,27 +80,42 @@ private function get_table( $activity_details, $som ) { | |
$avg_title = '<th>' . __( 'Average Speed', 'wp-strava' ) . '</th>'; | ||
$max_title = '<th>' . __( 'Max Speed', 'wp-strava' ) . '</th>'; | ||
$elevation_title = '<th>' . __( 'Elevation Gain', 'wp-strava' ) . '</th>'; | ||
$elevation = '<td data-label="' . __( 'Elevation Gain', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->elevation( $activity_details->total_elevation_gain ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_elevation_label() . '</div> | ||
</td>'; | ||
$avg_speed = ''; | ||
$max_speed = ''; | ||
$elevation = '<td>' . $strava_som->elevation( $activity_details->total_elevation_gain ) . '</td>'; | ||
$speed_label = ''; | ||
$elevation_label = '<td>' . $strava_som->get_elevation_label() . '</td>'; | ||
|
||
switch ( $strava_activitytype ) { | ||
case WPStrava_ActivityType::TYPE_GROUP_PACE: | ||
$avg_speed = '<td>' . $strava_som->pace( $activity_details->average_speed ) . '</td>'; | ||
$max_speed = '<td>' . $strava_som->pace( $activity_details->max_speed ) . '</td>'; | ||
$speed_label = '<td>' . $strava_som->get_pace_label() . '</td>'; | ||
$avg_speed = '<td data-label="' . __( 'Average Speed', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->pace( $activity_details->average_speed ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_pace_label() . '</div> | ||
</td>'; | ||
$max_speed = '<td data-label="' . __( 'Max Speed', 'wp-strava' ) . '"> | ||
<div>' . $strava_som->pace( $activity_details->max_speed ) . '</div> | ||
</td>'; | ||
break; | ||
case WPStrava_ActivityType::TYPE_GROUP_SPEED: | ||
$avg_speed = '<td>' . $strava_som->speed( $activity_details->average_speed ) . '</td>'; | ||
$max_speed = '<td>' . $strava_som->speed( $activity_details->max_speed ) . '</td>'; | ||
$speed_label = '<td>' . $strava_som->get_speed_label() . '</td>'; | ||
$avg_speed = '<td data-label="' . __( 'Average Speed', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->speed( $activity_details->average_speed ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_speed_label() . '</div> | ||
</td>'; | ||
$max_speed = '<td data-label="' . __( 'Max Speed', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->speed( $activity_details->max_speed ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_speed_label() . '</div> | ||
</td>'; | ||
break; | ||
case WPStrava_ActivityType::TYPE_GROUP_PACE: | ||
$avg_speed = '<td>' . $strava_som->swimpace( $activity_details->average_speed ) . '</td>'; | ||
$max_speed = '<td>' . $strava_som->swimpace( $activity_details->max_speed ) . '</td>'; | ||
$speed_label = '<td>' . $strava_som->get_swimpace_label() . '</td>'; | ||
$avg_speed = '<td data-label="' . __( 'Average Speed', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->swimpace( $activity_details->average_speed ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_swimpace_label() . '</div> | ||
</td>'; | ||
$max_speed = '<td data-label="' . __( 'Max Speed', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->swimpace( $activity_details->max_speed ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_swimpace_label() . '</div> | ||
</td>'; | ||
break; | ||
default: | ||
$avg_title = ''; | ||
|
@@ -109,13 +124,12 @@ private function get_table( $activity_details, $som ) { | |
} | ||
|
||
if ( WPStrava::get_instance()->settings->hide_elevation ) { | ||
$elevation = ''; | ||
$elevation_title = ''; | ||
$elevation_label = ''; | ||
$elevation = ''; | ||
} | ||
|
||
return ' | ||
<table id="activity-details-table"> | ||
<table class="activity-details-table"> | ||
<thead> | ||
<tr> | ||
<th>' . __( 'Elapsed Time', 'wp-strava' ) . '</th> | ||
|
@@ -127,22 +141,23 @@ private function get_table( $activity_details, $som ) { | |
</tr> | ||
</thead> | ||
<tbody> | ||
<tr class="activity-details-table-info"> | ||
<td>' . $strava_som->time( $activity_details->elapsed_time ) . '</td> | ||
<td>' . $strava_som->time( $activity_details->moving_time ) . '</td> | ||
<td>' . $strava_som->distance( $activity_details->distance ) . '</td> | ||
<tr> | ||
<td data-label="' . __( 'Elapsed Time', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->time( $activity_details->elapsed_time ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_time_label() . '</div> | ||
</td> | ||
<td data-label="' . __( 'Moving Time', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->time( $activity_details->moving_time ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_time_label() . '</div> | ||
</td> | ||
<td data-label="' . __( 'Distance', 'wp-strava' ) . '"> | ||
<div class="activity-details-table-info">' . $strava_som->distance( $activity_details->distance ) . '</div> | ||
<div class="activity-details-table-units">' . $strava_som->get_distance_label() . '</div> | ||
</td> | ||
' . $avg_speed . ' | ||
' . $max_speed . ' | ||
' . $elevation . ' | ||
</tr> | ||
<tr class="activity-details-table-units"> | ||
<td>' . $strava_som->get_time_label() . '</td> | ||
<td>' . $strava_som->get_time_label() . '</td> | ||
<td>' . $strava_som->get_distance_label() . '</td> | ||
' . $speed_label . ' | ||
' . $speed_label . ' | ||
' . $elevation_label . ' | ||
</tr> | ||
</tbody> | ||
</table> | ||
'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ public function handler( $atts ) { | |
/** | ||
* The the route details in in HTML table. | ||
* | ||
* @param string $route_details route details from the route class. | ||
* @param stdClass $route_details route details from the route class. | ||
* @param string $som System of measure (english/metric). | ||
* @return string HTML Table of route details. | ||
* @author Justin Foell <[email protected]> | ||
|
@@ -122,7 +122,7 @@ private function get_table( $route_details, $som ) { | |
} | ||
|
||
return ' | ||
<table id="activity-details-table"> | ||
<table class="activity-details-table"> | ||
<thead> | ||
<tr> | ||
<th>' . __( 'Est. Moving Time', 'wp-strava' ) . '</th> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,10 +236,19 @@ public function print_nickname_input() { | |
* @since 2.0.0 | ||
*/ | ||
public function print_id_input() { | ||
$first = true; | ||
foreach ( $this->get_all_ids() as $id => $nickname ) { | ||
?> | ||
<input type="text" name="strava_id[]" value="<?php echo esc_attr( $id ); ?>" /> | ||
<input type="text" name="strava_nickname[]" value="<?php echo esc_attr( $nickname ); ?>" /> | ||
<?php | ||
if ( $first ) : | ||
?> | ||
<span class="default-id"><?php esc_html_e( 'Default', 'wp-strava' ); ?></span> | ||
<?php | ||
endif; | ||
$first = false; | ||
?> | ||
<br/> | ||
<?php | ||
} | ||
|
@@ -408,7 +417,7 @@ public function sanitize_som( $som ) { | |
public function print_hide_time_input() { | ||
?> | ||
<label for="strava_hide_time"><input type="checkbox" id="strava_hide_time" name="strava_hide_time" <?php checked( $this->hide_time, 'on' ); ?>/> | ||
<?php _e( 'Do not show time on activities', 'wp-strava' ); ?></label> | ||
<?php esc_html_e( 'Do not show time on activities', 'wp-strava' ); ?></label> | ||
<?php | ||
} | ||
|
||
|
@@ -436,7 +445,7 @@ public function sanitize_hide_time( $checked ) { | |
public function print_hide_elevation_input() { | ||
?> | ||
<label for="strava_hide_elevation"><input type="checkbox" id="strava_hide_elevation" name="strava_hide_elevation" <?php checked( $this->hide_elevation, 'on' ); ?>/> | ||
<?php _e( 'Do not show elevation on activities', 'wp-strava' ); ?></label> | ||
<?php esc_html_e( 'Do not show elevation on activities', 'wp-strava' ); ?></label> | ||
<?php | ||
} | ||
|
||
|
@@ -464,7 +473,7 @@ public function sanitize_hide_elevation( $checked ) { | |
public function print_no_link_input() { | ||
?> | ||
<label for="strava_no_link"><input type="checkbox" id="strava_no_link" name="strava_no_link" <?php checked( $this->no_link, 'on' ); ?>/> | ||
<?php _e( 'Do not link activities to Strava.com', 'wp-strava' ); ?></label> | ||
<?php esc_html_e( 'Do not link activities to Strava.com', 'wp-strava' ); ?></label> | ||
<?php | ||
} | ||
|
||
|
@@ -492,8 +501,8 @@ public function sanitize_no_link( $checked ) { | |
public function print_clear_input() { | ||
?> | ||
<label for="strava_cache_clear"><input type="checkbox" id="strava_cache_clear" name="strava_cache_clear" /> | ||
<?php _e( 'Clear cached image and transient data', 'wp-strava' ); ?></label> | ||
<p class="description"><?php _e( 'To clear cache, check this box and click "Save Changes"' ); ?></p> | ||
<?php esc_html_e( 'Clear cached image and transient data', 'wp-strava' ); ?></label> | ||
<p class="description"><?php esc_html_e( 'To clear cache, check this box and click "Save Changes"' ); ?></p> | ||
<?php | ||
} | ||
|
||
|
@@ -560,7 +569,7 @@ public function get_default_id() { | |
/** | ||
* Get all IDs and their nicknames in one array. | ||
* | ||
* @return void | ||
* @return array Array of IDs and nicknames. | ||
* @author Justin Foell <[email protected]> | ||
* @since 2.0.0 | ||
*/ | ||
|
@@ -644,7 +653,8 @@ public function add_id( $id ) { | |
* @since 2.0.0 | ||
*/ | ||
public function save_info( $id, $secret, $info ) { | ||
$infos = get_option( 'strava_info', array() ); | ||
$infos = get_option( 'strava_info' ); | ||
$infos = empty( $infos ) ? array() : $infos; | ||
$infos = array_filter( $infos, array( $this, 'filter_by_id' ), ARRAY_FILTER_USE_KEY ); // Remove old IDs. | ||
|
||
$info->client_secret = $secret; | ||
|
@@ -661,7 +671,7 @@ public function save_info( $id, $secret, $info ) { | |
* @since 2.0.0 | ||
*/ | ||
public function filter_by_id( $key ) { | ||
if ( in_array( $key, $this->ids ) ) { | ||
if ( in_array( $key, $this->ids ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- Loose comparison OK. | ||
return true; | ||
} | ||
return false; | ||
|