Skip to content

Commit

Permalink
Merge pull request #114 from cmanon/feature/109-error-unauthorized
Browse files Browse the repository at this point in the history
Feature/109 error unauthorized
  • Loading branch information
jrfoell authored Sep 24, 2021
2 parents 0556c90 + 3b78e20 commit 1bf67c4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: cmanon, jrfoell, lancewillett, dlintott, sebastianerb
Tags: strava, activity, bicycle, cycling, biking, running, run, swimming, swim, paddle, kayak, gps, shortcode, widget, plugin, block, blocks
Requires at least: 4.6
Tested up to: 5.8
Stable tag: 2.10.0
Stable tag: 2.10.1
Requires PHP: 5.3
License: GPLv2 or later

Expand Down Expand Up @@ -134,6 +134,10 @@ On the WP-Strava settings page you cannot currently remove and add another athle

== Changelog ==

= 2.10.1 =
Reworked settings save with multiple athletes, related to https://wordpress.org/support/topic/wp-strava-error-401-unauthorized/


= 2.10.0 =
Add ability to paste Activity/Route/Segment URL into the block editor and have it insert the appropriate block https://wordpress.org/support/topic/sorry-this-content-could-not-be-embedded-5/
Add `reduce_polyline()` for maps with large polylines but no summary provided (prevents empty map) https://wordpress.org/support/topic/map-embed-from-segment-shows-default-map/
Expand Down
58 changes: 50 additions & 8 deletions src/WPStrava/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ public function sanitize_nickname( $nicknames ) {
}
}

// Process $nicknames so indexes start with zero.
$nicknames = array_merge( $nicknames, array() );
// Rebase array keys after unset.
$nicknames = array_values( $nicknames );
}

foreach ( $nicknames as $index => $nickname ) {
Expand All @@ -351,13 +351,54 @@ public function sanitize_nickname( $nicknames ) {
*
* Renamed from sanitize_token().
*
* @param string $id Client ID.
* @return string
* @param array $ids Client IDs.
* @return array
* @author Justin Foell <[email protected]>
* @since 2.0
*/
public function sanitize_id( $id ) {
return $id;
public function sanitize_id( $ids ) {
$this->get_ids();

if ( ! is_array( $ids ) ) {
$ids = array( $ids );
}

// Filter empty IDs.
$ids = array_filter( $ids );

// Rebase array keys after unset.
$ids = array_values( $ids );

$this->maybe_clean_info( $ids );

$this->ids = $ids;

return $ids;
}

/**
* Remove IDs from strava_info that are being deleted.
*
* @param array $ids IDs that we're keeping.
* @author Justin Foell <[email protected]>
* @since 2.10.1
*/
private function maybe_clean_info( $ids ) {
$update = false;

$infos = $this->info;

foreach ( $infos as $id => $info ) {
if ( ! in_array( $id, $ids ) ) {
$update = true;
unset( $infos[ $id ] );
}
}

if ( $update ) {
update_option( 'strava_info', $infos );
}

}

/**
Expand Down Expand Up @@ -584,10 +625,11 @@ public function get_ids() {
foreach ( $ids as $index => $id ) {
if ( empty( $id ) ) {
unset( $ids[ $index ] );
$ids = array_values( $ids ); // Rebase array keys after unset @see https://stackoverflow.com/a/5943165/2146022
}
}
$this->ids = $ids;

// Rebase array keys after unset @see https://stackoverflow.com/a/5943165/2146022
$this->ids = array_values( $ids );
return $this->ids;
}

Expand Down
4 changes: 2 additions & 2 deletions wp-strava.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Strava
* Plugin URI: https://wordpress.org/plugins/wp-strava/
* Description: Show your strava.com activity on your WordPress site. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
* Version: 2.10.0
* Version: 2.10.1
* Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott, Sebastian Erb
* License: GPL2
* Text Domain: wp-strava
Expand All @@ -27,7 +27,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

define( 'WPSTRAVA_PLUGIN_VERSION', '2.10.0' );
define( 'WPSTRAVA_PLUGIN_VERSION', '2.10.1' );
define( 'WPSTRAVA_PLUGIN_FILE', __FILE__ );
define( 'WPSTRAVA_PLUGIN_DIR', trailingslashit( dirname( __FILE__ ) ) );
define( 'WPSTRAVA_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
Expand Down

0 comments on commit 1bf67c4

Please sign in to comment.