Sorry, we don't support your browser.  Install a modern browser

Feedback & Bugfix – “merge_root_selectors()” declared multiple times#219

Hello,

we encountered a critical error while using your plugin in combination with Bricks Builder and Tutor LMS, which we were able to debug and fix.

Here’s a brief summary of what happened – and how we solved it:

Problem:

When loading the Course Builder, the following error was thrown in the debug log:

Fatal error: Cannot redeclare CoreFramework\App\Bricks\merge_root_selectors()

Cause:

The function merge_root_selectors() (or merge_root_selectors_bricks() after renaming) was declared within a method (add_corresponding_css).

Since this method is executed multiple times through various hooks, PHP attempted to register the function each time – which led to a Fatal Error.

Analysis:

The function was multiple times in scope, although technically it may only be loaded once.

The function_exists() check didn’t help because the definition within a method is not reliably prevented.

it exists twice, in the following files:

/wp-content/plugins/core-framework/wp/App/Bricks/Bricks.php

/wp-content/plugins/core-framework/wp/App/Oxygen/Functions.php

Solution:

We moved the function out of the method and placed it globally (outside the class, but within the file):

if ( ! function_exists( ‘merge_root_selectors’ ) ) function merge_root_selectors( $cssString ) // Function content
}
}

This ensures that it’s only declared once, regardless of multiple instances or hooks.

Recommendation:

Please revise the function call in a future version of the plugin and ensure that no function is declared within methods or multiple loaded contexts.

If you’d like, I’m happy to send you the patch or revised part directly.
Thanks for your plugin – otherwise runs great!

Best regards,
Chris

21 days ago