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
This commit is contained in:
parent
4a2c4c8f01
commit
ffe8f1b13a
|
@ -1072,13 +1072,6 @@ function add_settings_section($id, $title, $callback, $page) {
|
||||||
$page = 'reading';
|
$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);
|
$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';
|
$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);
|
$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 ) {
|
function do_settings_sections( $page ) {
|
||||||
global $wp_settings_sections, $wp_settings_fields;
|
global $wp_settings_sections, $wp_settings_fields;
|
||||||
|
|
||||||
if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) )
|
if ( ! isset( $wp_settings_sections[$page] ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach ( (array) $wp_settings_sections[$page] as $section ) {
|
foreach ( (array) $wp_settings_sections[$page] as $section ) {
|
||||||
|
@ -1178,7 +1164,7 @@ function do_settings_sections( $page ) {
|
||||||
function do_settings_fields($page, $section) {
|
function do_settings_fields($page, $section) {
|
||||||
global $wp_settings_fields;
|
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;
|
return;
|
||||||
|
|
||||||
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
|
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' ) {
|
function add_settings_error( $setting, $code, $message, $type = 'error' ) {
|
||||||
global $wp_settings_errors;
|
global $wp_settings_errors;
|
||||||
|
|
||||||
if ( !isset($wp_settings_errors) )
|
|
||||||
$wp_settings_errors = array();
|
|
||||||
|
|
||||||
$new_error = array(
|
$new_error = array(
|
||||||
'setting' => $setting,
|
'setting' => $setting,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
|
|
Loading…
Reference in New Issue