Skip Navigation

[Resolved] Issues with the Toolset-provided custom code snippet when activating child theme

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 3 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2006253

Hi Support

On activating a child theme (we are using Avada), it is having issues with the Toolset-provided custom code snippet fix-bootstrap-conflicts-with-avada.

The code was introduced to prevent conflicts with Avada Builder elements due to Boostrap conflicts with Toolset plugins, (Avada FAQs element, Avada Pricing table while using Safari, Avada Content Tabs element).

When I activate the Avada child theme, I'm getting error:

Fatal error: Cannot redeclare theme_enqueue_styles() (previously declared in .../wp-content/themes/Avada-Child-Theme/functions.php:4) in .../wp-content/toolset-customizations/fix-bootstrap-conflicts-with-avada.php on line 8

Once the error happens I get blocked from WP Admin and have to rename the child theme via FTP to recover.

Kind regards
Simon

#2006355

Hi Simon,

Thank you for contacting us and I'd be happy to assist.

As the errors suggest, the function of the same name cannot be declared again.

In your code snippet named "fix-bootstrap-conflicts-with-avada" (Toolset custom code section), a function with name "theme_enqueue_styles" is already defined.

But, the function with the same name is also added in the "functions.php" file of the Avada Child theme. This is why, when that child theme is activated, it results in that error.

You can merge the code of the two functions in one place, for example, remove the code snippet "fix-bootstrap-conflicts-with-avada" and update the function in the "functions.php" file to:


function theme_enqueue_styles() {
	wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array('avada-stylesheet') );
	wp_enqueue_style('toolset_bootstrap_4-css', get_site_url().'/wp-content/plugins/types/vendor/toolset/toolset-common/res/lib/bootstrap4/css/bootstrap.min.css?ver=4.3.1');
}

add_action('wp_enqueue_scripts', 'theme_enqueue_styles');

Alternatively, if you'd prefer to have two independent functions, you can rename the function in the code snippet "fix-bootstrap-conflicts-with-avada" to something other than "theme_enqueue_styles":


function fix_bootstrap_conflicts_enqueue_styles() {
	wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array('avada-stylesheet') );
	wp_enqueue_style('toolset_bootstrap_4-css', get_site_url().'/wp-content/plugins/types/vendor/toolset/toolset-common/res/lib/bootstrap4/css/bootstrap.min.css?ver=4.3.1');
}

add_action('wp_enqueue_scripts', 'fix_bootstrap_conflicts_enqueue_styles');

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar