From 8cce143275c70a1fd3cd0068001519ef7b503001 Mon Sep 17 00:00:00 2001 From: Jonathan Daggerhart Date: Fri, 29 May 2015 09:49:03 -0400 Subject: [PATCH] admin field fixes --- admin/openid-connect-generic-settings.php | 17 +++++++++++------ openid-connect-generic.php | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/admin/openid-connect-generic-settings.php b/admin/openid-connect-generic-settings.php index 2727d9e..5be6027 100644 --- a/admin/openid-connect-generic-settings.php +++ b/admin/openid-connect-generic-settings.php @@ -37,7 +37,7 @@ class OpenID_Connect_Generic_Settings { * - section - settings/option page section ( client_settings | authorization_settings ) * - example (optional example will appear beneath description and be wrapped in ) */ - $this->settings_fields = array( + $fields = array( 'login_type' => array( 'title' => __('Login Type'), 'description' => __('Select how the client (login form) should provide login options.'), @@ -116,8 +116,16 @@ class OpenID_Connect_Generic_Settings { ), ); + $fields = apply_filters( 'openid-connect-generic-settings-fields', $this->settings_fields ); + + // some simple pre-processing + foreach ( $fields as $key => &$field ) { + $field['key'] = $key; + $field['name'] = OPENID_CONNECT_GENERIC_SETTINGS_NAME . '[' . $key . ']'; + } + // allow alterations of the fields - $this->settings_fields = apply_filters( 'openid-connect-generic-settings-fields', $this->settings_fields ); + $this->settings_fields = $fields; } /** @@ -153,9 +161,6 @@ class OpenID_Connect_Generic_Settings { // preprocess fields and add them to the page foreach ( $this->settings_fields as $key => $field ) { - $field['key'] = $key; - $field['name'] = OPENID_CONNECT_GENERIC_SETTINGS_NAME . '[' . $key . ']'; - // make sure each key exists in the settings array if ( ! isset( $this->settings[ $key ] ) ){ $this->settings[ $key ] = null; @@ -251,7 +256,7 @@ class OpenID_Connect_Generic_Settings { */ public function do_checkbox( $field ) { ?> - + settings; } - return wp_parse_args( get_option( OPENID_CONNECT_GENERIC_SETTINGS_NAME, array() ), $this->default_settings ); + $this->settings = wp_parse_args( get_option( OPENID_CONNECT_GENERIC_SETTINGS_NAME, array() ), $this->default_settings ); + return $this->settings; } /**