Make WordPress Core


Ignore:
Timestamp:
04/14/2016 03:39:45 AM (9 years ago)
Author:
jeremyfelt
Message:

Multisite: Introduce WP_Theme methods to network enable/disable themes.

  • WP_Theme::network_enable_theme() can be used to enable a theme or array of themes on a network.
  • WP_Theme::network_disable_theme() can be used to disable a theme or array of themes on a network.
  • Use these new methods in the network admin vs direct update_site_option() calls.
  • Add tests.

Props igmoweb.
Fixes #30594.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/themes.php

    r36770 r37202  
    3030
    3131if ( $action ) {
    32     $allowed_themes = get_site_option( 'allowedthemes' );
    3332    switch ( $action ) {
    3433        case 'enable':
    3534            check_admin_referer('enable-theme_' . $_GET['theme']);
    36             $allowed_themes[ $_GET['theme'] ] = true;
    37             update_site_option( 'allowedthemes', $allowed_themes );
     35            WP_Theme::network_enable_theme( $_GET['theme'] );
    3836            if ( false === strpos( $referer, '/network/themes.php' ) )
    3937                wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
     
    4341        case 'disable':
    4442            check_admin_referer('disable-theme_' . $_GET['theme']);
    45             unset( $allowed_themes[ $_GET['theme'] ] );
    46             update_site_option( 'allowedthemes', $allowed_themes );
     43            WP_Theme::network_disable_theme( $_GET['theme'] );
    4744            wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
    4845            exit;
     
    5451                exit;
    5552            }
    56             foreach ( (array) $themes as $theme )
    57                 $allowed_themes[ $theme ] = true;
    58             update_site_option( 'allowedthemes', $allowed_themes );
     53            WP_Theme::network_enable_theme( (array) $themes );
    5954            wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
    6055            exit;
     
    6661                exit;
    6762            }
    68             foreach ( (array) $themes as $theme )
    69                 unset( $allowed_themes[ $theme ] );
    70             update_site_option( 'allowedthemes', $allowed_themes );
     63            WP_Theme::network_disable_theme( (array) $themes );
    7164            wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
    7265            exit;
Note: See TracChangeset for help on using the changeset viewer.