Fix for PHP8 – depreciated call to wp_localize_script
-
I’m running this plugin on WP Engine hosting and Php8 is a bit more strict on how it handles wp_localize_script().
The third parameter is expected to be an array, but a string is passed instead. This produces a depreciation notice throughout wp-admin.
It’s very easy to fix thanks to Query Monitor – just edit one line.
In wpengine-geoip/class-geoip.php, line 177 has a call to wp_localize_script().
Wrapping the third parameter in an array fixes it.
So it should read:
wp_localize_script( self::TEXT_DOMAIN . ‘-admin-js’, ‘nonce’, array(wp_create_nonce( self::TEXT_DOMAIN ) ));
If that change gets pushed to the repo, then all users of the plugin will benefit when the php8 switchover happens.
- You must be logged in to reply to this topic.