diff --git a/src/WPStrava/Settings.php b/src/WPStrava/Settings.php index 0035b5a..cd341c2 100644 --- a/src/WPStrava/Settings.php +++ b/src/WPStrava/Settings.php @@ -692,7 +692,9 @@ class WPStrava_Settings { public function save_info( $id, $secret, $info ) { $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. + + array_walk( $infos, array( $this, 'filter_by_id' ) ); + $infos = array_filter( $infos ); $info->client_secret = $secret; $infos[ $id ] = $info; @@ -700,19 +702,19 @@ class WPStrava_Settings { } /** - * array_filter() callback to remove info for IDs we no longer have. + * array_walk() callback to clear IDs we no longer want. * * @param int $key Strava Client ID - * @return boolean True if Client ID is in $this->ids, false otherwise. * @author Justin Foell * @since 2.0.0 */ - public function filter_by_id( $key ) { + public function filter_by_id( &$value, $key ) { $ids = $this->get_ids(); if ( in_array( $key, $ids ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- Loose comparison OK. - return true; + return; } - return false; + + $value = null; } /**