Posted By

rickahontas on 03/09/13


Tagged

post page wordpress hide editor admin


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

rickahontas


Hide Page/Post Editor in Admin Backend


 / Published in: PHP
 

This is a combined version of Bill Erickson's hide post editor and rilwis' Metabox include for specific IDs. It hides the editor for a specified post ID. You can have multiple IDs, just separate with commas.

  1. <?php
  2.  
  3. add_action( 'admin_init', 'hide_editor' );
  4. function hide_editor() {
  5. // Get the Post ID
  6. // $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
  7. // if($post_id == '104'){
  8.  
  9. // Include in back-end only
  10. if ( ! defined( 'WP_ADMIN' ) || ! WP_ADMIN )
  11. return false;
  12.  
  13. // Always include for ajax
  14. if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
  15. return true;
  16.  
  17. // Check for post IDs
  18. // $checked_post_IDs = array (1,2,3,4);
  19. $checked_post_IDs = array( 104 );
  20.  
  21. if ( isset( $_GET['post'] ) )
  22. $post_id = $_GET['post'];
  23. elseif ( isset( $_POST['post_ID'] ) )
  24. $post_id = $_POST['post_ID'];
  25. else
  26. $post_id = false;
  27.  
  28. $post_id = (int) $post_id;
  29.  
  30. if ( in_array( $post_id, $checked_post_IDs ) ) {
  31.  
  32. remove_post_type_support('page', 'editor');
  33. // add custom .js to footer for uploading images
  34. function custom_admin_js() {
  35. $url = get_option('siteurl');
  36. $url = get_bloginfo('template_directory') . '/library/js/libs/meta-content.js';
  37. echo '"<script type="text/javascript" src="'. $url . '"></script>"';
  38. }
  39. add_action('admin_footer', 'custom_admin_js');
  40. } return true;
  41.  
  42. // If no condition matched
  43. return false;
  44. }
  45.  
  46. ?>

Report this snippet  

You need to login to post a comment.