[wp-trac] [WordPress Trac] #56243: Use a consistent parameter name for functions accepting a post ID or post object

WordPress Trac noreply at wordpress.org
Mon Jul 18 18:18:41 UTC 2022


#56243: Use a consistent parameter name for functions accepting a post ID or post
object
-------------------------------+-------------------------------------
 Reporter:  SergeyBiryukov     |       Owner:  SergeyBiryukov
     Type:  enhancement        |      Status:  accepted
 Priority:  normal             |   Milestone:  6.1
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:  docs, coding-standards
-------------------------------+-------------------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:3 pbiron]:
 > There are also **a lot** of occurrences of `$post_ID` (some of which
 need to be an ID and not a post object, so not sure if they all should be
 changed to `$post`).

 I think those that do not accept a `WP_Post` object should be renamed to
 `$post_id` for consistency.

 > I can provide a list of those occurrences if needed...

 That would be helpful, thanks!

 > Not sure if it would be "scope creep" for this ticket, there are also
 mix of `$comment_ID` and `$comment_id` throughout code.  Should those be
 standardized as well?

 Indeed, I've started looking into that too and will open a similar ticket
 for those :) It's worth noting that `$comment_ID` causes a WPCS warning
 and should be fixed anyway:
 {{{
 | WARNING | [ ] Variable "$comment_ID" is not in valid snake_case
 |         |     format, try "$comment_i_d"
 |         |
 (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56243#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list