Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何自定义默认的wordpress编辑器?_Wordpress_Editor_Customization - Fatal编程技术网

如何自定义默认的wordpress编辑器?

如何自定义默认的wordpress编辑器?,wordpress,editor,customization,Wordpress,Editor,Customization,很高兴听到索尼(wordpress3.3)有了新的编辑器api,使我们能够轻松地在自定义字段中使用编辑器的多个实例 但我需要自定义默认编辑器(用于主要内容),但我不知道如何使用此函数。 我需要为名为baner的新自定义帖子类型自定义编辑器,我需要用更少的按钮更改编辑器的大小。我知道我可以通过简单地使用自定义字段来实现,但是出于某种原因,我想使用内容来描述横幅 提前感谢。您可以尝试此方法,您可以添加其他字段,而且使用和安装也很简单。您可以使用过滤器自定义编辑器(TinyMCE),如图所示。附加代码

很高兴听到索尼(wordpress3.3)有了新的编辑器api,使我们能够轻松地在自定义字段中使用编辑器的多个实例

但我需要自定义默认编辑器(用于主要内容),但我不知道如何使用此函数。 我需要为名为baner的新自定义帖子类型自定义编辑器,我需要用更少的按钮更改编辑器的大小。我知道我可以通过简单地使用自定义字段来实现,但是出于某种原因,我想使用内容来描述横幅


提前感谢。

您可以尝试此方法,您可以添加其他字段,而且使用和安装也很简单。

您可以使用过滤器自定义编辑器(TinyMCE),如图所示。附加代码段:

function myformatTinyMCE($in)
{
 $in['plugins']='inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen';
 $in['wpautop']=true;
 $in['apply_source_formatting']=false;
 $in['theme_advanced_buttons1']='formatselect,forecolor,|,bold,italic,underline,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,|,wp_fullscreen,wp_adv';
 $in['theme_advanced_buttons2']='pastetext,pasteword,removeformat,|,charmap,|,outdent,indent,|,undo,redo';
 $in['theme_advanced_buttons3']='';
 $in['theme_advanced_buttons4']='';
 return $in;
}
add_filter('tiny_mce_before_init', 'myformatTinyMCE' );
这段代码应该放在主题的
functions.php
文件中。您可能希望
print\r($in)
查看所有传递的密钥(我在这里省略了其中一些密钥,因为我不相信我上面链接的页面是最新的)。您可以浏览最新的源代码。在函数
公共静态函数编辑器设置($editor\u id,$set)


此外,您可能还希望确保这只发生在您的
baner
post_类型上,因为这将影响创建的编辑器的所有实例。

我正在寻找一种解决方案,将自定义元盒放置在默认编辑器上方,我已经找到了解决我的旧问题的方法(如何使用wp_编辑器自定义默认编辑器)

解决方案是先取消默认编辑器的设置,然后创建另一个元框来放置内容,然后使用wp_编辑器创建新的实例,是不是很简单

add_action( 'add_meta_boxes', 'page_meta_boxes' );
public function page_meta_boxes()
{

    global $_wp_post_type_features;
            //ive defined my other metaboxes first with higher priority
    add_meta_box(
        $id     =   'page_heading_meta_box',
        $title  =   __('Heading'),
        $callback   = array(&$this,'render_page_heading_metabox'),
        $post_type  =   'page',
        $context    =   'normal',
        $priority   =   'core'
        );
    add_meta_box(
        $id     =   'page_description_meta_box',
        $title  =   __('Description'),
        $callback   = array(&$this,'render_page_description_metabox'),
        $post_type  =   'page',
        $context    =   'normal',
        $priority   =   'core'
        );
    //check for the required post type page or post or <custom post type(here article)  
    if (isset($_wp_post_type_features['article']['editor']) && $_wp_post_type_features['post']['editor']) {
        unset($_wp_post_type_features['article']['editor']);
        add_meta_box(
            'wsp_content',
            __('Content'),
            array(&$this,'content_editor_meta_box'),
            'article', 'normal', 'core'
        );
    }
    if (isset($_wp_post_type_features['page']['editor']) && $_wp_post_type_features['page']['editor']) {
        unset($_wp_post_type_features['page']['editor']);
        add_meta_box(
            'wsp_content',
            __('Content'),
            array(&$this,'content_editor_meta_box'),
            'page', 'normal', 'low'
        );
    }
    }
add_操作('add_meta_box','page_meta_box');
公共功能页面\元\框()
{
全局$\u wp\u post\u type\u功能;
//我首先以更高的优先级定义了我的其他代谢组
添加元框(
$id='页面标题\元框',
$title=u uu('Heading'),
$callback=array(&$this,'render\u page\u heading\u metabox'),
$post_类型='page',
$context='normal',
$priority='core'
);
添加元框(
$id='页面描述\元框',
$title=u u_;('Description'),
$callback=array(&$this,'render\u page\u description\u metabox'),
$post_类型='page',
$context='normal',
$priority='core'
);
//检查所需的post类型页或post或true,
#text区域名称
#(字符串)(可选)提交表单时分配给生成的textarea和传递的参数的名称。(可能包括[]以数组形式传递数据)
#默认值:$editor\u id
'textarea_name'=>'content',
#text区域_行
#(整数)(可选)文本区域要显示的行数
#默认值:获取选项('Default\u post\u edit\u rows',10)
#tabindex
#(整数)(可选)用于表单字段的tabindex值
#默认值:无
'tabindex'=>'4'
#编辑者
#(字符串)(可选)用于视觉和HTML编辑器按钮的附加CSS样式,需要#包括标记,可以使用“范围”
#默认值:无
#编辑课
#(字符串)(可选)附加到编辑器文本区域的任何额外CSS类
#默认值:
#微小的
#(布尔)(可选)是否输出按此键时使用的最小编辑器配置
#默认值:false
#dfw
#(布尔)(可选)是否用DFW替换默认全屏编辑器(需要特定的DOM元素和css)
#默认值:false
#蒂尼姆斯
#(array)(可选)Load TinyMCE,可用于使用array()将设置直接传递给TinyMCE
#默认值:true
#快速标签
#(数组)(可选)加载Quicktags,可用于使用数组()将设置直接传递给Quicktags
#默认值:true
);
wp_编辑器($post->post_内容,'content');
}
现在您可以完全自定义编辑器了!这就是现在的样子。希望它对你也有用!

它有点重,有额外的表格,我不喜欢这样,不管怎样,谢谢你的建议。我尝试过这个,但没有找到任何选项,比如更改编辑器大小(即textarea\u行),使其变小等。您在初始问题中链接到了wp_编辑器参考——您可以使用键
textarea_行
teeny
通过
$settings
参数修改这些选项
        function content_editor_meta_box($post)
    {
        $settings = array(
            #media_buttons
            #(boolean) (optional) Whether to display media insert/upload buttons
            #Default: true
            'media_buttons' => true,

            #textarea_name
            #(string) (optional) The name assigned to the generated textarea and passed parameter when the form is submitted. (may include [] to pass data as array)
            #Default: $editor_id
            'textarea_name'=>'content',

            #textarea_rows
            #(integer) (optional) The number of rows to display for the textarea
            #Default: get_option('default_post_edit_rows', 10)

            #tabindex
            #(integer) (optional) The tabindex value used for the form field
            #Default: None
            'tabindex' => '4'

            #editor_css
            #(string) (optional) Additional CSS styling applied for both visual and HTML editors buttons, needs to #include <style> tags, can use "scoped"
            #Default: None

            #editor_class
            #(string) (optional) Any extra CSS Classes to append to the Editor textarea
            #Default:

            #teeny
            #(boolean) (optional) Whether to output the minimal editor configuration used in PressThis
            #Default: false

            #dfw
            #(boolean) (optional) Whether to replace the default fullscreen editor with DFW (needs specific DOM elements #and css)
            #Default: false

            #tinymce
            #(array) (optional) Load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
            #Default: true

            #quicktags
            #(array) (optional) Load Quicktags, can be used to pass settings directly to Quicktags using an array()
            #Default: true
        );
        wp_editor($post->post_content,'content');

    }