ugr*_*een 6 php wordpress jquery wordpress-theming
有人知道从页面编辑屏幕中删除主编辑器的方法吗?而不只是与CSS.我添加了一些带有tinymce的其他元框,它们与主要元素碰撞.
我有一个类从编辑屏幕中删除其他元框,但我不能这样摆脱主编辑器.我试图将'divpostrich'和'divpost'添加到类中的数组中(但没有运气):
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();
Run Code Online (Sandbox Code Playgroud)
我也尝试用jquery删除'divpostrich'.但是无法弄清楚将js放在哪里工作.当我用firebug删除浏览器中的'postdivrich'时 - 我剩下的tinymce字段工作得很完美.
有任何想法吗?
Eva*_*van 27
WP内置了WP支持,因此您不必直接使用全局变量并确保前向兼容性,如果它们更改了功能的处理方式.WP核心代码与@ user622018答案的逻辑完全相同
function remove_editor() {
remove_post_type_support('page', 'editor');
}
add_action('admin_init', 'remove_editor');
Run Code Online (Sandbox Code Playgroud)
小智 9
您正在寻找的是全局$_wp_post_type_features阵列.
以下是如何使用它的快速示例
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");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15411 次 |
| 最近记录: |