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.

3 Likes

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

Where did you drop the code sorry? Iā€™m having this too, using Bricksable which seems to be linked and not sure if the code is in that or the child theme.

Code didnā€™t helpā€¦ as I can remember, problem was with wrong plugin extract (in wrong directory) so you should check that first if you did it manually