Added refresh cron and refresh method

This commit is contained in:
Justin Foell
2019-06-03 14:27:14 -05:00
parent 15de60d764
commit cfdf3aae9e
5 changed files with 128 additions and 15 deletions
+21 -4
View File
@@ -398,18 +398,35 @@ class WPStrava_Settings {
/**
* Undocumented function
*
* @param [type] $id
* @param [type] $info
* @return void
* @param int $id Strava API Client ID
* @param string $secret Strava API Client Secret
* @param stdClass $info
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since 2.0.0
*/
public function save_info( $id, $info ) {
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;
update_option( 'strava_info', $infos );
}
/**
* array_filter() callback to remove info for IDs we no longer have.
*
* @param int $key Strava Client ID
* @return boolean True if Client ID is in $this->ids, false otherwise.
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since 2.0.0
*/
public function filter_by_id( $key ) {
if ( in_array( $key, $this->ids ) ) {
return true;
}
return false;
}
/**
* Undocumented function
*