Make WordPress Core

Ticket #30594: enable_themes_function_2.diff

File enable_themes_function_2.diff, 4.1 KB (added by igmoweb, 12 years ago)

Patch updated

  • src/wp-admin/network/themes.php

     
    2929$referer = remove_query_arg( $temp_args, wp_get_referer() );
    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_network_enable_theme( $_GET['theme'] );
    3836                        if ( false === strpos( $referer, '/network/themes.php' ) )
    3937                                wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
    4038                        else
    … …  
    4240                        exit;
    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_network_disable_theme( $_GET['theme'] );
    4744                        wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
    4845                        exit;
    4946                case 'enable-selected':
    … …  
    5350                                wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
    5451                                exit;
    5552                        }
    56                         foreach( (array) $themes as $theme )
    57                                 $allowed_themes[ $theme ] = true;
    58                         update_site_option( 'allowedthemes', $allowed_themes );
     53                        wp_network_enable_theme( (array) $themes );
    5954                        wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
    6055                        exit;
    6156                case 'disable-selected':
    … …  
    6560                                wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
    6661                                exit;
    6762                        }
    68                         foreach( (array) $themes as $theme )
    69                                 unset( $allowed_themes[ $theme ] );
    70                         update_site_option( 'allowedthemes', $allowed_themes );
     63                        wp_network_disable_theme( (array) $themes );
    7164                        wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
    7265                        exit;
    7366                case 'update-selected' :
  • src/wp-includes/class-wp-theme.php

     
    11951195        }
    11961196
    11971197        /**
     1198         * Enable a theme for a whole network
     1199         *
     1200         * @param mixed $stylesheet Stylesheet name or array of stylesheets
     1201         * @access public
     1202         */
     1203        public static function network_enable_theme( $stylesheets ) {
     1204
     1205                if ( ! is_array( $stylesheets ) )
     1206                        $stylesheets = array( $stylesheets );
     1207
     1208                $allowed_themes = get_site_option( 'allowedthemes' );
     1209
     1210                foreach ( $stylesheets as $stylesheet )
     1211                        $allowed_themes[ $stylesheet ] = true; 
     1212
     1213                update_site_option( 'allowedthemes', $allowed_themes );
     1214        }
     1215
     1216        /**
     1217         * Disable a theme for a whole network
     1218         *
     1219         * @param mixed $stylesheet Stylesheet name or array of stylesheets
     1220         * @access public
     1221         */
     1222        public static function network_disable_theme( $stylesheets ) {
     1223                if ( ! is_array( $stylesheets ) )
     1224                        $stylesheets = array( $stylesheets );
     1225               
     1226                $allowed_themes = get_site_option( 'allowedthemes' );
     1227
     1228                foreach ( $stylesheets as $stylesheet ) {
     1229                        if ( isset( $allowed_themes[ $stylesheet ] ) )
     1230                                unset( $allowed_themes[ $stylesheet ] );
     1231                }
     1232
     1233                update_site_option( 'allowedthemes', $allowed_themes );
     1234        }
     1235
     1236        /**
    11981237         * Sort themes by name.
    11991238         *
    12001239         * @since 3.4.0
  • src/wp-includes/ms-functions.php

     
    24312431
    24322432        return $site_results;
    24332433}
     2434
     2435/**
     2436 * Enable a theme for a whole network
     2437 *
     2438 * @uses WP_Theme::network_enable_theme()
     2439 *
     2440 * @param mixed $stylesheet Stylesheet name or array of stylesheets
     2441 */
     2442function wp_network_enable_theme( $stylesheets ) {
     2443
     2444        WP_Theme::network_enable_theme( $stylesheets );
     2445
     2446}
     2447
     2448/**
     2449 * Disable a theme network wide
     2450 *
     2451 * @uses WP_Theme::network_disable_theme()
     2452 *
     2453 * @param mixed $stylesheet Stylesheet name or array of stylesheets
     2454 */
     2455function wp_network_disable_theme( $stylesheets ) {
     2456
     2457        WP_Theme::network_disable_theme( $stylesheets );
     2458
     2459}