[wp-trac] [WordPress Trac] #37255: Update attachment functions to accept a post object in addition to ID

WordPress Trac noreply at wordpress.org
Mon Mar 6 00:22:31 UTC 2023


#37255: Update attachment functions to accept a post object in addition to ID
-------------------------------------------------+-------------------------
 Reporter:  wido                                 |       Owner:
                                                 |  johnbillion
     Type:  enhancement                          |      Status:  accepted
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Media                                |     Version:  4.6
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing needs-dev-note needs-  |     Focuses:
  testing-info 2nd-opinion                       |
-------------------------------------------------+-------------------------
Changes (by azaozz):

 * keywords:  has-patch needs-testing needs-dev-note needs-testing-info =>
     needs-testing needs-dev-note needs-testing-info 2nd-opinion


Comment:

 > could be an improvement to standardize the functions that require a post
 id even support the $post object?

 I mostly agree. Perhaps may be nice to standardize functions that do
 something with WP posts to accept either `$post->ID` or `$post`, purely
 for consistency. It doesn't make any difference "under the hood", just
 affects "code readability and self-documenting" a little. That may be a
 bit "weird" in some places, but being consistent even when weird is not
 that bad, maybe :)

 However I do not agree it is a good idea to accept a WP post object in
 functions that do not do anything with it, for example all image specific
 functions. Looking at the current patch, all functions that have `image`
 in the name should not be changed to accept a `$post` object. There is no
 good excuse for that.

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


More information about the wp-trac mailing list