Opened 11 years ago
Closed 10 years ago
#30594 closed enhancement (fixed)
New function to network enable a theme
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.6 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Themes | Keywords: | has-patch has-unit-tests |
| Focuses: | administration, multisite | Cc: |
Description
I haven't found any ticket asking about this but what if we create a new function to network enable/disable a theme?
Right now, wp-admin/themes.php is doing the following thing to enable themes in a network:
...
$allowed_themes = get_site_option( 'allowedthemes' );
switch ( $action ) {
case 'enable':
check_admin_referer('enable-theme_' . $_GET['theme']);
$allowed_themes[ $_GET['theme'] ] = true;
update_site_option( 'allowedthemes', $allowed_themes );
...
We could encapsulate that in new functions, one to enabling and another to disabling.
Just in case, the code was pretty easy so I upload here a patch.
Thanks.
Attachments (7)
Change History (24)
#2
@
11 years ago
- Milestone changed from Awaiting Review to Future Release
- Summary changed from New function to network activate a theme to New function to network enable a theme
Thanks for the ticket igmoweb, this seems pretty sensible.
- I'd go with the singular
wp_network_enable_theme()andwp_network_disable_theme(). - We may be able to attach these as static methods to
WP_Theme.
#3
@
11 years ago
Patch updated (enable_themes_function_2.diff). Now using WP_Theme and also improved the comments.
Thanks.
This ticket was mentioned in Slack in #core by igmoweb. View the logs.
10 years ago
#6
@
10 years ago
I've updated the patch (enable_themes_function_3.diff), as it needed some refreshment and also attached two unit tests.
Thanks.
This ticket was mentioned in Slack in #core by igmoweb. View the logs.
10 years ago
#8
@
10 years ago
@jeremyfelt As discussed in #core, I'm attaching new patch: Functions + unit tests in the same patch
I've also added a few more asserts that make sure that network enabling/disabling the same theme twice works as expected.
#10
@
10 years ago
- Milestone changed from Future Release to 4.5
- Owner set to igmoweb
- Status changed from new to assigned
Thanks @igmoweb, this is looking good.
Some minor adjustments:
- I think we can follow how
WP_Themeis setup in general and useWP_Theme::network_enable_theme()andWP_Theme::network_disable_theme()directly without providing thewp_network_*wrapper functions. - The additions to
class-wp-theme.phpneed to be formatted per core code style. It looks like spacing is a bit off in the methods and theifstatements need braces. - Let's split the tests up into 4 parts: network enable a single theme, network enable an array of themes, network disable a single theme, and network disable an array of themes.
This ticket was mentioned in Slack in #core by jorbin. View the logs.
10 years ago
#13
@
10 years ago
- Milestone changed from 4.5 to Future Release
Due to lack of activity and the upcoming 4.5 beta 1 deadline, this is going to be punted.
#14
@
10 years ago
- Keywords 4.6-early added
Excellent stuff @igmoweb, thank you.
I've refreshed and adjusted the tests a bit in 30594.3.diff and added an is_multisite() check to each of the new methods. I think we'll be able to get this in early for 4.6.
Enable/Disable themes network widly functions