[wp-trac] [WordPress Trac] #59866: Attachment pages are only disabled for users that are logged in

WordPress Trac noreply at wordpress.org
Thu Nov 9 11:54:01 UTC 2023


#59866: Attachment pages are only disabled for users that are logged in
--------------------------+-----------------------------
 Reporter:  joppuyo       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  6.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 This is related to the previous ticket #57913 regarding "disable
 attachment page functionality".

 I'm an author of a plugin [https://wordpress.org/plugins/disable-media-
 pages/ Disable Media Pages] which has provided this functionality in
 previous WordPress versions. I'm trying to figure out what's the best way
 forward for the plugin since WordPress 6.4 as this functionality is now
 built into the core.

 While testing 6.4, I noticed that even if `attachment_pages_enabled` is
 set to `0` the redirection only kicks in for logged-in users. For
 anonymous users, the attachment page is still displayed. It seems this is
 because `read_post` capability
 [https://github.com/WordPress/WordPress/blob/e2d61d78ede843c2d05f44a4e15f30a57fb47d95
 /wp-includes/canonical.php#L553C11-L553C11 is checked before] the
 redirection is performed. Anonymous users don't have any capabilities so
 the redirection work in this case.

 Is this feature intended to work this way or is this an oversight in the
 implementation?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59866>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list