WordPress.org

Make WordPress Core

Opened 8 years ago

Last modified 3 months ago

#13743 reopened enhancement

Ability to choose a network default theme

Reported by: fuwaneko Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Networks and Sites Keywords: dev-feedback has-patch has-screenshots needs-testing
Focuses: multisite Cc:

Description

As stated in summary. I use WP 3.0 RC and I've found out that there is no way to set up a theme which should be used by default for newly created sites in network. Even then I disable all the themes except the one I want to be used, WP still set thentyten as theme for newly registered site. The only solution I was able to find is to change theme description and name to twentyten and delete all other themes. It's so simple to let administrator choose default network theme, and this option is present in many other CMS.

Attachments (14)

13743.1.patch (5.1 KB) - added by Mista-Flo 17 months ago.
POC
13743.2.patch (5.2 KB) - added by Mista-Flo 17 months ago.
Code refactoring, handle case if WP_DEFAULT_THEME is set in wp-config.php
13743.3.patch (6.0 KB) - added by Mista-Flo 17 months ago.
Code refactoring
13743.4.patch (2.9 KB) - added by PieWP 17 months ago.
Changed loading priority
13743.5.patch (3.0 KB) - added by PieWP 17 months ago.
Added fallback message for select not rendering
13743.6.patch (14.4 KB) - added by Mista-Flo 14 months ago.
Handle network default theme in WPMS Theme list table (raw action)
Themes ‹ Network Admin Sites La Cigogne Française — WordPress.png (286.8 KB) - added by Mista-Flo 14 months ago.
WPMS Theme list table with raw action : set default theme
Themes ‹ Network Admin — WordPress2.png (198.7 KB) - added by Mista-Flo 14 months ago.
WPMS Theme list table with default theme
13743.7.patch (17.2 KB) - added by Mista-Flo 14 months ago.
Disallow theme desactivation for network default theme
13743.8.patch (17.2 KB) - added by Mista-Flo 14 months ago.
Fix wording
Screenshot_patch_8_networkdefauttheme.png (230.2 KB) - added by Mista-Flo 14 months ago.
13743.9.patch (8.3 KB) - added by Mista-Flo 3 months ago.
Refresh patch
13743.10.patch (8.0 KB) - added by PieWP 3 months ago.
schema.php:396 Fixed placement of comment, schema.php:380-383 Removed redundant code; covered by 397
13743.11.patch (8.3 KB) - added by Mista-Flo 3 months ago.

Download all attachments as: .zip

Change History (53)

#1 follow-up: @nacin
8 years ago

  • Milestone Unassigned deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Define WP_DEFAULT_THEME.

#2 @nacin
8 years ago

  • Milestone set to Future Release
  • Resolution worksforme deleted
  • Status changed from closed to reopened

I'm going to re-open into a future release, I can't seem to find a ticket discussing this otherwise. I agree there should probably be a way to define a default (radio button on ms-themes perhaps?), and that can simply be used in the schema when we're creating a new blog in a network.

#3 in reply to: ↑ 1 ; follow-up: @fuwaneko
8 years ago

  • Cc fuwaneko added

Replying to nacin:

Define WP_DEFAULT_THEME.

Oh, thank you. But still I think that this option should be present in admin interface rather than as php define in wp-config.php. At least this should be mentioned in docs somewhere more obvious than WP 3.0 Changelog :)

#4 in reply to: ↑ 3 @michaelh
8 years ago

Replying to fuwaneko:

Oh, thank you. But still I think that this option should be present in admin interface rather than as php define in wp-config.php. At least this should be mentioned in docs somewhere more obvious than WP 3.0 Changelog :)

As you suggested.

http://codex.wordpress.org/Super_Admin_Themes_SubPanel#Default_Theme

#5 @ocean90
8 years ago

Related #13768

#6 @wpmuguru
8 years ago

Because WordPress requires a functional theme to function, changing the default theme should remain a wp-config.php edit. People should be aware of what they are doing before changing it. As a config edit, the admin is more likely to look it up in the codex, ask in the support forum, etc.

Recommend wontfix

#7 @louyx
7 years ago

  • Cc louy08@… added

#8 @jeremyfelt
4 years ago

  • Component changed from Multisite to Themes
  • Focuses multisite added
  • Keywords default theme removed

We can close this if we don't want an option in the dashboard for default theme. As it stands, the constant works for setting without a UI.

#9 follow-up: @jeremyfelt
4 years ago

I do like the idea of having an option for default theme that applies to any new sites created on a network. This makes it easier to have one theme enabled for the primary site with a more appropriate default theme ready for the others.

#10 @chriscct7
2 years ago

  • Keywords has-patch added

#11 @chriscct7
2 years ago

  • Keywords needs-patch added; has-patch removed

#12 in reply to: ↑ 9 @Mista-Flo
17 months ago

  • Keywords ui-feedback added

Replying to jeremyfelt:

I do like the idea of having an option for default theme that applies to any new sites created on a network. This makes it easier to have one theme enabled for the primary site with a more appropriate default theme ready for the others.

I'm interessting in that too. We can't just let it for developers, Network administrators have not always technical skills, so I think we have to make life easier for them.

Last edited 17 months ago by Mista-Flo (previous) (diff)

#13 @Mista-Flo
17 months ago

  • Keywords has-patch dev-feedback added; needs-patch ui-feedback removed

This is a first patch to test this enhancement.

I have created a network option in the network settings : Default Theme.
It's a dropdown of all enabled themes in the network.

Then, in the wpmu_create_blog, if the default theme option is set, we update the site option with the good theme.

The current issue is that this option is in prior of WP_DEFAULT_THEME constant if it's set in the wp-config. How can we handle this ? Maybe a test like that :

if ( ! in_array ( WP_DEFAULT_THEME, WP_Theme::$default_themes ) )

There are others things that may need to be done in my opinion to have a better UX :
-In Network Admin > Themes list : Add a state "default theme" for the current default theme of the network (don't know how to display it in this page)
-In Network Admin > Add site : Allow the user to select the desired theme directly in the form.

What do you think ?

Last edited 17 months ago by Mista-Flo (previous) (diff)

@Mista-Flo
17 months ago

POC

This ticket was mentioned in Slack in #core-multisite by florian-tiar. View the logs.


17 months ago

@Mista-Flo
17 months ago

Code refactoring, handle case if WP_DEFAULT_THEME is set in wp-config.php

#15 @Mista-Flo
17 months ago

  • Keywords needs-testing added

Here's my second patch which is more solid, I handle backward compat with WP_DEFAULT_THEME const if it's defined on wp-config.php. If the new default theme network option is empty, default to the actual default core theme. But I don't check if the default core theme is enabled on network, don't know if it can cause troubles.

I tested the both situations (with the option, and with the constant in wp config), and it works well.

This ticket was mentioned in Slack in #core-multisite by florian-tiar. View the logs.


17 months ago

@Mista-Flo
17 months ago

Code refactoring

@PieWP
17 months ago

Changed loading priority

@PieWP
17 months ago

Added fallback message for select not rendering

#17 @PieWP
17 months ago

Changed loading priority in the patch of @Mista-Flo.

If a theme has been selected in the settings screen it should be loaded in favour of the defined WP_DEFAULT_THEME. Note that this is backwards compatible since the code will only execute when the new 'default_theme' network setting is set, so in existing installations it will fall back to the WP_DEFAULT_THEME constant.

#18 follow-up: @Mista-Flo
17 months ago

  • Keywords dev-feedback removed

Hey thanks for the help.

I get it now for the BC concern, it's fine.

I don't understand one thing in your patch. Did you forgot to assign again stylesheet and template var in case if we want to get the WP_DEFAULT_THEME or WP core theme.

And the if empty $theme could throw à warning if the $theme Var is not set, no ?

#19 in reply to: ↑ 18 @PieWP
17 months ago

Replying to Mista-Flo:

I don't understand one thing in your patch. Did you forgot to assign again stylesheet and template var in case if we want to get the WP_DEFAULT_THEME or WP core theme.

They are assigned on line 368, and only get overwritten in case the default theme option is set.

Replying to Mista-Flo:

And the if empty $theme could throw à warning if the $theme Var is not set, no ?

empty() also checks for an isset(), you can insert non-existing vars into an empty() without generating strict notices.

#20 @Mista-Flo
17 months ago

My bad, that's true. :)

Seems we have a nice patch here.

This ticket was mentioned in Slack in #core-multisite by florian-tiar. View the logs.


17 months ago

#22 @flixos90
17 months ago

  • Keywords 2nd-opinion added; needs-testing removed

This one has a patch, but I think we need some discussion about the idea/approach altogether before we start doing actual patch reviews. :)

I personally think that a network option to specify the default theme for new sites makes sense. Even if we don't consider the "developer vs user" thought, having a network option is an improvement over the WP_DEFAULT_THEME constant because that would, in a multinetwork setup, allow different default themes per network.

This ticket was mentioned in Slack in #core-multisite by florian-tiar. View the logs.


15 months ago

This ticket was mentioned in Slack in #core-multisite by florian-tiar. View the logs.


14 months ago

#25 @Mista-Flo
14 months ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

Since we seems to have a good direction on this subject, I opened a new ticket to better explain the approach : #39269

#26 @jeremyfelt
14 months ago

#39269 was marked as a duplicate.

#27 @jeremyfelt
14 months ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Reopening this ticket so that the conversation can stay in one place. :)

#28 @Mista-Flo
14 months ago

  • Keywords needs-refresh added; has-patch 2nd-opinion removed

So here is the recap of our last chat :

The goal

Let network administrators choose a network default theme on the admin.

Technical Approach

  • UX : Network > Themes list table with a row action "Set default theme" (this will be a network option)
  • Add an indicator on the same page to say "This theme is the default theme", like super admin in user list page.
  • Add a restriction that the theme cannot be deleted
  • Keep Backward Compatibility with WP_DEFAULT_THEME constant, that means, if the constant is set, we can't let user choose another default theme : How handle this behavior ?

@Mista-Flo
14 months ago

Handle network default theme in WPMS Theme list table (raw action)

#29 @Mista-Flo
14 months ago

  • Keywords dev-feedback ux-feedback ui-feedback has-patch added; needs-refresh removed

The last patch (13743.6) use the new technical approach proposed in https://core.trac.wordpress.org/ticket/13743#comment:28

I like this approach which avoid displaying a new option in the network settings.

Here some screenshots, btw, prehaps it needs some UX/UI feedback since the indicator and wording are not really clear.

@Mista-Flo
14 months ago

WPMS Theme list table with raw action : set default theme

@Mista-Flo
14 months ago

WPMS Theme list table with default theme

@Mista-Flo
14 months ago

Disallow theme desactivation for network default theme

#30 @karmatosed
14 months ago

Would changing it to 'Make Default' and removing the 'Theme' make more sense? Then you could indicate with 'Default'.

I'm suggesting this as that's a little packed visually and as you are in themes, I'm not sure you need to repeat the word.

#31 @Mista-Flo
14 months ago

  • Keywords ux-feedback ui-feedback removed

Hey, Thanks for your review :)

I have updated my last patch with your recommendation about the wording, I have just kept the "default theme" wording for the indicator, I guess it's more impacting.

@karmatosed Except that, any opinion for the UI ? Or do you think it's fine ?

@Mista-Flo
14 months ago

Fix wording

#32 @Mista-Flo
14 months ago

  • Keywords has-screenshots needs-testing added

#33 @Mista-Flo
14 months ago

  • Summary changed from Ability to change default theme for network sites to Ability to choose a network default theme

#34 @Mista-Flo
3 months ago

  • Component changed from Themes to Networks and Sites

This ticket was mentioned in Slack in #core-multisite by florian-tiar. View the logs.


3 months ago

#36 @desrosj
3 months ago

  • Keywords needs-refresh added

#37 follow-up: @desrosj
3 months ago

@Mista-Flo The most recent patch did not apply correctly for me. When you have a chance, can you please double check it?

@Mista-Flo
3 months ago

Refresh patch

#38 in reply to: ↑ 37 @Mista-Flo
3 months ago

  • Keywords needs-refresh removed

Replying to desrosj:

@Mista-Flo The most recent patch did not apply correctly for me. When you have a chance, can you please double check it?

Hi, thanks for your comment.

I have refreshed the patch. You can now apply and test it.

@PieWP
3 months ago

schema.php:396 Fixed placement of comment, schema.php:380-383 Removed redundant code; covered by 397

#39 @Mista-Flo
3 months ago

Thank you @PieWP !

I have updated the patch too, to use the new function WP_Theme::network_get_default_theme instead of always calling the get_network_option function.

@Mista-Flo
3 months ago

Note: See TracTickets for help on using tickets.