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

plugins - How to add wp visual editor in a custom widget?

programmeradmin4浏览0评论

I am developing a widget plugin and want to add a textarea with WYSIWYG editor in widget settings.

Any help would be highly appreciated.

Thanks.

I am developing a widget plugin and want to add a textarea with WYSIWYG editor in widget settings.

Any help would be highly appreciated.

Thanks.

Share Improve this question asked Sep 26, 2014 at 20:51 bakarbakar 1013 silver badges15 bronze badges 1
  • Have you checked TinyMCE in Codex and some relative searches on google? – Mayeenul Islam Commented Oct 25, 2014 at 4:24
Add a comment  | 

2 Answers 2

Reset to default 1

Embedding WYSIWYG Editor in Custom widget needs the declaration of the fields under a form function, this will create a WYSIWYG Editor in your widget. You can define your parameter, what all features you want to show.

public function form( $instance ) {

    $rand    = rand( 0, 999 );
    $ed_id   = $this->get_field_id( 'wp_editor_' . $rand );
    $ed_name = $this->get_field_name( 'wp_editor_' . $rand );
    $content   = 'Hello World!';
    $editor_id = $ed_id;
    $settings = array('media_buttons' => true,'textarea_rows' => 4,'textarea_name' => $ed_name,'teeny' => true,);
    wp_editor( $content, $editor_id, $settings );

You can try plugins like this:

https://wordpress.org/plugins/wp-editor-widget/screenshots/
https://wordpress.org/plugins/black-studio-tinymce-widget/screenshots/

This plugins works all widgets

发布评论

评论列表(0)

  1. 暂无评论