plugin development – wp_editor not working in Visual mode and becomes empty on save

I have created a custom widget, and want to transform the textarea into a wysiwyg editor.

The widget looks like this, I’ve stripped out all the unnecessary parts.

class Sponsor_Widget extends WP_Widget {

  function __construct() {
    $widget_ops = array('classname' => 'sponsor_widget', 'description' => __('Widget to display a Sponsor in the Secondary Widget Area.'));
    $control_ops = array('width' => 400, 'height' => 350);
    parent::__construct('sponsor_widget', __('Sponsor Widget'), $widget_ops, $control_ops);

  function widget( $args, $instance ) {
    // Other fields (Removed)

    $text = apply_filters( 'widget_text', empty( $instance('text') ) ? '' : $instance('text'), $instance );

    echo $before_widget;

    echo $text;

    echo $after_widget;

  function update( $new_instance, $old_instance ) {
    $instance = $old_instance;
    // Other fields (Removed)
    $instance('text') =  $new_instance('text');
    return $instance;

  function form( $instance ) {
    $instance = wp_parse_args( (array) $instance, array( 'sponsor_tier' => '5', 'sponsor_color' => '', 'sponsor_name' => '', 'logo_image' => '', 'logo_imageID' => '', 'linkpage' => '', 'text' => '' ) );
    // Other fields (Removed)

    $text = $instance('text');

      <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e( 'About Sponsor:' ); ?></label>
        $textAreaName = $this->get_field_name('text');
        $textAreaId = $this->get_field_id('text');
        $textAreaId = str_replace("-", "", $textAreaId);
        $textAreaId = str_replace("_", "", $textAreaId);

        $settings  = array(
          'media_buttons' => false,
          'teeny'         => true,
          'textarea_name' => $textAreaName,
          'textarea_rows' => 3,
          'tinymce'             => true,

        wp_editor( $text, $textAreaId, $settings );


Now the editor appears and has the content loaded, but editing inside the visual box does not allow me to save the content, because the change event doesn’t seem to be triggered on the textarea.

If I Switch to text mode and make a few edits, I can now save the content, and it saves correctly, but after the widget refreshes the editor becomes blank. As though it’s not re-initialized after the ajax refresh?

enter image description here

  1. I don’t have any errors in the console
  2. I’ve tried deactivating all plugins
  3. I even went ahead and stripped all _ and – from teh textAreaId thinking maybe it didn’t like those, but that’s not it either.

How to fix a The “tag” plugin does not exist error

when trying to access the home page of my site i am getting this error:

[Wed Jul 01 13:20:49.209695 2020] [lsapi:notice] [pid 8961:tid 47660541200128] [client] Backend log: Uncaught PHP Exception DrupalComponentPluginExceptionPluginNotFoundException: “The “tag” plugin does not exist. Valid plugin IDs for DrupalviewsPluginViewsPluginManager are: ” at /home/sitename/public_html/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php line 53n

every other page works fine.

any idea what i can do to fix this?
this is a drupal 8 site

functions – Override the filter from plugin in child theme

That’s not how filters work. Much like a filter in real life, something goes in, it gets changed, and the result goes out. Filters always take in a parameter and return something. They’re an opportunity to change something

So if we take this:

$review_num_fetch = apply_filters('tourmaster_review_num_fetch', 5);

This means the plugin uses 5, but it has given other code an opportunity to change this to another value. It does this by passing it to the tourmaster_review_num_fetch filter then using the result. So hook into that filter and return a different value to change it.

When that line runs, WP looks at all the filters registered, passes the value, and then replaces it with what the filter returned.

This is what a filter that adds 1 to the value looks like:

function addone( $in ) {
    $out = $in + 1;
    return $out;

And this is how you would add it:

add_filter( 'tourmaster_review_num_fetch', 'addone' );

With that you should have all the knowledge needed for implementing your solution