[wp-trac] [WordPress Trac] #31820: get_option() returns Integers as strings
WordPress Trac
noreply at wordpress.org
Thu Jan 7 18:28:42 UTC 2016
#31820: get_option() returns Integers as strings
--------------------------------+------------------------------
Reporter: golderweb | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: 4.1.1
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------------+------------------------------
Changes (by MikeHansenMe):
* keywords: => has-patch
Comment:
[attachment: 31820.diff] changes the doc to show the return value is a
string. If you do need to force something to be an int you could do
something like
{{{
function force_int( $value ) {
if ( is_numeric( $value ) ) {
return (int) $value;
}
}
add_filter( 'option_your_option_name', 'force_int' );
}}}
https://codex.wordpress.org/Plugin_API/Filter_Reference/option_(option_name)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31820#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list