WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#49056 new defect (bug)

Can we stop bundling default themes?

Reported by: crdunst Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Upgrade/Install Keywords: close
Focuses: Cc:
PR Number:

Description

Maybe this has been raised before - I searched, but couldn't find the same suggestion.

Can WordPress stop bundling themes with upgrades?

I understand a default theme (such as TwentyTwenty) makes sense with a fresh install, but not on existing websites, for a number of reasons:

1) Bundled, but unused themes just mean more code overhead. More guessable directories/files for malicious actors to hack.

2) Extra disk space is needed to store these mostly unused themes. Individually it's not much space, but multiply it up into millions of installs, and cumulatively it's significant.

3) Extra bandwidth when they're downloaded for both WordPress.org CDNs, and also for end-user sites.

I deleted 2020 theme from a client's website when upgrading to 5.3, and I've just had to delete it again, presumably after 5.3.1 or 5.3.2 self-installed. They're never going to use one of the default themes (as good as they are) for their corporate site, so it's just a waste of everyone's time. I'm maintaining dozens of sites, so this gets annoying.

There's an argument for 'what about if they delete their only theme - it needs a theme to default to'. This doesn't stack up though if the end-user can manually delete the default theme, and find themselves in the same position. UI can overcome this to a degree when no themes are available with a 'search the repo for a theme, how about twentytwenty (maybe the interface does? I've never tried deleting all themes on an install).

Anyway, just my feedback from a regular user/maintainer.

Change History (10)

#1 @knutsp
5 weeks ago

  • Keywords close added

Quoting @otto42

The default themes are actually there for a reason. The core requires a fallback theme in case the currently active theme can’t be found or is inaccessible for whatever reason. So, the default theme should be present, even if you’re not using it.

You can use a constant CORE_UPGRADE_SKIP_NEW_BUNDLED: https://core.trac.wordpress.org/browser/tags/5.3/src/wp-admin/includes/update-core.php#L810

Last edited 5 weeks ago by knutsp (previous) (diff)

#2 follow-up: @crdunst
5 weeks ago

Thanks for your response, and for the heads-up on the constant.

It begs two questions for me though:

1) The constant exists, so if it's set, what happens if all themes are then deleted? WP must handle it in some way?

2) If WP doesn't handle 'no themes' gracefully, shouldn't we change that behaviour? A simple message on the front-end, and a notice on the back-end: "you have no theme installed, please install one" or similar?

Someone with time and the inclination could calculate the number of bundled downloads, per incremental updates, and the disk space/bandwidth consumed per year. Cumulatively, perhaps there's an energy wastage issue in this day and age of climate change? Maybe it's trivial, maybe it's not. Just feels like it's an 'always been the case, WP needs it' without challenging the pros/cons.

#3 @knutsp
5 weeks ago

  • Focuses coding-standards removed

I wonder:

  1. What is the logic with this constant to defined and set to false, not true (it contains SKIP)?
  1. Could a new default theme replace the previous default theme if present and inactive (not for multisite)?
  1. Should this be a core user option with a UI, perhaps when/if there will be a core UI user option to automatically update major versions?

After a major core update I always delete the previous default theme, on all (single) sites not using this (being the active theme).

Site Health recommends removing unused themes, except (the last or any?) default theme (and parent theme of active child theme). So updating core creates issues in Site Health (new default themes and the bundeled plugins). This is not ideal.

This ticket was mentioned in Slack in #forums by pbiron. View the logs.


4 weeks ago

#6 @tomgreer
4 weeks ago

I'm thrilled to learn about the CORE_UPGRADE_SKIP_NEW_BUNDLED constant. We've been busy deleting and re-deleting twenty-twenty from every site we maintain (about 60). We delete because they will never be needed and will require time and attention when patches are released.

By the way, I agree with @crdunst. You are wasting a tremendous amount of bandwidth and disk storage by auto-installing each year's new theme by default. I see websites just about every day with twenty-twelve, thirteen, fourteen, etc. installed. And none have ever been used. What a waste!

I disagree with the argument about the need for fallback in case the active theme can't be loaded. That's a tremendously weak argument. First of all, that almost never happens with an active website -- and second, I would want the website to crash and notify like it does on a fatal error as I'm sure that my content would look terrible using twenty-twenty. I'd want to be notified so I could address the issue.

Last edited 4 weeks ago by tomgreer (previous) (diff)

#7 @tomgreer
4 weeks ago

I assumed that CORE_UPGRADE_SKIP_NEW_BUNDLED needs to be set to TRUE for WordPress to skip installing the default theme as part of core update.

But the source code comments say "To disable new themes from being installed on upgrade, explicitly define CORE_UPGRADE_SKIP_NEW_BUNDLED as false." That's counter-intuitive.

So I explored the code. It appears to me the comment is wrong.

Please clarify, what value should be assigned to CORE_UPGRADE_SKIP_NEW_BUNDLED to tell WordPress not to installs themes when the core is updated?

Last edited 4 weeks ago by tomgreer (previous) (diff)

#8 in reply to: ↑ 2 @SergeyBiryukov
4 weeks ago

Replying to crdunst:

2) If WP doesn't handle 'no themes' gracefully, shouldn't we change that behaviour? A simple message on the front-end, and a notice on the back-end: "you have no theme installed, please install one" or similar?

I think that was addressed in [25666] / #21670 and [36335] / #21931.

Replying to tomgreer:

I disagree with the argument about the need for fallback in case the active theme can't be loaded.

Another argument is that not bundling new default themes provides a bad user experience for users seeking to experiment with them, see [39064] / #38551.

Replying to tomgreer:

Please clarify, what value should be assigned to CORE_UPGRADE_SKIP_NEW_BUNDLED to tell WordPress not to installs themes when the core is updated?

Thanks for pointing that out, it does look confusing.

Reading through the related commits and tickets:

The comment 8:ticket:34306 clarifies the intention behind explicitly setting the constant to false to re-enable installing new default themes at the time. Some implementation details have changed between the patches 34306.2.diff:ticket:34306 and 34306.3.diff:ticket:34306.

It looks like current comment refers to a part of [35738] that was later reverted in [39064]. The comment should be updated to reflect the initial intention of the constant as introduced in [17576] / 23:ticket:14484.

To summarize, in order to tell WordPress not to install new themes on update, CORE_UPGRADE_SKIP_NEW_BUNDLED should be set to true, as the name suggests.

Last edited 4 weeks ago by SergeyBiryukov (previous) (diff)

#9 @SergeyBiryukov
4 weeks ago

In 47007:

Docs: Correct the note about the CORE_UPGRADE_SKIP_NEW_BUNDLED constant in $_new_bundled_files global description.

In order to tell WordPress not to install new bundled themes on update, CORE_UPGRADE_SKIP_NEW_BUNDLED should be set to true, as the name suggests, not false.

Follow-up to [39064].

Props tomgreer, knutsp, crdunst.
See #49056.

#10 @autotutorial
4 weeks ago

I will add a note for the default theme.
https://github.com/WordPress/WordPress/blob/5.3-branch/wp-includes/default-constants.php#L407
it is also possible to force the use of a predefined theme in the wp-config.php file, before each modification make a backup of the database and files.
I changed it to a WordPress multisite 5.3 directly from the core file.

Last edited 4 weeks ago by autotutorial (previous) (diff)
Note: See TracTickets for help on using tickets.