[wp-trac] [WordPress Trac] #28672: add_settings_field & co don't return values
WordPress Trac
noreply at wordpress.org
Wed Oct 29 17:11:23 UTC 2014
#28672: add_settings_field & co don't return values
---------------------------------------------+-----------------------------
Reporter: TJNowell | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
Component: Options, Meta APIs | Review
Severity: normal | Version: 2.7
Keywords: needs-unit-tests good-first-bug | Resolution:
| Focuses: administration
---------------------------------------------+-----------------------------
Comment (by GunGeekATX):
I'm not sure it would specifically work for add_settings_section(). It
looks like you can add sections to a page even if the page isn't already
defined.
do_settings_sections() and do_settings_fields() return nothing if the page
or section hasn't been defined, so it might not hurt to have those return
WP_Error as well.
This is what do_settings_sections() returns now.
{{{
if ( ! isset( $wp_settings_sections[$page] ) )
return;
}}}
If you're working with the settings API, I can see where a typo in your
code would make debugging such an issue a bit harder. This would be
something you could check for:
{{{
// updated do_settings_sections()
if ( ! isset( $wp_settings_sections[$page] ) )
return new WP_Error( 'undefined_settings_page', sprintf(
__('Settings page %s has not been defined.'), $page ) );
}}}
{{{
// example from a plugin/theme
$section_check = do_settings_section( 'wordcampp' );
if ( is_wp_error( $section_check )
wp_die( $section_check->get_error_message() );
}}}
I can tackle a patch for this if it sounds like something that should be
in core.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28672#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list