mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-14 04:06:48 +09:00
Added refresh cron and refresh method
This commit is contained in:
@@ -24,8 +24,10 @@ abstract class WPStrava_Auth {
|
||||
abstract protected function get_authorize_url( $client_id );
|
||||
|
||||
public function hook() {
|
||||
add_filter( 'pre_set_transient_settings_errors', array( $this, 'maybe_oauth' ) );
|
||||
add_action( 'admin_init', array( $this, 'init' ) );
|
||||
if ( is_admin() ) {
|
||||
add_filter( 'pre_set_transient_settings_errors', array( $this, 'maybe_oauth' ) );
|
||||
add_action( 'admin_init', array( $this, 'init' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,11 +94,13 @@ abstract class WPStrava_Auth {
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
$data = $this->add_initial_params( $data );
|
||||
|
||||
$strava_info = $this->token_request( $data );
|
||||
|
||||
if ( isset( $strava_info->access_token ) ) {
|
||||
$settings->add_id( $client_id );
|
||||
$settings->save_info( $client_id, $strava_info );
|
||||
$settings->save_info( $client_id, $client_secret, $strava_info );
|
||||
|
||||
$this->feedback .= __( 'Successfully authenticated.', 'wp-strava' );
|
||||
return $strava_info;
|
||||
@@ -117,4 +121,8 @@ abstract class WPStrava_Auth {
|
||||
return $api->post( 'oauth/token', $data );
|
||||
}
|
||||
|
||||
protected function add_initial_params( $data ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user