最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wordpress - How to add placeholder to wp_editor? - Stack Overflow

programmeradmin9浏览0评论

Here's my function, and I want to add a placeholder for wp_editor(). However, there's no default parameter available for this. How can I achieve it?

I'm using BuddyPress, and the following function is used for the "What's New" textarea. I have replaced the simple textarea with wp_editor().

function show_whats_new_tinymce_editor($editor_id) {
    $current_user = wp_get_current_user();
    $user_display_name = !empty($current_user->display_name) ? $current_user->display_name : __('User', 'reign');

    $content = "What's new, {$user_display_name}?";

    $settings = array(
        'media_buttons' => false,
        'textarea_name' => 'comment',
        'textarea_rows' => 6,
        'teeny' => false,
        'tinymce' => array(
            'wpautop' => true,
            'toolbar1' => 'bold,italic,bullist,numlist,link,unlink,undo,redo,addmedia,addgif,videoembed,fullscreen',
            'toolbar2' => '',
            'branding' => false,
            'statusbar' => true, // Show status bar for resizing
            'resize' => true, // Allow resizing
            'height' => 200, // Set default height
            'extended_valid_elements' => 'a[href|target=_blank], iframe[src|width|height|frameborder|allowfullscreen]',
            'rel_list' => array(array('title' => 'No Follow', 'value' => 'nofollow')),
            'link_default_target' => '_blank'
        ),
        'quicktags' => false
    );

    $dark_mode = isset($_COOKIE['reign_dark_mode']) && $_COOKIE['reign_dark_mode'] === 'true';
    $settings['tinymce']['content_css'] = $dark_mode ? get_stylesheet_directory_uri() . '/assets/css/dark-mode-editor.css' : '';

    wp_editor($content, $editor_id, $settings);
}
发布评论

评论列表(0)

  1. 暂无评论