Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.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
Php Wordpress中的Tinymce错误页面类别_Php_Jquery_Html_Wordpress_Tinymce - Fatal编程技术网

Php Wordpress中的Tinymce错误页面类别

Php Wordpress中的Tinymce错误页面类别,php,jquery,html,wordpress,tinymce,Php,Jquery,Html,Wordpress,Tinymce,我把这段代码放在我的wordpress function.php中 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) { ?>

我把这段代码放在我的wordpress function.php中

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
    }
}
remove_filter('pre_term_description','wp_filter_kses');
删除过滤器(“术语描述”、“wp\U kses\U数据”);
添加过滤器(“编辑类别表单字段”、“类别描述”);
功能类别描述($tag)
{
?>

jQuery(函数($){ $('textarea#description')。最近('tr.form-field')。删除(); });
您可以在不删除任何内容和添加任何内容的情况下在现有的textarea上初始化TinyMCE

/**
 * 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' );

您可以根据自己的喜好修改tinyMCE(插件等)


希望这有帮助。

您可以在不删除任何内容的情况下,在现有文本区域中添加任何内容来初始化TinyMCE。首先,在
functions.php
enqueue admin脚本中,我在2017年进行了测试

/**
 * 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' );

您可以根据自己的喜好修改tinyMCE(插件等)


希望这有帮助。

下面的代码是工作代码,它可能会帮助您:

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;
 }
add_filter('edit_category_form_fields','edit_cat_description');
函数编辑目录描述($category){
$tag_extra_fields=get_选项(说明1);?>

.quicktags工具栏输入{float:left!重要; 宽度:自动!重要;} jQuery(函数($){ $('#description,textarea#tag description')。最近('.form-field')。hide(); });
以下代码是工作代码,它可能会帮助您:

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;
 }
add_filter('edit_category_form_fields','edit_cat_description');
函数编辑目录描述($category){
$tag_extra_fields=get_选项(说明1);?>

.quicktags工具栏输入{float:left!重要; 宽度:自动!重要;} jQuery(函数($){ $('#description,textarea#tag description')。最近('.form-field')。hide(); });
你从哪里得到这段代码的?它是一个指南吗?你能链接到其他资源或示例吗?我遵循以下原则:你能解释一下这里的困扰吗?对我来说,它似乎工作得很好。我的意思是,尽可能好…我希望使用“内容html”:你好。而不是“内容tmce”preview Editable这段代码是从哪里获得的?它是一个指南吗?你能链接到其他资源或示例吗?我遵循以下原则:你能解释一下这里让你感到困扰的是什么吗?对我来说,它似乎工作得很好。我的意思是,它应该很好…我希望是“内容html”:你好。而不是“内容tmce”预览可编辑这几乎是正确的,只是我是两个描述字段。想法?意味着你想要实现两个描述字段?由于你的函数:“编辑猫描述”解决了!谢谢:)@Matteo Enna…欢迎光临。这几乎是正确的,只是我是两个描述字段。想法?意味着您想要实现两个描述字段?由于您的函数:“编辑猫描述”!谢谢:)@Matteo Enna…欢迎光临。