WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#35151 closed enhancement (wontfix)

New constant `WP_CONTENT_DIR_NAME`

Reported by: sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch 2nd-opinion close
Focuses: Cc:

Description

If I want change wp-content to other name I must defined three constants:

WP_CONTENT_DIR
WP_SITEURL
WP_CONTENT_URL

This is not flexible because I can't change url in page settings. I suggest add const: WP_CONTENT_DIR_NAME with name of new name.

I define WP_CONTENT_DIR_NAME with new name and is automatically set. I add path

Attachments (1)

35151.patch (17.1 KB) - added by sebastian.pisula 4 years ago.

Download all attachments as: .zip

Change History (8)

This ticket was mentioned in Slack in #core by sebastian.pisula. View the logs.


4 years ago

#2 @swissspidy
4 years ago

  • Keywords has-patch added

#3 @dd32
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

To clarify, only WP_CONTENT_DIR and WP_CONTENT_URL need to be defined. WP_SITEURL is unrelated.

The primary use of these constants isn't to rename the folder, it's to support subdirectory installations with WordPress as an external.
For example, in the below scenario we've got WordPress installed into a subdirectory with it's wp-content directory, however we're overriding it and using the one in the parent directory instead.

/public_html/wp-config.php
/public_html/wp-content/ (This would be used)
/public_html/wordpress/
/public_html/wordpress/wp-content/ (This wouldb be ignored)
/public_html/wordpress/wp-admin/

#4 @sebastian.pisula
4 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

I think that this will be helpful constant. I use wp cli to install website:

core config:
  dbprefix: wp_
  extra-php: |
    define('WP_DEBUG', 1);
    define('WP_DEBUG_LOG', 1);
    define('WP_DEBUG_DISPLAY', 0);
    define('WP_CONTENT_DIR_NAME', 'my-wp-content');

So I want change WP_CONTENT_DIR I must change WP_CONTENT_URL. And I must define in wp-config.php WP_SITEURL AND WP_HOMEURL but I want get value from option no defined in wp-config.php

For example:

  1. staging version is on url http://staging.domain.com/
  2. 1 of 3 developer work on http://domain.com/
  3. 2 of 3 developer work on http://localhost:1234/company/domain.com/
  4. 2 of 3 developer work on http://localhost/domain.com/
  5. production url is http://domain.com/

So I must configure in each env WP_CONTENT_URL because is bad. If I defined WP_CONTENT_DIR_NAME I don't must change WP_CONTENT_URL because this url will be generate automatic. Then I can use WP-CLI and others automatic apps.

My patch don't destroy nothing but it helps programmer to work

This ticket was mentioned in Slack in #core by sebastian.pisula. View the logs.


4 years ago

#6 @dd32
4 years ago

  • Keywords 2nd-opinion close added
  • Milestone set to Awaiting Review

#7 @aaroncampbell
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

I agree with @dd32 that the common use case of WP_CONTENT_DIR and WP_CONTENT_URL is to move the content directory rather than just rename it (usually to keep WP in it's own directory to be pulled in as an external). I'm honestly not sure what the benefit would be of renaming it where it sits.

Having said all that, you can define these constants in a way that works as you push from dev to staging to live. I often use separate config files for those environments, but if you want to keep them all the same, try something like this:

define( 'WP_CONTENT_DIR', __DIR__ . '/content' );
define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );

I really don't think we need another constant here.

Note: See TracTickets for help on using tickets.