From 0ac088bb1966553286106b9395702e82459dcded Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 30 May 2012 09:54:35 +0100 Subject: [PATCH] pass fields --- classes/class-wc-settings-api.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/classes/class-wc-settings-api.php b/classes/class-wc-settings-api.php index e39a1d5255714..45628bb3d1707 100644 --- a/classes/class-wc-settings-api.php +++ b/classes/class-wc-settings-api.php @@ -54,8 +54,10 @@ public function process_admin_options() { if ( count( $this->errors ) > 0 ) { $this->display_errors(); + return false; } else { update_option( $this->plugin_id . $this->id . '_settings', $this->sanitized_fields ); + return true; } } @@ -118,7 +120,7 @@ function format_settings( $value ) { * @since 1.0.0 * @uses method_exists() */ - function generate_settings_html ( $form_fields ) { + function generate_settings_html ( $form_fields = false ) { if ( ! $form_fields ) $form_fields = $this->form_fields; @@ -331,8 +333,14 @@ function generate_multiselect_html ( $key, $data ) { * @since 1.0.0 * @uses method_exists() */ - function validate_settings_fields () { - foreach ( $this->form_fields as $k => $v ) { + function validate_settings_fields( $form_fields = false ) { + + if ( ! $form_fields ) + $form_fields = $this->form_fields; + + $this->sanitized_fields = array(); + + foreach ( $form_fields as $k => $v ) { if ( ! isset( $v['type'] ) || ( $v['type'] == '' ) ) { $v['type'] == 'text'; } // Default to "text" field type. if ( method_exists( $this, 'validate_' . $v['type'] . '_field' ) ) {