2017-01-23 7 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」に表示されます。例えば

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

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

私は、このガイドに従っていますhttps://paulund.co.uk/add-tinymce-editor-category-description

どうすれば解決できますか?

+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

これはほぼ正しいです、ちょうど私が2つの説明フィールドです。アイデア? –

+0

2つの説明フィールドを実装したいのですか? –

+0

あなたの関数のおかげで解決されました: "edit_cat_description"!ありがとうございました:) –

0

何も削除しないで、既存のテキストエリアにTinyMCEを初期化することができます。まずfunctions.phpエンキューadminスクリプトでは、私が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にあなたがあなたの好み(プラグインなど)へのTinyMCEを変更することができ

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

を追加します。

これが役に立ちます。コードの下

関連する問題