The code uses create_function() for the ‘widgets_init’ action.
The following fix worked for me:
At the bottom of easy-social-icons.php change:
add_action( ‘widgets_init’, create_function( ”, ‘register_widget( “Cnss_Widget” );’ ) );
to:
//add_action( ‘widgets_init’, create_function( ”, ‘register_widget( “Cnss_Widget” );’ ) );
add_action( ‘widgets_init’, ‘cnss_widgets_init’ );
function cnss_widgets_init() {
register_widget( “Cnss_Widget” );
}
Here’s a simpler version that uses an anonymous function:
add_action( ‘widgets_init’, function() { register_widget( “Cnss_Widget” ); } );
-
This reply was modified 1 year, 8 months ago by
daymobrew. Reason: Include anonymous function version
Many thanks daymobrew, I switched plugins, but it is still installed and I will try it out. In the meantime for the above reason and other issues that arose with 7.1 and 7.2, I have reverted to 7.0.
@daymobrew
I was finally able to try your suggestions on my WAMP localhost, which is using PHP 7.0.
With the anonymous function version, the icon I was using disappeared and received the following:
Notice: Use of undefined constant ‘widgets_init’ - assumed '‘widgets_init’' in \wp-content\plugins\easy-social-icons\easy-social-icons.php on line 1456
When I tried your first suggestion I had similar issues:
Notice: Use of undefined constant ‘widgets_init’ - assumed '‘widgets_init’' in \wp-content\plugins\easy-social-icons\easy-social-icons.php on line 1457
Notice: Use of undefined constant ‘cnss_widgets_init’ - assumed '‘cnss_widgets_init’' in \wp-content\plugins\easy-social-icons\easy-social-icons.php on line 1457
I think the warnings are related to quotes – the editor changes the single and double quotes to opening and closing quotes.
I copied my code to: https://pastebin.com/vGibW4RE
and I fixed the quotes. Please try that.
Yes, I had thought so too, but when I started to play with the quotes, before I posted to you, I produced a fatal error.
Your last suggestion seems to work OK, so I went back to the anonymous function and switched the quotes:
add_action( "widgets_init", function() { register_widget( 'Cnss_Widget' ); } );
This seems to work well too so I have used it on my active site.