[wp-trac] [WordPress Trac] #46866: Introduce the 'Uploaded to' onto the Full Media Editor

WordPress Trac noreply at wordpress.org
Fri Oct 9 20:46:20 UTC 2020


#46866: Introduce the 'Uploaded to' onto the Full Media Editor
-------------------------------------------------+-------------------------
 Reporter:  garrett-eclipse                      |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  5.6
Component:  Media                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-screenshots needs-     |     Focuses:  ui,
  testing needs-design-feedback                  |  administration
-------------------------------------------------+-------------------------

Comment (by garrett-eclipse):

 Hello, I've updated the patch in
 [https://core.trac.wordpress.org/attachment/ticket/46866/46866.5.diff
 46866.5.diff] and feel we're nearing the final iteration so please test
 and review away @Mista-Flo @antpb @SergeyBiryukov.

 Replying to [comment:21 SergeyBiryukov]:
 > Just a quick note that the latest patch appears to remove some checks
 from `wp_prepare_attachment_for_js()`:
 > * `$parent_type && $parent_type->show_ui`
 > * `current_user_can( 'edit_post', $attachment->post_parent )`
 >
 > At a glance, these are still relevant to avoid displaying a link that
 should not be displayed if the parent post type doesn't have a UI or the
 current user cannot edit the parent post.
 >
 > Would be good to test and verify that removing these does not lead to
 any unexpected results, e.g. displaying a link leading to nowhere, or PHP
 notices when the post type no longer exists.

 Yes as @Mista-Flo mentioned this was on purposed, after investigation all
 the checks for capabilities and show_ui is handled from within the
 get_link functions for us so we can remove them here and just rely on the
 empty link check to tell if we can insert the link or not.

 In `get_edit_user_link` the following check is done for us;
 `current_user_can_edit_user` - https://github.com/WordPress/wordpress-
 develop/blob/79703088c4fea9655b5f071cadee4a7949dd1cca/src/wp-includes
 /link-template.php#L1627

 In `get_edit_post_link` the following checks are done for us;
 `current_user_can_edit_post` - https://github.com/WordPress/wordpress-
 develop/blob/79703088c4fea9655b5f071cadee4a7949dd1cca/src/wp-includes
 /link-template.php#L1380
 `post_type_object_has_edit_link` - https://github.com/WordPress/wordpress-
 develop/blob/79703088c4fea9655b5f071cadee4a7949dd1cca/src/wp-includes
 /link-template.php#L1380
 In this function there's an `_edit_link` check, and in the constructor for
 post_types that will be empty if `show_ui` or `has_edit_link` are
 empty/false - https://github.com/WordPress/wordpress-
 develop/blob/f36c42c70034348c4007157c1fc8a8d69e50c90c/src/wp-includes
 /class-wp-post-type.php#L469

 So to summarize, all checks are done for us. There was two 'read' checks
 but from our discussion on slack here they were removed to match with the
 author setup and avoid admins seeing a attachment as an orphan when it
 isn't.

 Also in this update I use the author exist check to provide no author
 verbiage if they don't similar to what was found for the media template.

 I do encourage thorough testing of the capabilities and review.

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


More information about the wp-trac mailing list