기본 워드프레스 편집기를 사용자 정의하는 방법?
소니(word press 3) 소식을 들으니 반갑네요.3) 는 사용자 지정 필드에서 편집기의 여러 인스턴스를 쉽게 사용할 수 있는 기능을 제공하는 새로운 편집기 apiwp_editor()를 보유하고 있습니다.
하지만 기본 편집기(메인 콘텐츠용)를 사용자 지정해야 했고 이 기능으로 어떻게 해야 하는지 알 수 없었습니다.버튼이 적은 편집기의 크기를 변경해야 하는 배너라는 새로운 사용자 지정 게시물 유형에 대해 편집기를 커스터마이징해야 했습니다.대신 사용자 지정 필드를 사용하여 수행할 수 있다는 것을 알고 있지만 어떤 이유에서인지 배너 설명에 내용을 사용하고 싶습니다.
미리 감사드립니다.
기본 편집기 위에 사용자 지정 메타박스를 배치하는 솔루션을 찾고 있었는데 이전 질문(wp_editor로 기본 편집기를 사용자 지정하는 방법)에 대한 솔루션을 찾았습니다!
해결책은 먼저 기본 편집기의 설정을 해제하는 것이었습니다.그런 다음 다른 메타박스를 만들어 콘텐츠를 배치한 다음 wp_editor를 사용하여 새로운 인스턴스를 생성합니다. 간단하지 않습니까?
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'
);
}
}
이런 식으로 콘텐츠라는 새로운 메타박스를 등록했습니다.이제 편집자를 배치할 시간입니다.
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');
}
이제 편집기를 완전히 사용자 지정할 수 있습니다!지금의 모습입니다.여러분에게도 유용하기를 바랍니다!
여기에 표시된 것처럼 필터를 사용하여 편집기(Tiny MCE)를 사용자 정의할 수 있습니다.코드 조각 첨부:
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 )
전달된 모든 키를 보려면(위에서 링크한 페이지가 최신이라고 생각하지 않기 때문에 일부 키를 생략했습니다).여기서 최신 소스를 검색할 수 있습니다.찾으시는 필터가 작동하는 것을 확인하실 수 있습니다.public static function editor_settings($editor_id, $set)
또한, 이 문제가 단지 당신의 경우에만 발생하는 것을 확인하고 싶을 수도 있습니다.baner
post_type은 생성되는 모든 편집기 인스턴스에 영향을 미칩니다.
이 Editor를 사용해 볼 수 있습니다. 이 Editor를 사용하면 필드를 추가할 수 있습니다. 또한 간단히 사용하고 설치할 수 있습니다.
언급URL : https://stackoverflow.com/questions/8815843/how-to-customize-default-wordpress-editor
'bestsource' 카테고리의 다른 글
MySQL 오류 해결 "잠금을 시도할 때 데드락이 발견되었습니다. 트랜잭션 재시작 시도" (0) | 2023.10.16 |
---|---|
단위시험환경에서 스프링콩 재정립 (0) | 2023.10.16 |
다른 값이 비어 있거나 없는 경우 SQL 쿼리가 한 값을 표시하도록 하려면 어떻게 해야 합니까? (0) | 2023.10.16 |
Linux 운영 체제 클래스용 컨텐츠 (0) | 2023.10.16 |
jQuery 개체에서 셀렉터를 가져오려면 어떻게 해야 합니까? (0) | 2023.10.16 |