[wp-trac] [WordPress Trac] #19012: get_ID and the_ID should accept $id as a parameter

WordPress Trac wp-trac at lists.automattic.com
Thu Oct 20 05:38:25 UTC 2011


#19012: get_ID and the_ID should accept $id as a parameter
-------------------------------------------------+-------------------------
 Reporter:  peterchester                         |       Owner:  ryan
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  Future
Component:  Post Types                           |  Release
 Severity:  normal                               |     Version:  3.3
 Keywords:  needs-testing needs-codex needs-     |  Resolution:
  patch 2nd-opinion                              |
-------------------------------------------------+-------------------------

Comment (by peterchester):

 Thanks for the review Mark!

 Including updated the patch with integer cast instead of is_numeric().
 {{{
         if ( (int) $id > 0 ) {
 }}}

 And as to the question of if this is useful, i cite as an example, 3 cases
 in wp-include/post-thumbnail-template.php such as:

 {{{
 function has_post_thumbnail( $post_id = null ) {
         $post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
         return (bool) get_post_thumbnail_id( $post_id );
 }
 }}}

 With this update this sort of thing can be updated to read:

 {{{
 function has_post_thumbnail( $post_id = null ) {
         $post_id = get_the_ID( $post_id );
         return (bool) get_post_thumbnail_id( $post_id );
 }
 }}}

 Or even:

 {{{
 function has_post_thumbnail( $post_id = null ) {
         return (bool) get_post_thumbnail_id( get_the_ID( $post_id ) );
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19012#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list