settings upgrade to follow refactoring

isekai
Jonathan Daggerhart 9 years ago
parent 822c2befd3
commit d0ceb60a37

@ -257,6 +257,11 @@ class OpenID_Connect_Generic_Settings_Page {
settings_fields( $this->settings_field_group );
do_settings_sections( $this->options_page_name );
submit_button();
// simple debug to view settings array
if ( isset( $_GET['debug'] ) ) {
var_dump( $this->settings->get_values() );
}
?>
</form>

@ -37,6 +37,14 @@ class WP_Option_Settings {
return isset( $this->values[ $key ] );
}
function __unset( $key ){
unset( $this->values[ $key ]);
}
function get_values(){
return $this->values;
}
function get_option_name() {
return $this->option_name;
}

@ -121,11 +121,22 @@ class OpenID_Connect_Generic {
* Handle plugin upgrades
*/
function upgrade(){
$last_version = get_option( 'openid-connect-generic-plugin-version', self::VERSION );
$last_version = get_option( 'openid-connect-generic-plugin-version', 0 );
$settings = $this->settings;
if ( version_compare( self::VERSION, $last_version, '>' ) ) {
// upgrade required
// @todo move this to another file for upgrade scripts
if ( isset( $settings->ep_login ) ) {
$settings->endpoint_login = $settings->ep_login;
$settings->endpoint_token = $settings->ep_token;
$settings->endpoint_userinfo = $settings->ep_userinfo;
unset( $settings->ep_login, $settings->ep_token, $settings->ep_userinfo );
$settings->save();
}
// update the stored version number
update_option( 'openid-connect-generic-plugin-version', self::VERSION );
}

Loading…
Cancel
Save