WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#53308 new defect (bug)

The WP_CONTENT_URL constant contains an incorrect URL

Reported by: webtemyk Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.7.2
Component: Bootstrap/Load Keywords: reporter-feedback
Focuses: Cc:

Description (last modified by peterwilsoncc)

In one of the latest versions of WordPress, we added this code to the file wp-config.php:

<?php
if ( ! defined( 'WP_CLI' ) ) {
        define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] );
        define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] );
}

However, when declaring some constants, the site URL continues to be taken from the option in the database:

<?php
define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );

The problem occurs when the site administrator moves the site to another domain or switches to HTTPS, but does not change the URL in the database. At the same time, WordPress continues to work, even with the wrong address in the option in the database, but the old site address turns out to be in the constant

Change History (1)

#1 @peterwilsoncc
4 months ago

  • Component changed from General to Bootstrap/Load
  • Description modified (diff)
  • Keywords reporter-feedback added

Hi @webtemyk and welcome to trac!

Prior to running the code to define WP_CONTENT_URL WordPress adds a filter to override the siteurl and homeurl option if the constants are set, the filters are added in the wp-includes/default-filters.php file, and the for the filters check if the constants are defined.

However, if you have set your site up in multisite mode these filters do not run. Is your site running as a multisite install?

Thanks,
Peter

Note: See TracTickets for help on using tickets.