Fixed array_map issue in settings. Closes #2106 #2104

This commit is contained in:
Coen Jacobs 2013-01-02 12:32:26 +01:00
parent fc48f124cb
commit 843614f9d0
1 changed files with 5 additions and 3 deletions

View File

@ -109,7 +109,7 @@ abstract class WC_Settings_API {
// Load form_field settings
$this->settings = get_option( $this->plugin_id . $this->id . '_settings', null );
if ( ! is_array( $this->settings ) ) {
if ( ! $this->settings || ! is_array( $this->settings ) ) {
// If there are no settings defined, load defaults
$this->init_form_fields();
@ -118,8 +118,10 @@ abstract class WC_Settings_API {
$this->settings[ $k ] = isset( $v['default'] ) ? $v['default'] : '';
}
$this->settings = array_map( array( $this, 'format_settings' ), $this->settings );
$this->enabled = isset( $this->settings['enabled'] ) && $this->settings['enabled'] == 'yes' ? 'yes' : 'no';
if ( $this->settings && is_array( $this->settings ) ) {
$this->settings = array_map( array( $this, 'format_settings' ), $this->settings );
$this->enabled = isset( $this->settings['enabled'] ) && $this->settings['enabled'] == 'yes' ? 'yes' : 'no';
}
}