Issue with WordPress text widget, Black Studio TinyMCE Widget and icl_sw_filters_widget_text

We had a problem where the text of plain old WordPress text widgets was not showing on pages. Error log showed entries like

[13-Dec-2017 09:25:29 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'icl_sw_filters_widget_text' not found or invalid function name in /home/itukylat/public_html/wp-includes/class-wp-hook.php on line 288

Function icl_sw_filters_widget_text is defined in WPML String Translation plugin, but we didn’t have that installed. The only place where I could find hook to icl_sw_filters_widget_text being added is in Black Studio Tiny MCE Widget plugin, in black-studio-tinymce-widget/includes/class-compatibility-plugins.php, function wpml_widget_after:

if ( false === has_filter( 'widget_text', 'icl_sw_filters_widget_text' ) && function_exists( 'icl_sw_filters_widget_text' ) || version_compare( $this->wpml_get_version(), '3.8.0' ) >= 0 ) {
    add_filter( 'widget_text', 'icl_sw_filters_widget_text', 0 );
}

and indeed that gets called, even though there is no icl_sw_filters_widget_text function anywhere.

I suspect there is something wrong with the if statement, but I didn’t dig any deeper. But I did report the issue to Black Studio Tiny MCE Widget author.

Meanwhile, as a workaround I defined my own icl_sw_filters_widget_text function:

function icl_sw_filters_widget_text($text) {
    return $text;
}

Now the texts in text widgets show up again.

One Reply to “Issue with WordPress text widget, Black Studio TinyMCE Widget and icl_sw_filters_widget_text”

  1. The Black Studio Tiny MCE Widget author just fixed the issue, in less than two hours of me reporting it (version 2.6.1). That was fast!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.