dragunoff

wpquestions.com, ID = 2830

Aug 12th, 2011
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. /**
  2.  * Set the default column layout in the New Post section
  3.  *
  4.  * change every occurance of 'post' if you want to use it for pages or custom post types - example 'metaboxhidden_post' should be 'metaboxhidden_page' or 'metaboxhidden_custom_post_slug'
  5.  */
  6.  
  7. // get current user info
  8. global $current_user;
  9. get_currentuserinfo();
  10. $user_id = $current_user->ID;
  11.  
  12. // array of hidden metaboxes (removing a box from this array would cause it to appear)
  13. $metaboxhidden_post = array (
  14.     0 => 'tagsdiv-post_tag',
  15.     1 => 'postexcerpt',
  16.     2 => 'trackbacksdiv',
  17.     3 => 'postcustom',
  18.     4 => 'commentstatusdiv',
  19.     5 => 'slugdiv',
  20.     6 => 'authordiv',
  21.     7 => 'formatdiv',
  22.     8 => 'categorydiv',
  23.     9 => 'postimagediv',
  24. );
  25.  
  26. // metabox order and columns
  27. $new_metabox_order = array (
  28.     // the right-hand column
  29.     // make it empty
  30.     'side' => '',
  31.     // the main column
  32.     // set the order of boxes here, the ones in the $metaboxhidden_post array won't show up regardless of order
  33.     'normal' => 'submitdiv,postexcerpt,trackbacksdiv,postcustom,slugdiv,authordiv,tagsdiv-post_tag,categorydiv,formatdiv,commentstatusdiv,postimagediv',
  34.     // I'm not sure about this one
  35.     'advanced' => '',
  36. );
  37.  
  38. // update meta values
  39. update_user_meta( $user_id, 'screen_layout_post', 1 ); // 1-column layout
  40. update_user_meta( $user_id, 'metaboxhidden_post', $metaboxhidden_post ); // hidden boxes
  41. update_user_meta( $user_id, 'meta-box-order_post', $new_metabox_order ); // order and columns
  42.  
  43.  
  44. // disable the side column altogether (if necessary)
  45. add_filter( 'screen_layout_columns', 'custom_screen_layout_columns' );
  46.  
  47. function custom_screen_layout_columns( $columns ) {
  48.    
  49.     $columns['post'] = 1;
  50.    
  51.     return $columns;
  52.    
  53. }
Advertisement
Add Comment
Please, Sign In to add comment