From 8aeba4dcd62ea018d0dba22193cd8777d9a4534f Mon Sep 17 00:00:00 2001 From: boghy933 Date: Thu, 21 Sep 2017 10:50:59 +0200 Subject: [PATCH 1/4] check if settings_sections and settings_fields are array before foreach --- src/class.settings-api.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/class.settings-api.php b/src/class.settings-api.php index e73d470..030e9a0 100755 --- a/src/class.settings-api.php +++ b/src/class.settings-api.php @@ -97,6 +97,8 @@ function add_field( $section, $field ) { * registers them to WordPress and ready for use. */ function admin_init() { + if( ! is_array( $this->settings_sections ) ) + return ; //register settings sections foreach ( $this->settings_sections as $section ) { if ( false == get_option( $section['id'] ) ) { @@ -115,6 +117,8 @@ function admin_init() { add_settings_section( $section['id'], $section['title'], $callback, $section['id'] ); } + if( ! is_array($this->settings_fields) ) + return ; //register settings fields foreach ( $this->settings_fields as $section => $field ) { foreach ( $field as $option ) { @@ -502,6 +506,9 @@ function get_option( $option, $section, $default = '' ) { function show_navigation() { $html = '