2016년 6월 1일 수요일

워드프레스 기본 에디터를 네이버 스마트에디터로 변경

워드프레스 기본 에디터로 작성시 <br>태그가 처리되지 않는 점과 쓰레기코드들이 붙는등
불편함이 있어 네이버 스마트에디터를 기본 에디터로 바꿔버렸습니다.

망보드에 있는 스마트에디터랑 업로드 기능을 사용합니다.
스마트에디터에서 사진업로드를 하면 망보드 파일관리자에 나타납니다.


/* 글 작성에 스마트에디터 사용 : 망보드 스마트에디터 파일 업로드 사용 */
add_filter('the_editor', 'wt_my_editor');
function wt_my_editor($wrapper)
{
echo("<style type='text/css'>.smartEditor { width:99%; }</style>");
$html = "<link href='/wp-content/plugins/mangboard/plugins/editors/smart/css/default.css' rel='stylesheet' type='text/css' />";
$html .= "<script type='text/javascript' src='/wp-content/plugins/mangboard/plugins/editors/smart/js/HuskyEZCreator.js?ver=4.5.2'></script>";
$html .= "<script type='text/javascript'>
var oEditors=[];
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors,
elPlaceHolder: 'content',
sSkinURI:'/wp-content/plugins/mangboard/plugins/editors/smart/SmartEditor2Skin.html',
fCreator: 'createSEditor2'});

jQuery(document).ready(function() {
jQuery('#post').on('submit', function() {
oEditors.getById['content'].exec('UPDATE_CONTENTS_FIELD', []);
this.submit();
});
jQuery('#edButtonHTML').remove();
});
</script>";
$html .= "<div id='smartEditor'><textarea class='smartEditor' rows='10' cols='*' name='content' tabindex='2' id='content'>%s</textarea></div>";

return $html;
}

/* html 퀵태그 숨김 */
add_filter('wp_editor_settings', 'wt_editor_settings');
function wt_editor_settings($settings) {
$settings['quicktags'] = false;
return $settings;
}

/* 워드프레스 리치에디터 사용 금지 */
add_filter( 'user_can_richedit', 'wt_patrick_user_can_richedit');
function wt_patrick_user_can_richedit($c) {
return false;
    global $post_type;
    if ('post' == $post_type)
        return false;
    return $c;
}

댓글 없음:

댓글 쓰기