Make WordPress Core

Ticket #30594: enable_themes_function_3.diff

File enable_themes_function_3.diff, 4.2 KB (added by igmoweb, 11 years ago)

Updated patch

  • 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

     
    12641264        }
    12651265
    12661266        /**
     1267         * Enable a theme for a whole network
     1268         *
     1269         * @param mixed $stylesheet Stylesheet name or array of stylesheets
     1270         * @access public
     1271         */
     1272        public static function network_enable_theme( $stylesheets ) {
     1273            if ( ! is_array( $stylesheets ) )
     1274                    $stylesheets = array( $stylesheets );
     1275
     1276            $allowed_themes = get_site_option( 'allowedthemes' );
     1277
     1278            foreach ( $stylesheets as $stylesheet )
     1279                $allowed_themes[ $stylesheet ] = true;
     1280
     1281            update_site_option( 'allowedthemes', $allowed_themes );
     1282    }
     1283
     1284        /**
     1285         * Disable a theme for a whole network
     1286         *
     1287         * @param mixed $stylesheet Stylesheet name or array of stylesheets
     1288         * @access public
     1289         */
     1290        public static function network_disable_theme( $stylesheets ) {
     1291        if ( ! is_array( $stylesheets ) )
     1292            $stylesheets = array( $stylesheets );
     1293
     1294        $allowed_themes = get_site_option( 'allowedthemes' );
     1295
     1296        foreach ( $stylesheets as $stylesheet ) {
     1297                if ( isset( $allowed_themes[ $stylesheet ] ) )
     1298                unset( $allowed_themes[ $stylesheet ] );
     1299        }
     1300
     1301        update_site_option( 'allowedthemes', $allowed_themes );
     1302    }
     1303
     1304        /**
    12671305         * Sort themes by name.
    12681306         *
    12691307         * @since 3.4.0
  • src/wp-includes/ms-functions.php

     
    24942494         */
    24952495        return apply_filters( 'subdirectory_reserved_names', $names );
    24962496}
     2497
     2498
     2499/**
     2500 * Enable a theme for a whole network
     2501 *
     2502 * @uses WP_Theme::network_enable_theme()
     2503 *
     2504 * @param mixed $stylesheet Stylesheet name or array of stylesheets
     2505 */
     2506function wp_network_enable_theme( $stylesheets ) {
     2507
     2508        WP_Theme::network_enable_theme( $stylesheets );
     2509
     2510}
     2511
     2512/**
     2513 * Disable a theme network wide
     2514 *
     2515 * @uses WP_Theme::network_disable_theme()
     2516 *
     2517 * @param mixed $stylesheet Stylesheet name or array of stylesheets
     2518 */
     2519function wp_network_disable_theme( $stylesheets ) {
     2520
     2521        WP_Theme::network_disable_theme( $stylesheets );
     2522
     2523}
     2524 No newline at end of file