Prevent possible fatal error
-
Hello,
I would like to make you aware of potentially nasty bug in your plugin.
In
cleverreach-wp\Components\class-wp-clever-reach-widget.php
on line 97 there iswidget_title
filter applied as follows:$title = apply_filters( 'widget_title', $form->getName() );
The problem is the
widget_title
filter expects to be given three parameters, see: https://developer.www.ads-software.com/reference/hooks/widget_title/I wanted to use the
widget_title
filter to change widget title for your widget only, so I added following snippet to my theme’sfunctions.php
:add_filter('widget_title', function (string $title, array $instance, $id_base): string { return ($id_base === 'wp_cleverreach') ? 'Melden Sie sich für unseren Newsletter an' : $title ; }, 10, 3);
However, this resulted in “PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in […] and exactly 3 expected.”
The solution is to pass the additional two arguments – the fix is as easy as changing the line 97 to:
$title = apply_filters( 'widget_title', $form->getName(), $instance, $this->id_base );
- The topic ‘Prevent possible fatal error’ is closed to new replies.