Within your widget, you can include a editor with a textarea and the class custom-widget-wp-editor
.
<textarea id="<?php echo $this->get_field_id( 'header' ); ?>" name="<?php echo $this->get_field_name( 'header' ); ?>" class="custom-widget-wp-editor"><?php echo $header; ?></textarea>
Make sure you include the JS-file within the widgets and customizer view.
/**
* Add a fix for tinymce within widgets.
*
* @return void
*/
function custom_widgets_widget_editor_script() {
global $pagenow;
if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
wp_enqueue_editor();
wp_enqueue_script( 'wp-editor-widgets', get_stylesheet_directory_uri() . '/js/wp-editor-widgets.js', array( 'jquery' ), '1.0', false );
}
}
add_action( 'admin_enqueue_scripts', 'custom_widgets_widget_editor_script' );
Hi Jeffrey,
This sadly doesn't seem to be working anymore...