PHP 8.1.27 – Fatal Error

Tried several 8.x versions and Code-Snippet will always break it. Is there any fix for it?

Deactivating Code-Snippet will make the site work.

thrown in /var/www/vhosts/hostingxyz/homepage/wp/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()’d code on line 8
[08-Feb-2024 18:23:34 UTC] PHP Fatal error: Uncaught Error: Undefined constant “condition” in /var/www/vhosts/hostingxyz/homepage/wp/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()’d code:8
Stack trace: 0 /var/www/vhosts/hostingxyz/homepage/wp/wp-content/plugins/code-snippets/php/snippet-ops.php(582): eval() 1 /var/www/vhosts/hostingxyz/homepage/wp/wp-content/plugins/code-snippets/php/snippet-ops.php(663): Code_Snippets\execute_snippet() 2 /var/www/vhosts/hostingxyz/homepage/wp/wp-includes/class-wp-hook.php(324): Code_Snippets\execute_active_snippets() 3 /var/www/vhosts/hostingxyz/homepage/wp/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 4 /var/www/vhosts/hostingxyz/homepage/wp/wp-includes/plugin.php(517): WP_Hook->do_action() 5 /var/www/vhosts/hostingxyz/homepage/wp/wp-settings.php(506): do_action() 6 /var/www/vhosts/hostingxyz/homepage/wp/wp-config.php(104): require_once(‘/var/www/vhosts…’) 7 /var/www/vhosts/hostingxyz/homepage/wp/wp-load.php(50): require_once(‘/var/www/vhosts…’) 8 /var/www/vhosts/hostingxyz/homepage/wp/wp-admin/admin-ajax.php(22): require_once(‘/var/www/vhosts…’) 9 {main}

thrown in /var/www/vhosts/hostingxyz/homepage/wp/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()’d code on line 8

O.k. I was able to narrow it down. Creating a PHP Snippet do deactivate Gutenberg blocks will cause the fatal error:

<?php //Remove Gutenberg Block Library CSS from loading on the frontend function smartwp_remove_wp_block_library_css(){ wp_dequeue_style( 'wp-block-library' ); wp_dequeue_style( 'wp-block-library-theme' ); wp_dequeue_style( 'wc-blocks-style' ); // Remove WooCommerce block CSS } add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 );

or similar one, will not work, too.

Any idea?

//Remove Gutenberg Block Library CSS from loading on the frontend
function smartwp_remove_wp_block_library_css(){
wp_dequeue_style( ‘wp-block-library’ );
wp_dequeue_style( ‘wp-block-library-theme’ );
}

add_action( ‘wp_enqueue_scripts’, ‘smartwp_remove_wp_block_library_css’ );if (condition) {

}

It’s not limited to this shortcode there are more than this code which throw errors …

thrown in /var/www/vhosts/hostingxyz/hompage/wp/wp-content/plugins/code-snippets/php/front-end/class-frontend.php(248) : eval()’d code on line 3

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer