Guest User

Untitled

a guest
Mar 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2.  
  3. // hide support for certain admin "features" (metaboxes) for some pages
  4. function hide_features() {
  5. if ( isset($_GET['action']) && $_GET['action'] === 'edit' ) {
  6. $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
  7. if( !isset( $post_id ) ) return;
  8.  
  9. $templated_pages_names = array(
  10. // 'template-contact.php',
  11. );
  12.  
  13. $templated_pages_ids = array();
  14.  
  15. foreach ($templated_pages_names as $page_name) {
  16. $templated_page_id = get_page_by_custom_template($page_name, 'id');
  17. if ($templated_page_id) {
  18. $templated_pages_ids[] = $templated_page_id;
  19. }
  20. }
  21.  
  22. $optioned_pages_ids = array(
  23. get_option('page_for_posts'),
  24. get_option('page_on_front')
  25. );
  26. $pages_no_content_editor = array_merge($optioned_pages_ids, $templated_pages_ids);
  27. $features_to_remove = array('editor');
  28. // for some reason we're unable to remove thumbnail and page-attributes support with this...
  29.  
  30. if(in_array($post_id, $pages_no_content_editor)){
  31. foreach ($features_to_remove as $feature) {
  32. remove_post_type_support('page', $feature);
  33. }
  34. }
  35. }
  36. }
  37.  
  38. add_action( 'do_meta_boxes', 'hide_features' );
Add Comment
Please, Sign In to add comment