-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/603: remove Auth0 related features #310
Changes from 5 commits
a663cad
c8c9878
feb6fe3
39e23c8
25e76af
59d1247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,49 @@ function() { | |
} | ||
); | ||
|
||
/** | ||
* Method to cleanup settings before setting the new version. | ||
* | ||
* @param string $plugin Full path to the plugin's main file. | ||
*/ | ||
function sophi_remove_stale_data( $plugin ) { | ||
/** Return if the plugin is not Sophi. */ | ||
if ( 'sophi.php' !== basename( $plugin ) ) { | ||
return; | ||
} | ||
|
||
$version_key = 'sophi_version'; | ||
$current_version = get_transient( $version_key ); | ||
|
||
if ( false === $current_version ) { | ||
$current_version = get_option( $version_key, false ); | ||
|
||
if ( false !== $current_version ) { | ||
set_transient( $version_key, $current_version ); | ||
} | ||
} | ||
|
||
if ( SOPHI_WP_VERSION === $current_version ) { | ||
return; | ||
} | ||
|
||
if ( false === $current_version || version_compare( $current_version, SOPHI_WP_VERSION, '<' ) ) { | ||
|
||
/** Cleanup logic before setting the new version of the plugin. */ | ||
delete_option( 'sophi_site_automation_access_token' ); | ||
|
||
$sophi_settings = get_option( 'sophi_settings' ); | ||
unset( $sophi_settings['client_id'] ); | ||
unset( $sophi_settings['client_secret'] ); | ||
|
||
update_option( 'sophi_settings', $sophi_settings ); | ||
update_option( $version_key, SOPHI_WP_VERSION, true ); | ||
set_transient( $version_key, SOPHI_WP_VERSION ); | ||
} | ||
} | ||
|
||
add_action( 'plugin_loaded', 'sophi_remove_stale_data' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit worried about the new option in terms of site performance. Is there another way to clean the data without adding a new option? I think we can remove irrelevant options when updating the Sophi setting. Do you think it's sufficient to clean the old settings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dinhtungdu I've replaced this logic, can you check? |
||
|
||
/** | ||
* Sophi HTTPS notice. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may still want some validation that Host/Tenant ID are entered when someone tries to save the form.