diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 55513dd0c2..6b34ee1666 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -949,32 +949,63 @@ case 'autosave-generate-nonces' : break; case 'closed-postboxes' : check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); - $closed = isset( $_POST['closed'] )? $_POST['closed'] : ''; + $closed = isset( $_POST['closed'] ) ? $_POST['closed'] : ''; $closed = explode( ',', $_POST['closed'] ); - $hidden = isset( $_POST['hidden'] )? $_POST['hidden'] : ''; + $hidden = isset( $_POST['hidden'] ) ? $_POST['hidden'] : ''; $hidden = explode( ',', $_POST['hidden'] ); - $page = isset( $_POST['page'] )? $_POST['page'] : ''; - if ( !preg_match( '/^[a-z-_]+$/', $page ) ) { + $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + + if ( !preg_match( '/^[a-z_-]+$/', $page ) ) die(-1); - } - $current_user = wp_get_current_user(); + + if ( ! $user = wp_get_current_user() ) + die(-1); + if ( is_array($closed) ) - update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed); + update_usermeta($user->ID, 'closedpostboxes_'.$page, $closed); + if ( is_array($hidden) ) - update_usermeta($current_user->ID, 'meta-box-hidden_'.$page, $hidden); -break; + update_usermeta($user->ID, 'meta-box-hidden_'.$page, $hidden); + + die('1'); + break; case 'hidden-columns' : check_ajax_referer( 'hiddencolumns', 'hiddencolumnsnonce' ); - $hidden = isset( $_POST['hidden'] )? $_POST['hidden'] : ''; + $hidden = isset( $_POST['hidden'] ) ? $_POST['hidden'] : ''; $hidden = explode( ',', $_POST['hidden'] ); - $page = isset( $_POST['page'] )? $_POST['page'] : ''; - if ( !preg_match( '/^[a-z_-]+$/', $page ) ) { + $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + + if ( !preg_match( '/^[a-z_-]+$/', $page ) ) die(-1); - } - $current_user = wp_get_current_user(); + + if ( ! $user = wp_get_current_user() ) + die(-1); + if ( is_array($hidden) ) - update_usermeta($current_user->ID, "manage-$page-columns-hidden", $hidden); -break; + update_usermeta($user->ID, "manage-$page-columns-hidden", $hidden); + + die('1'); + break; +case 'meta-box-order': + check_ajax_referer( 'meta-box-order' ); + $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; + $page_columns = isset( $_POST['page_columns'] ) ? (int) $_POST['page_columns'] : 0; + $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + + if ( !preg_match( '/^[a-z_-]+$/', $page ) ) + die(-1); + + if ( ! $user = wp_get_current_user() ) + die(-1); + + if ( $order ) + update_user_option($user->ID, "meta-box-order_$page", $order); + + if ( $page_columns ) + update_usermeta($user->ID, "screen_layout_$page", $page_columns); + + die('1'); + break; case 'get-permalink': check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; @@ -1106,11 +1137,6 @@ case 'inline-save-tax': exit; break; -case 'meta-box-order': - check_ajax_referer( 'meta-box-order' ); - update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] ); - die('1'); - break; case 'find_posts': check_ajax_referer( 'find-posts' ); diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 9488d4def7..23f1fd1f8e 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -143,24 +143,52 @@ function _wp_dashboard_control_callback( $dashboard, $meta_box ) { * @since unknown */ function wp_dashboard() { - echo "
\n\n"; + global $screen_layout_columns; - echo "
\n\n"; - $class = do_meta_boxes( 'dashboard', 'side', '' ) ? ' class="has-sidebar"' : ''; - echo "
\n\n"; - - echo "
\n\n"; - echo "
\n\n"; + $hide2 = $hide3 = $hide4 = ''; + switch ( $screen_layout_columns ) { + case 4: + $width = 'width:24.5%;'; + break; + case 3: + $width = 'width:32.67%;'; + $hide4 = 'display:none;'; + break; + case 2: + $width = 'width:49%;'; + $hide3 = $hide4 = 'display:none;'; + break; + default: + $width = 'width:98%;'; + $hide2 = $hide3 = $hide4 = 'display:none;'; + } +?> +
+\n"; do_meta_boxes( 'dashboard', 'normal', '' ); - echo "
\n\n"; - echo "
\n\n"; + + echo "\t
\n"; + do_meta_boxes( 'dashboard', 'side', '' ); - echo "
\n

\n"; + echo "\t

\n"; + do_meta_boxes( 'dashboard', 'column3', '' ); + + echo "\t
\n"; + do_meta_boxes( 'dashboard', 'column4', '' ); +?> +
+ + +

+\n\n"; +?> +

+ - echo ""; +
+ ' . __('Writing Posts') . '

'; - $_wp_contextual_help['post'] = $help; + switch ( $screen ) { + case 'post': + if ( !isset($_wp_contextual_help['post']) ) { + $help = drag_drop_help(); + $help .= '

' . __('Writing Posts') . '

'; + $_wp_contextual_help['post'] = $help; + } + break; + case 'page': + if ( !isset($_wp_contextual_help['page']) ) { + $help = drag_drop_help(); + $_wp_contextual_help['page'] = $help; + } + break; + case 'dashboard': + if ( !isset($_wp_contextual_help['dashboard']) ) { + $help = '

' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "

\n"; + $help .= drag_drop_help(); + $_wp_contextual_help['dashboard'] = $help; + } + break; + case 'link': + if ( !isset($_wp_contextual_help['link']) ) { + $help = drag_drop_help(); + $_wp_contextual_help['link'] = $help; + } + break; + case 'options-general': + if ( !isset($_wp_contextual_help['options-general']) ) + $_wp_contextual_help['options-general'] = __('General Settings'); + break; } - if ( !isset($_wp_contextual_help['page']) ) { - $help = drag_drop_help(); - $_wp_contextual_help['page'] = $help; - } - - if ( !isset($_wp_contextual_help['dashboard']) ) { - $help = drag_drop_help(); - $_wp_contextual_help['dashboard'] = $help; - } - - if ( !isset($_wp_contextual_help['link']) ) { - $help = drag_drop_help(); - $_wp_contextual_help['link'] = $help; - } - - if ( !isset($_wp_contextual_help['options-general']) ) - $_wp_contextual_help['options-general'] = __('General Settings'); - $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); ?>