From 2ac3a16aff2b0caf527a27b1bb998be72e64104f Mon Sep 17 00:00:00 2001 From: PeteMall Date: Mon, 29 Nov 2010 07:24:54 +0000 Subject: [PATCH] Update and error messages for site-themes. See #14897 git-svn-id: http://svn.automattic.com/wordpress/trunk@16606 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/network/site-themes.php | 53 +++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/wp-admin/network/site-themes.php b/wp-admin/network/site-themes.php index e016660d81..5a94da7dfb 100644 --- a/wp-admin/network/site-themes.php +++ b/wp-admin/network/site-themes.php @@ -43,6 +43,7 @@ if ( $action ) { switch ( $action ) { case 'enable': $theme = $_GET['theme']; + $update = 'enabled'; if ( !$allowed_themes ) $allowed_themes = array( $theme => true ); else @@ -50,37 +51,38 @@ if ( $action ) { break; case 'disable': $theme = $_GET['theme']; + $update = 'disabled'; if ( !$allowed_themes ) $allowed_themes = array(); else unset( $allowed_themes[$theme] ); break; case 'enable-selected': - $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); - if ( empty($themes) ) { - restore_current_blog(); - wp_redirect( wp_get_referer() ); - exit; - } - foreach( (array) $themes as $theme ) - $allowed_themes[ $theme ] = true; + if ( isset( $_POST['checked'] ) ) { + $update = 'enable'; + $themes = (array) $_POST['checked']; + foreach( (array) $themes as $theme ) + $allowed_themes[ $theme ] = true; + } else { + $update = 'error'; + } break; case 'disable-selected': - $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); - if ( empty($themes) ) { - restore_current_blog(); - wp_redirect( wp_get_referer() ); - exit; - } - foreach( (array) $themes as $theme ) - unset( $allowed_themes[ $theme ] ); + if ( isset( $_POST['checked'] ) ) { + $update = 'disable'; + $themes = (array) $_POST['checked']; + foreach( (array) $themes as $theme ) + unset( $allowed_themes[ $theme ] ); + } else { + $update = 'error'; + } break; } update_option( 'allowedthemes', $allowed_themes ); restore_current_blog(); - wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message + wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) ); exit; } @@ -110,7 +112,22 @@ foreach ( $tabs as $tab_id => $tab ) { echo '' . esc_html( $tab['label'] ) . ''; } ?> - +

' . __( 'Theme enabled.' ) . '

'; + break; + case 'disabled': + echo '

' . __( 'Theme disabled.' ) . '

'; + break; + case 'error': + echo '

' . __( 'No theme selected.' ) . '

'; + break; + } +} ?> +