| @@ -15,8 +15,23 @@ | ||
| 15 | 15 | // Only WordPress and PHP methods can be used. Plugin classes and methods |
| 16 | 16 | // are not reliably available due to the Plugin being deactivated and going |
| 17 | 17 | // through deletion now. |
| 18 | 18 | |
| 19 | +// Delete the log file from the uploads directory. | |
| 20 | +// The Plugin's own directory is deleted by WordPress once this routine completes, | |
| 21 | +// so any historic log file stored there doesn't need deleting here. | |
| 22 | +// This mirrors ConvertKit_Log::get_log_file_name() in the Kit WordPress Libraries, | |
| 23 | +// which we can't call as the Plugin's classes aren't reliably available. | |
| 24 | +$upload_dir = wp_upload_dir(); | |
| 25 | +if ( empty( $upload_dir['error'] ) && ! empty( $upload_dir['basedir'] ) ) { | |
| 26 | + $log_slug = sanitize_key( basename( __DIR__ ) ); | |
| 27 | + $log_file = trailingslashit( $upload_dir['basedir'] ) . 'kit-logs/' . $log_slug . '-' . wp_hash( $log_slug ) . '.log'; | |
| 28 | + | |
| 29 | + if ( file_exists( $log_file ) ) { | |
| 30 | + wp_delete_file( $log_file ); | |
| 31 | + } | |
| 32 | +} | |
| 33 | + | |
| 19 | 34 | // Get settings. |
| 20 | 35 | $settings = get_option( '_wp_convertkit_settings' ); |
| 21 | 36 | |
| 22 | 37 | // Bail if no settings exist. |
| @@ -29,16 +44,14 @@ | ||
| 29 | 44 | wp_remote_post( |
| 30 | 45 | 'https://api.kit.com/v4/oauth/revoke', |
| 31 | 46 | array( |
| 32 | 47 | 'headers' => array( |
| 33 | - 'Accept' => 'application/json', | |
| 34 | - 'Content-Type' => 'application/json', | |
| 48 | + 'Content-Type' => 'application/x-www-form-urlencoded', | |
| 35 | 49 | ), |
| 36 | - 'body' => wp_json_encode( | |
| 37 | - array( | |
| 38 | - 'client_id' => 'HXZlOCj-K5r0ufuWCtyoyo3f688VmMAYSsKg1eGvw0Y', | |
| 39 | - 'token' => $settings['access_token'], | |
| 40 | - ) | |
| 50 | + 'body' => array( | |
| 51 | + 'client_id' => 'HXZlOCj-K5r0ufuWCtyoyo3f688VmMAYSsKg1eGvw0Y', | |
| 52 | + 'token' => $settings['access_token'], | |
| 53 | + 'token_type_hint' => 'access_token', | |
| 41 | 54 | ), |
| 42 | 55 | 'timeout' => 5, |
| 43 | 56 | ) |
| 44 | 57 | ); |
| @@ -49,16 +62,14 @@ | ||
| 49 | 62 | wp_remote_post( |
| 50 | 63 | 'https://api.kit.com/v4/oauth/revoke', |
| 51 | 64 | array( |
| 52 | 65 | 'headers' => array( |
| 53 | - 'Accept' => 'application/json', | |
| 54 | - 'Content-Type' => 'application/json', | |
| 66 | + 'Content-Type' => 'application/x-www-form-urlencoded', | |
| 55 | 67 | ), |
| 56 | - 'body' => wp_json_encode( | |
| 57 | - array( | |
| 58 | - 'client_id' => 'HXZlOCj-K5r0ufuWCtyoyo3f688VmMAYSsKg1eGvw0Y', | |
| 59 | - 'token' => $settings['refresh_token'], | |
| 60 | - ) | |
| 68 | + 'body' => array( | |
| 69 | + 'client_id' => 'HXZlOCj-K5r0ufuWCtyoyo3f688VmMAYSsKg1eGvw0Y', | |
| 70 | + 'token' => $settings['refresh_token'], | |
| 71 | + 'token_type_hint' => 'refresh_token', | |
| 61 | 72 | ), |
| 62 | 73 | 'timeout' => 5, |
| 63 | 74 | ) |
| 64 | 75 | ); |