2017-01-23 1 views
0

나는이 코드를 내 wordpress function.php에 넣었습니다.Wordpress의 Tinymce 오류 페이지 카테고리

remove_filter('pre_term_description', 'wp_filter_kses'); 
remove_filter('term_description', 'wp_kses_data'); 

add_filter('edit_category_form_fields', 'cat_description'); 
function cat_description($tag) 
{ 
    ?> 
     <table class="form-table"> 
      <tr class="form-field"> 
       <th scope="row" valign="top"><label for="description"><?php _ex('Description', 'Taxonomy Description'); ?></label></th> 
       <td> 
       <?php 
        $settings = array('wpautop' => true, 'media_buttons' => true, 'quicktags' => true, 'textarea_rows' => '15', 'textarea_name' => 'description'); 
        wp_editor(wp_kses_post($tag->description , ENT_QUOTES, 'UTF-8'), 'cat_description', $settings); 
       ?> 
       <br /> 
       <span class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></span> 
       </td> 
      </tr> 
     </table> 
    <?php 
} 

add_action('admin_head', 'remove_default_category_description'); 
function remove_default_category_description() 
{ 
    global $current_screen; 
    if ($current_screen->id == 'edit-category') 
    { 
    ?> 
     <script type="text/javascript"> 
     jQuery(function($) { 
      $('textarea#description').closest('tr.form-field').remove(); 
     }); 
     </script> 
    <?php 
    } 
} 

눈에 잘 띄지 않습니다.

그러나 "content-html"에 표시되어야하는 텍스트는 "content-tmce"에 표시됩니다. https://paulund.co.uk/add-tinymce-editor-category-description

는 어떻게 해결할 수 :이 가이드를 따라가

"content-html": &lt;strong&gt;hello&lt;/strong&gt; 

"content-tmce": <strong>hello</strong> 

: 예를 들어

?

+1

은 어디에서이 코드를 얻었 는가? 가이드였습니까? 다른 리소스 나 예제에 링크 할 수 있습니까? –

+0

나는 이것을 따른다 : https://paulund.co.uk/add-tinymce-editor-category-description –

+0

너를 괴롭히는 것이 조금 더 설명 할 수 있니? 내게 그것은 잘 작동하는 것 같습니다. 내 말은, 그래야 할만큼 괜찮은 것 ... –

답변

2

당신을 도움이 될 수 코드 노력하고 있습니다 :

add_filter('edit_category_form_fields', 'edit_cat_description'); 

function edit_cat_description($category) { 
    $tag_extra_fields = get_option(description1);?> 
    <table class="form-table"> 
    <tr class="form-field"> 
    <th scope="row" valign="top"><label for="description"> 
    <?php _ex('Description', 'Taxonomy Description'); ?></label></th> 
    <td> 
    <?php $settings = array('wpautop' => true, 'media_buttons' => true,'quicktags' => true, 'textarea_rows' => '15', 'textarea_name' => 'description'); 

    wp_editor(html_entity_decode($category->description , ENT_QUOTES, 'UTF-8'), 'description1', $settings); ?> 
    <br /> 
    <span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span> 
    </td> 
    </tr> 
    </table> 
    <?php 
} 

add_action('admin_print_styles', 'category_tinymce_css'); 
function category_tinymce_css() { 
?>  
    <style type="text/css"> 
    .quicktags-toolbar input{float:left !important; 
    width:auto !important;} 
    </style> 
    <?php 
} 

add_action('admin_head', 'taxonomy_tinycme_hide_description'); 
function taxonomy_tinycme_hide_description() { 
    global $pagenow; 
    if(($pagenow == 'edit-tags.php' || $pagenow == 'term.php' ||  isset($_GET['action']))) : ?> <script type="text/javascript"> 
    jQuery(function($) { 
    $('#description, textarea#tag-description').closest('.form- field').hide(); 
    }); 
    </script><?php endif; 
} 
+0

거의 정확합니다. 설명 필드는 두 개입니다. 아이디어? –

+0

두 개의 설명 필드를 구현 하시겠습니까? –

+0

귀하의 기능 덕분에 해결되었습니다 : "edit_cat_description"! 고맙습니다. :) –

0

아무 것도 제거하지 않고 아무것도 추가하지 않고도 기존 텍스트 영역에 TinyMCE를 초기화 할 수 있습니다. 먼저 functions.php 대기열 관리자 스크립트에서, 나는 myol 수동으로 tiny_mce을 대기열 수있는 솔루션을 사용하고 스물 세븐틴

/** 
* Load admin JS scripts 
* 
* @since 1.0.0 
*/ 
function twentyseventeen_scripts_admin() { 
    $js_src = includes_url('js/tinymce/') . 'tinymce.min.js'; 
    $css_src = includes_url('css/') . 'editor.css'; 

    echo '<script src="' . esc_url($js_src) . '" type="text/javascript"></script>'; 

    wp_register_style('tinymce_css', $css_src); 
    wp_enqueue_style('tinymce_css'); 

    wp_enqueue_script('admin', get_theme_file_uri('/assets/js/admin.js'), array('jquery'), '1.0', true); 
} 
add_action('admin_enqueue_scripts', 'twentyseventeen_scripts_admin'); 

테스트. 당신의 admin.js에서 다음

은 (플러그인 등)

jQuery(document).ready(function($){ 
    "use strict"; 

    if ($('.taxonomy-category').length) { // We're on taxonomy category screen 
     tinyMCE.init({ 
      mode : 'specific_textareas', 
      selector :'#edittag #description, #tag-description' 
     }); 
    } 

}); 

enter image description here

enter image description here

당신이 원하는대로 TinyMCE에 수정할 수 있습니다 추가 할 수 있습니다.

희망이 도움이됩니다. 코드 아래

관련 문제