X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/e08b42e8ad054ec67522d7ac1aaae5dc68cb3d01..fc24d733700d6d2bd886ffa9188df5c78069b018:/wp-admin/network/themes.php diff --git a/wp-admin/network/themes.php b/wp-admin/network/themes.php index aada6edb..e326c93c 100644 --- a/wp-admin/network/themes.php +++ b/wp-admin/network/themes.php @@ -40,14 +40,12 @@ if ( $action ) { else wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) ); exit; - break; case 'disable': check_admin_referer('disable-theme_' . $_GET['theme']); unset( $allowed_themes[ $_GET['theme'] ] ); update_site_option( 'allowedthemes', $allowed_themes ); wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) ); exit; - break; case 'enable-selected': check_admin_referer('bulk-themes'); $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); @@ -60,7 +58,6 @@ if ( $action ) { update_site_option( 'allowedthemes', $allowed_themes ); wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) ); exit; - break; case 'disable-selected': check_admin_referer('bulk-themes'); $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); @@ -73,7 +70,6 @@ if ( $action ) { update_site_option( 'allowedthemes', $allowed_themes ); wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) ); exit; - break; case 'update-selected' : check_admin_referer( 'bulk-themes' ); @@ -99,32 +95,50 @@ if ( $action ) { echo ''; require_once(ABSPATH . 'wp-admin/admin-footer.php'); exit; - break; case 'delete-selected': - if ( ! current_user_can( 'delete_themes' ) ) + if ( ! current_user_can( 'delete_themes' ) ) { wp_die( __('You do not have sufficient permissions to delete themes for this site.') ); + } + check_admin_referer( 'bulk-themes' ); $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); - unset( $themes[ get_option( 'stylesheet' ) ], $themes[ get_option( 'template' ) ] ); - if ( empty( $themes ) ) { wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); exit; } - $files_to_delete = $theme_info = array(); - foreach ( $themes as $key => $theme ) { - $theme_info[ $theme ] = wp_get_theme( $theme ); - $files_to_delete = array_merge( $files_to_delete, list_files( $theme_info[ $theme ]->get_stylesheet_directory() ) ); - } + $themes = array_diff( $themes, array( get_option( 'stylesheet' ), get_option( 'template' ) ) ); if ( empty( $themes ) ) { wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) ); exit; } + $files_to_delete = $theme_info = array(); + $theme_translations = wp_get_installed_translations( 'themes' ); + foreach ( $themes as $key => $theme ) { + $theme_info[ $theme ] = wp_get_theme( $theme ); + + // Locate all the files in that folder. + $files = list_files( $theme_info[ $theme ]->get_stylesheet_directory() ); + if ( $files ) { + $files_to_delete = array_merge( $files_to_delete, $files ); + } + + // Add translation files. + $theme_slug = $theme_info[ $theme ]->get_stylesheet(); + if ( ! empty( $theme_translations[ $theme_slug ] ) ) { + $translations = $theme_translations[ $theme_slug ]; + + foreach ( $translations as $translation => $data ) { + $files_to_delete[] = $theme_slug . '-' . $translation . '.po'; + $files_to_delete[] = $theme_slug . '-' . $translation . '.mo'; + } + } + } + include(ABSPATH . 'wp-admin/update.php'); $parent_file = 'themes.php'; @@ -141,16 +155,21 @@ if ( $action ) {

'; + } ?> @@ -163,8 +182,9 @@ if ( $action ) { @@ -182,7 +202,7 @@ if ( $action ) { '_wpnonce' => $_REQUEST['_wpnonce'] ), network_admin_url( 'themes.php' ) ) ) ); } - + $paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1; wp_redirect( add_query_arg( array( 'deleted' => count( $themes ), @@ -190,7 +210,6 @@ if ( $action ) { 's' => $s ), network_admin_url( 'themes.php' ) ) ); exit; - break; } } @@ -212,7 +231,7 @@ get_current_screen()->add_help_tab( array( get_current_screen()->set_help_sidebar( '

' . __('For more information:') . '

' . '

' . __('Documentation on Network Themes') . '

' . - '

' . __('Support Forums') . '

' + '

' . __('Support Forums') . '

' ); $title = __('Themes');