diff --git a/includes/WPStrava/ActivityShortcode.php b/includes/WPStrava/ActivityShortcode.php index 4591af4..eb63ad3 100644 --- a/includes/WPStrava/ActivityShortcode.php +++ b/includes/WPStrava/ActivityShortcode.php @@ -52,13 +52,13 @@ public function handler( $atts ) { $this->add_script = true; $defaults = array( - 'id' => 0, - 'som' => WPStrava::get_instance()->settings->som, - 'map_width' => '480', - 'map_height' => '320', - 'client_id' => WPStrava::get_instance()->settings->get_default_id(), - 'markers' => false, - 'image_only' => false, + 'id' => 0, + 'som' => WPStrava::get_instance()->settings->som, + 'map_width' => '480', + 'map_height' => '320', + 'client_id' => WPStrava::get_instance()->settings->get_default_id(), + 'markers' => false, + 'image_only' => false, ); $atts = shortcode_atts( $defaults, $atts, 'activity' ); diff --git a/includes/WPStrava/LatestActivities.php b/includes/WPStrava/LatestActivities.php index a6c0f49..3a96618 100644 --- a/includes/WPStrava/LatestActivities.php +++ b/includes/WPStrava/LatestActivities.php @@ -35,9 +35,10 @@ public static function get_activities_html( $args ) { $response .= "
"; if ( ! empty( $activity->start_date_local ) ) { - $unixtime = strtotime( $activity->start_date_local ); - // Translators: Shows something like "On <[went 10 miles] [during 2 hours] [climbing 100 feet]>." - $response .= sprintf( __( 'On %1$s %2$s', 'wp-strava' ), + $unixtime = strtotime( $activity->start_date_local ); + $response .= sprintf( + // Translators: Shows something like "On <[went 10 miles] [during 2 hours] [climbing 100 feet]>." + __( 'On %1$s %2$s', 'wp-strava' ), date_i18n( get_option( 'date_format' ), $unixtime ), self::get_activity_time( $unixtime ) ); diff --git a/includes/WPStrava/LatestActivitiesWidget.php b/includes/WPStrava/LatestActivitiesWidget.php index ee259d9..ea4b4c5 100644 --- a/includes/WPStrava/LatestActivitiesWidget.php +++ b/includes/WPStrava/LatestActivitiesWidget.php @@ -16,7 +16,7 @@ public function __construct() { public function maybe_enqueue() { if ( is_active_widget( false, false, $this->id_base ) ) { - wp_enqueue_style( 'wp-strava-style' ); //only load this when wigit is loaded + wp_enqueue_style( 'wp-strava-style' ); // Only load this when widget is loaded. } } @@ -41,9 +41,9 @@ public function widget( $args, $instance ) { /** @see WP_Widget::update */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; - $instance['title'] = strip_tags( $new_instance['title'] ); - $instance['client_id'] = strip_tags( $new_instance['client_id'] ); - $instance['strava_club_id'] = strip_tags( $new_instance['strava_club_id'] ); + $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); + $instance['client_id'] = wp_strip_all_tags( $new_instance['client_id'] ); + $instance['strava_club_id'] = wp_strip_all_tags( $new_instance['strava_club_id'] ); $instance['quantity'] = $new_instance['quantity']; return $instance; diff --git a/includes/WPStrava/LatestMapWidget.php b/includes/WPStrava/LatestMapWidget.php index 76262b2..3f8922e 100644 --- a/includes/WPStrava/LatestMapWidget.php +++ b/includes/WPStrava/LatestMapWidget.php @@ -55,10 +55,10 @@ public function form( $instance ) { public function update( $new_instance, $old_instance ) { // Processes widget options to be saved from the admin. $instance = $old_instance; - $instance['title'] = strip_tags( $new_instance['title'] ); - $instance['client_id'] = strip_tags( $new_instance['client_id'] ); - $instance['strava_club_id'] = strip_tags( $new_instance['strava_club_id'] ); - $instance['distance_min'] = strip_tags( $new_instance['distance_min'] ); + $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); + $instance['client_id'] = wp_strip_all_tags( $new_instance['client_id'] ); + $instance['strava_club_id'] = wp_strip_all_tags( $new_instance['strava_club_id'] ); + $instance['distance_min'] = wp_strip_all_tags( $new_instance['distance_min'] ); return $instance; } @@ -97,6 +97,7 @@ public function widget( $args, $instance ) { try { $activities = $strava_activity->get_activities( $client_id, $strava_club_id ); } catch ( WPStrava_Exception $e ) { + // If athlete_token is still set, warn about that first and foremost. if ( isset( $instance['athlete_token'] ) ) { // Translators: Message shown when using deprecated athlete_token parameter. echo wp_kses_post( __( 'The athlete_token parameter is deprecated as of WP-Strava version 2 and should be replaced with client_id.', 'wp-strava' ) ); diff --git a/includes/WPStrava/Settings.php b/includes/WPStrava/Settings.php index 3bc37e4..dd76c98 100644 --- a/includes/WPStrava/Settings.php +++ b/includes/WPStrava/Settings.php @@ -580,8 +580,9 @@ public function add_id( $id ) { public function save_info( $id, $secret, $info ) { $infos = get_option( 'strava_info', array() ); $infos = array_filter( $infos, array( $this, 'filter_by_id' ), ARRAY_FILTER_USE_KEY ); // Remove old IDs. + $info->client_secret = $secret; - $infos[ $id ] = $info; + $infos[ $id ] = $info; update_option( 'strava_info', $infos ); }