facebookincubator / Facebook-Pixel-for-Wordpress

A plugin for advertisers who use Wordpress to enable them easily setup the facebook pixel.
GNU General Public License v2.0
37 stars 34 forks source link

Not complain with PHP >5.6 #38

Open golendercaria opened 2 years ago

golendercaria commented 2 years ago

The plugin give a compatibilities with PHP 5.6 or higher, but is not the case.

When I have install the plugin and going to wp-admin/options-general.php?page=facebook_pixel_options I have a blank page and this error on error_log :

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function FacebookPixelPlugin\Core\str_contains() in /var/www/vhosts/xxxx/httpdocs/wp-content/plugins/official-facebook-pixel/core/FacebookWordpressOptions.php:70\nStack trace:\n#0 /var/www/vhosts/xxxx/httpdocs/wp-content/plugins/official-facebook-pixel/core/FacebookWordpressSettingsPage.php(275)...

The reason of this error is str_contains is only implemented on PHP 8 : https://www.php.net/manual/en/function.str-contains.php

For the moment we solve the problem with this little fix, in my functions.php :

    if (!function_exists('str_contains')) {
        function str_contains($haystack, $needle) {
            return $needle !== '' && mb_strpos($haystack, $needle) !== false;
        }
    }
fbisaso commented 1 year ago

This will be fixed in the next release.

https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/commit/f318d64e182d8b5a781de0a684dded33ea47a275