From ffe8f1b13afe589ab3d365f4c290f0e93f549fba Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 4 Sep 2013 19:07:09 +0000 Subject: [PATCH] Remove unnecessary checks before setting `$wp_settings_*` arrays. Adds unit test for setting a nonexistent variable to a multi-dimensional `array`. Props scribu. Fixes #17884. Built from https://develop.svn.wordpress.org/trunk@25240 git-svn-id: http://core.svn.wordpress.org/trunk@25210 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index eba762711a..9bb36cc6e6 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1072,13 +1072,6 @@ function add_settings_section($id, $title, $callback, $page) { $page = 'reading'; } - if ( !isset($wp_settings_sections) ) - $wp_settings_sections = array(); - if ( !isset($wp_settings_sections[$page]) ) - $wp_settings_sections[$page] = array(); - if ( !isset($wp_settings_sections[$page][$id]) ) - $wp_settings_sections[$page][$id] = array(); - $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); } @@ -1117,13 +1110,6 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default', $page = 'reading'; } - if ( !isset($wp_settings_fields) ) - $wp_settings_fields = array(); - if ( !isset($wp_settings_fields[$page]) ) - $wp_settings_fields[$page] = array(); - if ( !isset($wp_settings_fields[$page][$section]) ) - $wp_settings_fields[$page][$section] = array(); - $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); } @@ -1143,7 +1129,7 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default', function do_settings_sections( $page ) { global $wp_settings_sections, $wp_settings_fields; - if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) ) + if ( ! isset( $wp_settings_sections[$page] ) ) return; foreach ( (array) $wp_settings_sections[$page] as $section ) { @@ -1178,7 +1164,7 @@ function do_settings_sections( $page ) { function do_settings_fields($page, $section) { global $wp_settings_fields; - if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) + if ( ! isset( $wp_settings_fields[$page][$section] ) ) return; foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { @@ -1219,9 +1205,6 @@ function do_settings_fields($page, $section) { function add_settings_error( $setting, $code, $message, $type = 'error' ) { global $wp_settings_errors; - if ( !isset($wp_settings_errors) ) - $wp_settings_errors = array(); - $new_error = array( 'setting' => $setting, 'code' => $code,