Make WordPress Core

Changeset 56657

Timestamp:
09/22/2023 12:02:28 AM (11 months ago)
Author:
SergeyBiryukov
Message:

Media: Disable attachment pages for new installations.

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 [2958], [3303], [7149], [34690].

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 #57913.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/schema.php

    r56414 r56657  
    557557        // 5.8.0
    558558        'wp_force_deactivated_plugins'    => array(),
     559
     560
     561
    559562    );
    560563
  • trunk/src/wp-admin/includes/upgrade.php

    r56549 r56657  
    840840    }
    841841
     842
     843
     844
     845
    842846    maybe_disable_link_manager();
    843847
     
    23242328
    23252329/**
     2330
     2331
     2332
     2333
     2334
     2335
     2336
     2337
     2338
     2339
     2340
     2341
     2342
     2343
     2344
     2345
     2346
    23262347 * Executes network-level upgrade routines.
    23272348 *
  • trunk/src/wp-includes/canonical.php

    r56245 r56657  
    543543            wp_redirect( $redirect_url, 301 );
    544544            die();
     545
     546
     547
     548
     549
     550
     551
     552
     553
     554
     555
     556
    545557        }
    546558    }
     
    651663    // Trailing slashes.
    652664    if ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks()
     665
    653666        && ! is_404() && ( ! is_front_page() || is_front_page() && get_query_var( 'paged' ) > 1 )
    654667    ) {
  • trunk/src/wp-includes/version.php

    r56267 r56657  
    2424 * @global int $wp_db_version
    2525 */
    26 $wp_db_version = 55853;
     26$wp_db_version = 5;
    2727
    2828/**
  • trunk/tests/phpunit/tests/canonical.php

    r56559 r56657  
    1414        parent::set_up();
    1515        wp_set_current_user( self::$author_id );
     16
     17
    1618    }
    1719
     
    403405        $this->assertNull( $url );
    404406    }
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
    405428}
  • trunk/tests/phpunit/tests/canonical/postStatus.php

    r52010 r56657  
    170170        parent::set_up();
    171171        self::setup_custom_types();
     172
     173
    172174    }
    173175
Note: See TracChangeset for help on using the changeset viewer.