Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#24138 closed enhancement (maybelater)

Add Constant control for Multisite.

Reported by: krembo99's profile krembo99 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:


Not sure if this should be tagged as feature request or enhancement.

WordPress is now making quite an extensive use of constants (like AUTOSAVE_INTERVAL , WP_POST_REVISIONS or EMPTY_TRASH_DAYS ) that are configured in wp-config.php in the form of define('EMPTY_TRASH_DAYS', 1 ); .

Right now, AFAIK , there is no way to define those variable on a site-to-site (or blog-to-blog) basis in Multisite mode.

So for example if one wants his main blog to empty trash every 3 days, while another blog to be set to 5 , or even allow and enable DEBUG_MODE on a certain blog , while keeping it disabled in others , is not currently possible (again, AFAIK) .

Now, I am not sure this should be done with constants , or with some new functions , or simply in some settings implementation, or even with some kind of a blog-based config.php for each blog , but it sure would be a necessary layer of control to have ( if indeed the Multisite feature is to be kept alive and expanded ..)

Change History (6)

#1 @Ipstenu
10 years ago

You don't have to put the defines in wp-config. You can put them in a plugin, for example, so with the possible exception of debug mode, you should be able to control them per site that way. for example :)

#2 @krembo99
10 years ago

I know they could be defined anywhere , but since this is a multisite , regardless of the actual location where they are defined ,those constants will affect ALL blogs ( unless specifically defined or treated otherwise ).. I am also not sure how does a defined constant will act upon conflicts where the same constant is sharing a name but different in value. which will take priority ? (or the constant will just keep on "switching" and "bouncing" from one value to the other ) . Also, constants that are cron - dependent ( like trash or auto-save ) would be entering a bit of a conflict ( as to my understanding at least until the Heartbeat API #23216 will be fully implemented )

Last edited 10 years ago by SergeyBiryukov (previous) (diff)

#3 @Ipstenu
10 years ago

Nested ifs. Where and how you define them is the magic sauce :)

if ( $blog_id == 2 ) { define('EMPTY_TRASH_DAYS', 1 ); }

Which actually you could do in the wp-config, IIRC, and have a graceful fallback if not defined. I see people do that for having multiple blogs with different settings in one wp-config.php (stored outside of root) all the time. It's weird, but cool.

Sounds like a pretty awesome Multisite Plugin, actually. Most people who run a network assume they know better (and care more) about DB things than the people on the network (and they're probably right). So leaving the Super Admin to be the one who decides what's what is sensible.

#4 @nacin
10 years ago

We're trying to move away constants as much as possible, and this is one such reason.

For example WP_POST_REVISIONS is now confined to wp_revisions_to_keep() (which has a filter) and wp_revisions_enabled().

#5 @jeremyfelt
10 years ago

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

Closing as there isn't much actionable here. Workarounds are possible and the issue is more related to a general philosophy that WordPress has going forward.

#6 @mkormendy
8 years ago

I know this ticket is a tad old, but the following sample code is one proposed solution that I place at the end of my wp-config file that works nicely. In my case I wanted to define which sites were live and which were in development, but it can be easily modified for any site-specific purpose:

 * Development Environment Constant.
 * If this is a development environment, this will turn on certain debugging codes I have in my
 * theme and plugin files that I use for identifying which code blocks are in which files.
 * Remove the blog_id comparison for sites on production environment.

$blog_id = get_current_blog_id();
if ( $blog_id == 5 || $blog_id == 14 ) {
  define('ENV', 'dev');
Note: See TracTickets for help on using tickets.