Take control of new bundled plugins and themes

On the WordCamp Frankfurt 2016 I showed some useful constants. One of them was CORE_UPGRADE_SKIP_NEW_BUNDLED which allows you to suppress/control the installation of twenty* themes and akismet with every WordPress update. Let’s take a look how to do that.Read the more up to date and famous one afterwards!
Everything cool and wrong about upcoming WordPress 4.7
Open in new tab for later

My favorite constant

During my presentation at the WordCamp it has been my favorite constant because it allows you to keep the “wp-content” directory clean. Usually and with every WordPress update it tries to install Akismet and some Twenty* themes. This can be suppressed controlled using the CORE_UPGRADE_SKIP_NEW_BUNDLED constant.

Here is the thing. During the presentation I said that installing new Twenty* can be suppressed but saying that it can be controlled is more accurate. After my presentation Marc Nilius, Torsten Landsiedel and another one (please name him in the comments) came up with WordPress 3.2 since when it works a bit different.

How to control Akismet and Twenty*-Updates

Thanks to the three I investigated a bit further and found out that it controls some states in the current WordPress 4.6. Three things can be done.

Akismet comes with WordPress

The “update-core.php” says:

// If not explicitly defined as false, don't install new default themes.
if ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' )
    || CORE_UPGRADE_SKIP_NEW_BUNDLED ) {
    $_new_bundled_files = array( 'plugins/akismet/' => '2.0' );
}

So when you don’t define the CORE_UPGRADE_SKIP_NEW_BUNDLED constant anywhere then Akismet will appear after installation in your wp-content directory when you use version 2.0 or above of WordPress.

Make it “true” to install nothing

In the wp-config.php you can set the constant to true:

define( 'CORE_UPGRADE_SKIP_NEW_BUNDLED', true );

For the upper statements this would mean that it installs Akismet at first sight. But later on you find this in the “update-core.php”:

if ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED')
  || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) {
  // here comes the install procedure
}

I removed some details but this lines say, that when the constant is set to true, then it won’t install anything at all. Not even things that might come some day.

Automatically get twentyseventeen with WordPress Update

Or twentyeighteen, twentytwenty and so on. For this you might want to change the constant to false:

define( 'CORE_UPGRADE_SKIP_NEW_BUNDLED', false );

This makes both (bigger) statements above fall back to the default for new bundled files:

$_new_bundled_files = array(
  'plugins/akismet/' => '2.0',
  'themes/twentyten/' => '3.0',
  'themes/twentyeleven/' => '3.2',
  'themes/twentytwelve/' => '3.5',
  'themes/twentythirteen/' => '3.6',
  'themes/twentyfourteen/' => '3.8',
  'themes/twentyfifteen/' => '4.1',
  'themes/twentysixteen/' => '4.4',
);

In this case you’ll get all the upcoming themes. This is a nice thing for a developer but surely nothing you’ll want for your customer.

EDIT: The version numbers you see there are the ones of WordPress and not the plugin or theme itself. Meaning that Twentysixteen should be installed with Version 4.4 of WordPress. So everyone that updates from 4.3 to 4.4 will get the new theme. Twentyseventeen might be there like this:

  'themes/twentyseventeen' => 4.7,

Which brings you the theme with WordPress 4.7 when CORE_UPGRADE_SKIP_NEW_BUNDLED is set to false.

Conclusion

During my presentation I was a bit to joyful for my favorite constant. But nowadays it is there to keep old packages in wp-content or get new ones. No longer my favorite constant but one of the interesting and long forgotten ones.

Big thanks to the three for showing me that! 🙂
I hope this is correct now 😉

Leave a Reply

Your email address will not be published. Required fields are marked *