-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP-r56657: Disable attachment pages for new installations #1436
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WordPress creates attachment pages by default for every attachment uploaded. On the vast majority of sites, these attachment pages don't contain any meaningful information. They do however exist, get indexed by search engines, and sometimes even rank in search results, leading to bad results for users and site owners. This commit introduces a `wp_attachment_pages_enabled` database option to control the attachment pages behavior: * On existing sites, the option is set to `1` on upgrade, so that attachment pages continue to work as is. * For new sites, the option is set to to `0` by default, which means attachment pages are redirected to the attachment URL. * Sites that want to enable or disable the attachment pages can set the option to `1` or `0`, respectively. Follow-up to https://core.trac.wordpress.org/changeset/2958, https://core.trac.wordpress.org/changeset/3303, https://core.trac.wordpress.org/changeset/7149, https://core.trac.wordpress.org/changeset/34690. WP:Props aristath, poena, afercia, joostdevalk, jonoaldersonwp, azaozz, johnbillion, joedolson, basiliskan, audrasjb, davelo, rilwis, manfcarlo, tyxla, garrett-eclipse, seedsca, eatingrules, matveb, antpb, zodiac1978, oglekler, zunaid321, costdev, SergeyBiryukov. Fixes https://core.trac.wordpress.org/ticket/57913. Conflicts: - src/wp-admin/includes/upgrade.php - src/wp-includes/version.php - tests/phpunit/tests/canonical.php --- Merges https://core.trac.wordpress.org/changeset/56657 / WordPress/wordpress-develop@15e37005db to ClassicPress.
…grade_640()`. Follow-up to https://core.trac.wordpress.org/changeset/56657. See https://core.trac.wordpress.org/ticket/57913. --- Merges https://core.trac.wordpress.org/changeset/56658 / WordPress/wordpress-develop@e413569b67 to ClassicPress.
When attachment pages are disabled, change the links from "View Attachment Page" to "View Media File". Follow-up to https://core.trac.wordpress.org/changeset/56657, https://core.trac.wordpress.org/changeset/56658. WP:Props joedolson, ironprogrammer, oglekler. Fixes https://core.trac.wordpress.org/ticket/57913. --- Merges https://core.trac.wordpress.org/changeset/56711 / WordPress/wordpress-develop@dc31cf0624 to ClassicPress.
…sers. Ensure logged out users are redirected to the media file when attachment pages are inactive. This removes the read_post capability check from the canonical redirects as anonymous users lack the permission. This was previously committed in https://core.trac.wordpress.org/changeset/57310 before being reverted in https://core.trac.wordpress.org/changeset/57318. This update includes a fix to cover instances where revealing a URL could be considered a data leak and greatly expands the unit tests to ensure that this is covered along with many other instances. Follow-up to https://core.trac.wordpress.org/changeset/56657, https://core.trac.wordpress.org/changeset/56658, https://core.trac.wordpress.org/changeset/56711, https://core.trac.wordpress.org/changeset/57310, https://core.trac.wordpress.org/changeset/57318. WP:Props peterwilsoncc, jorbin, afercia, aristath, chesio, joppuyo, jorbin, lakshmananphp, poena, sergeybiryukov, swissspidy, johnbillion. Fixes https://core.trac.wordpress.org/ticket/59866. See https://core.trac.wordpress.org/ticket/57913. Conflicts: - tests/phpunit/tests/canonical.php --- Merges https://core.trac.wordpress.org/changeset/57357 / WordPress/wordpress-develop@fe1df4023c to ClassicPress.
KTS915
approved these changes
May 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well!
This was referenced May 8, 2024
…sers. Ensure logged out users are redirected to the media file when attachment pages are inactive. This removes the read_post capability check from the canonical redirects as anonymous users lack the permission. This was previously committed in https://core.trac.wordpress.org/changeset/57310 before being reverted in https://core.trac.wordpress.org/changeset/57318. This update includes a fix to cover instances where revealing a URL could be considered a data leak and greatly expands the unit tests to ensure that this is covered along with many other instances. Follow-up to https://core.trac.wordpress.org/changeset/56657, https://core.trac.wordpress.org/changeset/56658, https://core.trac.wordpress.org/changeset/56711, https://core.trac.wordpress.org/changeset/57310, https://core.trac.wordpress.org/changeset/57318. WP:Props peterwilsoncc, jorbin, afercia, aristath, chesio, joppuyo, jorbin, lakshmananphp, poena, sergeybiryukov, swissspidy, johnbillion. Fixes https://core.trac.wordpress.org/ticket/59866. See https://core.trac.wordpress.org/ticket/57913. Conflicts: - tests/phpunit/tests/canonical.php --- Merges https://core.trac.wordpress.org/changeset/57357 / WordPress/wordpress-develop@fe1df4023c to ClassicPress.
Managed that https://core.trac.wordpress.org/changeset/57358 is the same as https://core.trac.wordpress.org/changeset/57357. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As requested in #1434 this PR backports several WP changesets to achieve the result:
See https://core.trac.wordpress.org/ticket/57913
Backported:
Can't backport https://core.trac.wordpress.org/changeset/57358. Can't understand if it's needed.Also a checkbox for this options in Settings -> Media would be nice.
Closes #1434
Description
Disable attachment pages for new installation.
wp_attachment_pages_enabled
can be set to0
fromwp-admin/options.php
page.How has this been tested?
Locally and backported unit tests.
Types of changes