Critical error - Bricks on Plesk WP Toolkit

Hello!

I have all my WP sites hosted on Plesk panel with installed extension Wordpress Toolkit. This extension use many hosting companies and it works on cPanel as well. It is very usefull tool for manage WP sites security, plugins, updates, clone/copy sites, backup etc.
After I installed Bricks on brand new testing site, errors appears in WP Toolkit and It looks like a problem with Bricks (theme) class loading. Wordpress Toolkit uses the wp-cli utility to interact with WordPress site features (tune settings, receive info about site / plugins / themes, etc) and it looks like it doesn’t work here.
Is there any chance to fix it in near future? Here is error log I received from Toolkit (example staging.somesite.com):

Website “/staging.somesite.com” (https://staging.somesite.com): Failed to reset cache for the instance #153: PHP Fatal error: Uncaught Error: Class “Bricks\Elements” not found in /var/www/vhosts/somesite.com/staging.somesite.com/wp-content/themes/functions.php:21
Stack trace:
#0 /var/www/vhosts/somesite.com/staging.somesite.com/wp-includes/class-wp-hook.php(307): WP_CLI\Runner->{closure}()
#1 /var/www/vhosts/somesite.com/staging.somesite.com/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#2 /var/www/vhosts/somesite.com/staging.somesite.com/wp-includes/plugin.php(476): WP_Hook->do_action()
#3 /var/www/vhosts/somesite.com/staging.somesite.com/wp-settings.php(598): do_action()
#4 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1291): require(’…’)
#5 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1212): WP_CLI\Runner->load_wordpress()
#6 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#7 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/bootstrap.php(77): WP_CLI\Bootstrap\LaunchRunner->process()
#8 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#9 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/boot-fs.php(17): require_once(’…’)
#10 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wpt-wp-cli.php(31): require_once(’…’)
#11 {main}
thrown in /var/www/vhosts/somesite.com/staging.somesite.com/wp-content/themes/functions.php on line 21
Fatal error: Uncaught Error: Class “Bricks\Elements” not found in /var/www/vhosts/somesite.com/staging.somesite.com/wp-content/themes/functions.php:21
Stack trace:
#0 /var/www/vhosts/somesite.com/staging.somesite.com/wp-includes/class-wp-hook.php(307): WP_CLI\Runner->{closure}()
#1 /var/www/vhosts/somesite.com/staging.somesite.com/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#2 /var/www/vhosts/somesite.com/staging.somesite.com/wp-includes/plugin.php(476): WP_Hook->do_action()
#3 /var/www/vhosts/somesite.com/staging.somesite.com/wp-settings.php(598): do_action()
#4 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1291): require(’…’)
#5 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1212): WP_CLI\Runner->load_wordpress()
#6 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#7 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/bootstrap.php(77): WP_CLI\Bootstrap\LaunchRunner->process()
#8 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#9 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/vendor/wp-cli/wp-cli/php/boot-fs.php(17): require_once(’…’)
#10 /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wpt-wp-cli.php(31): require_once(’…’)
#11 {main}
thrown in /var/www/vhosts/somesite.com/staging.somesite.com/wp-content/themes/functions.php on line 21
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.

You might want to look at your PHP version.

I am running Bricks on Plesk with WordPress Toolkit with ZERO issues.

TBH. I don’t think the problem is Bricks.

Thanks for your answer.
Site works normally but with errors on WP Toolkit…
Tried to run on different PHP - 7.4.32, 8.0.24, 8.1.11 on FastCGI (because it is Litespeed server) and same error on WP Toolkit.
Tried to change theme, same thing. Only works when I delete Bricks from site and run site with different theme.

Are you running a Bricks child theme that is trying to register an element? (I’m guessing from the mention of ‘line 21 of the functions.php’ in the error).

If so, Plesk can run into problems unless you check the class exists first. So you can’t just do…

\Bricks\Elements::register_element( $file )

Which comes as default in Bricks’ child theme. You need to check it exists first, eg…

if ( class_exists( "\Bricks\Elements" ) {
  // do stuff..
}

Or if you’re not needing that part of code from the child theme, deleting the ‘Register custom elements’ part should solve also.

1 Like

Thanks, problem solved!

Just checked files in Themes directory and problem was with child theme upload… For some reason, when you make child theme upload from WP themes file upload, it doesn’t create own bricks-child directory and zip file is extracted in themes root folder.

1 Like