dragunoff

[WP] Change default edit screen layout

Aug 12th, 2011
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 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. /*
  39.  * update meta values for new users (or users who haven't messed with the screen settings yet)
  40.  * comment the 'if'-lines to force the change to all users
  41.  */
  42. if ( get_user_meta( $user_id, 'screen_layout_post', true ) == '' ) // check if the meta field is empty
  43.     update_user_meta( $user_id, 'screen_layout_post', '1' ); // and update the value
  44.    
  45. if ( get_user_meta( $user_id, 'metaboxhidden_post', true ) == '' )
  46.     update_user_meta( $user_id, 'metaboxhidden_post', $metaboxhidden_post ); // hidden boxes
  47.  
  48. if ( get_user_meta( $user_id, 'meta-box-order_post', trues ) == '' )
  49.     update_user_meta( $user_id, 'meta-box-order_post', $new_metabox_order ); // order and columns
  50.  
  51.  
  52. // uncomment the next block of code to disable the side column altogether
  53. /*
  54. add_filter( 'screen_layout_columns', 'custom_screen_layout_columns' );
  55.  
  56. function custom_screen_layout_columns( $columns ) {
  57.    
  58.     $columns['post'] = 1;
  59.    
  60.     return $columns;
  61.    
  62. }
  63. */
Advertisement
Add Comment
Please, Sign In to add comment