ugreen ugreen - 1 year ago 69
PHP Question

Remove main editor from wordpress edit page screen

Anyone know of a way to remove the main editor from the page edit screen? And not just with css. I've added a few other meta boxes with the tinymce and they collide with the main one.

I have a class that removes other meta boxes from the edit screen, but I cant get rid of the main editor this way. I've tried to add 'divpostrich' and 'divpost' to the array in the class (but with no luck):

class removeMetas{
public function __construct(){
add_action('do_meta_boxes', array($this, 'removeMetaBoxes'), 10, 3);
}

public function removeMetaBoxes($type, $context, $post){
/**
* usages
* remove_meta_box($id, $page, $context)
* add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default')
*/
$boxes = array( 'slugdiv', 'postexcerpt', 'passworddiv', 'categorydiv',
'tagsdiv', 'trackbacksdiv', 'commentstatusdiv', 'commentsdiv',
'authordiv', 'postcustom');

foreach ($boxes as $box){
foreach (array('link', 'post', 'page') as $page){
foreach (array('normal', 'advanced', 'side') as $context){
remove_meta_box($box, $type, $context);
}
}
}
}
}

$removeMetas = new removeMetas();


I have also tried removing the 'divpostrich' with jquery. But cant figure out where to put the js for it to work. When I remove the 'postdivrich' in the browser with firebug - my remaining tinymce fields work perfect.

Any ideas?

Answer Source

What you are looking for is the global $_wp_post_type_features array.

Below is a quick example of how it can be used

function reset_editor()
{
     global $_wp_post_type_features;

     $post_type="page";
     $feature = "editor";
     if ( !isset($_wp_post_type_features[$post_type]) )
     {

     }
     elseif ( isset($_wp_post_type_features[$post_type][$feature]) )
     unset($_wp_post_type_features[$post_type][$feature]);
}

add_action("init","reset_editor");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download