WordPress.org

Make WordPress Core

Changes between Initial Version and Version 3 of Ticket #19012


Ignore:
Timestamp:
10/20/11 05:27:28 (3 years ago)
Author:
markjaquith
Comment:

get_post() does something similar. It takes a post object, a post id, or nothing, and gives you a post object.

I wouldn't use is_numeric() though — too permissive.

Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal notation (0xFF) is allowed too but only without sign, decimal and exponential part.

Instead I'd say we cast to integer, and check for it being greater than zero. I'm also not sure it's useful for the_ID().

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #19012

    • Property Status changed from new to reviewing
    • Property Cc peter@… added
    • Property Owner changed from peterchester to ryan
    • Property Milestone changed from Awaiting Review to Future Release
    • Property Keywords needs-patch 2nd-opinion added; has-patch removed
  • Ticket #19012 – Description

    initial v3  
    1 I see through out the wordpress code as well as through out many plugins and themes that get_ID is often accompanied by a test to see if an ID had been passed. It would be a harmless but extremely useful update to simply allow get_ID and the_ID to accept an optional $id and pass it through if it's numerical. 
     1I see throughout the WordPress code as well as throughout many plugins and themes that {{{get_ID()}}} is often accompanied by a test to see if an ID had been passed. It would be a harmless but extremely useful update to simply allow {{{get_ID()}}} and {{{the_ID()}}} to accept an optional $id and pass it through if it's numerical. 
    22 
    33I've already gone ahead and created the patch (attached)