FluentCRM has a compatibility issue with the Avada theme
It seems that there are not many FluentCRM users who are also using the Avada theme, because I have been experiencing a compatibility issue between FluentCRM and Avada since I started using FluentCRM at the beginning of this year.
The issue occurs when creating email templates: an internal error appears, causing the email template design interface to fail to load. I had to write a custom MU plugin myself to work around this problem.
However, it seems that there are very few FluentCRM users with the same setup as mine (using the Avada theme), because even after several plugin updates, this issue has still not been fixed.
I hope the development team can test this compatibility issue. If possible, it would be best to fix it directly within the FluentCRM plugin so that users do not need to rely on custom workarounds.
Although I have only been using the free version of FluentCRM for the past few months, I suspect that one of the major reasons why there are so few Avada users using FluentCRM is that, once the free version of the plugin is installed, opening the email template designer can trigger a fatal WordPress error.
WordPress will then send an email notification to the administrator stating that the site has encountered a fatal error. For beginner users who are using Avada, this kind of error notification can be very alarming. Many of these users may immediately disable FluentCRM instead of investigating the issue and manually fixing it, as I did.
Users who rely on visual page builders are often not developers. They will simply assume that the product does not work properly or that it has serious issues. They usually do not care whether the problem is caused by Avada or FluentCRM β they only see that FluentCRM has caused a fatal error on their website.
I do not know whether this issue will eventually force FluentCRM and Avada users to choose between the two products, but I believe you should not give up on this group of Avada users.
I have not provided error logs or screenshots as evidence, but I believe this issue should be very easy to reproduce if your team is willing to test it.
Would you please share more details about the mu-plugin fix you have done so we can take a look and fix in the core.
<?php
/**
- Plugin Name: Chenyβs FluentCRM Avada Compatibility
- Description: Prevents Avada dynamic CSS generation from breaking the FluentCRM block email editor.
- Version: 1.6.0
- Author: Cheny
*/
defined( 'ABSPATH' ) || exit;
/**
- Detect the isolated FluentCRM block editor iframe request.
- FluentCRM renders this editor from an admin request with the
- fluent_crm_block_editor parameter and then fires wp_enqueue_scripts inside
- its own document head. Avada treats that as a front-end render and generates
- dynamic CSS, which can fatal when page-option context is not a real Avada
- page.
*/
function Cheny_is_fluentcrm_block_editor_request() {
return isset( $_REQUEST['fluent_crm_block_editor'] );
}
/**
-
Remove only Avada's dynamic CSS file generation from the FluentCRM editor.
-
The editor does not need Avada front-end dynamic CSS. Leaving the rest of
-
wp_enqueue_scripts alone keeps normal block/editor dependencies available.
*/
function Cheny_fluentcrm_remove_avada_dynamic_css() {
global $wp_filter;if ( ! Cheny_is_fluentcrm_block_editor_request() || empty( $wp_filter['wp_enqueue_scripts'] ) ) {
return;
}Cheny_fluentcrm_remove_avada_dynamic_css_filters( [] );
$hook = $wp_filter['wp_enqueue_scripts'];
if ( ! is_object( $hook ) || empty( $hook->callbacks ) ) {
return;
}foreach ( $hook->callbacks as $priority => $callbacks ) {
foreach ( $callbacks as $callback ) {
if ( empty( $callback['function'] ) || ! is_array( $callback['function'] ) ) {
continue;
}$object = $callback['function'][0]; $method = $callback['function'][1]; if ( is_object( $object ) && 'Fusion_Dynamic_CSS_File' === get_class( $object ) && 'enqueue_dynamic_css' === $method ) { remove_action( 'wp_enqueue_scripts', [ $object, $method ], $priority ); } }}
}
/**
-
Stop Avada from compiling theme/page option dynamic CSS in this editor.
-
Avada computes a dynamic CSS filename before enqueueing it. That computation
-
applies fusion_dynamic_css_array and hits the same typography/color bug, so
-
removing only the enqueue callback is not enough.
*/
function Cheny_fluentcrm_remove_avada_dynamic_css_filters( $css ) {
global $wp_filter;if ( ! Cheny_is_fluentcrm_block_editor_request() || empty( $wp_filter['fusion_dynamic_css_array'] ) ) {
return $css;
}$hook = $wp_filter['fusion_dynamic_css_array'];
if ( ! is_object( $hook ) || empty( $hook->callbacks ) ) {
return $css;
}foreach ( $hook->callbacks as $priority => $callbacks ) {
foreach ( $callbacks as $callback ) {
if ( empty( $callback['function'] ) || ! is_array( $callback['function'] ) ) {
continue;
}$object = $callback['function'][0]; $method = $callback['function'][1]; if ( is_object( $object ) && 'Fusion_Dynamic_CSS_From_Options' === get_class( $object ) && in_array( $method, [ 'dynamic_css_array_filter_to', 'dynamic_css_array_filter_po' ], true ) ) { remove_filter( 'fusion_dynamic_css_array', [ $object, $method ], $priority ); } }}
return $css;
}
/**
-
Defensive fallback for Avada typography color values.
-
If Avada still asks for a typography option in this special context, make
-
sure the sanitize_color callback receives the color string, not the complete
-
typography array.
-
@param mixed $value Option value.
-
@return mixed
*/
function Cheny_fluentcrm_normalize_avada_typography_color( $value ) {
if ( Cheny_is_fluentcrm_block_editor_request() && is_array( $value ) && isset( $value['color'] ) ) {
return $value['color'];
}return $value;
}
/**
-
Fix Avada bracket-style option subset lookups in the FluentCRM editor.
-
In this request shape, fusion_get_option( 'body_typography[color]' ) can
-
return the entire body_typography array. Avada later passes that value to
-
sanitize_color(), causing a PHP 8 TypeError.
-
@param mixed $value Resolved option value.
-
@param string $option_name Requested option name.
-
@return mixed
*/
function Cheny_fluentcrm_fix_avada_subset_option( $value, $option_name ) {
if ( ! Cheny_is_fluentcrm_block_editor_request() || ! is_array( $value ) || ! is_string( $option_name ) ) {
return $value;
}if ( false === strpos( $option_name, '[' ) ) {
return $value;
}$parts = explode( '[', str_replace( ']', '', $option_name ) );
$subset = isset( $parts[1] ) ? $parts[1] : '';if ( '' !== $subset && array_key_exists( $subset, $value ) ) {
return $value[ $subset ];
}return $value;
}
if ( Cheny_is_fluentcrm_block_editor_request() ) {
add_action( 'wp_enqueue_scripts', 'Cheny_fluentcrm_remove_avada_dynamic_css', PHP_INT_MIN );
add_filter( 'fusion_dynamic_css_array', 'Cheny_fluentcrm_remove_avada_dynamic_css_filters', PHP_INT_MIN );
add_filter( 'fusion_get_option', 'Cheny_fluentcrm_fix_avada_subset_option', 1, 2 );
foreach ( [ 'body', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'post_title', 'post_titles_extras' ] as $typography ) {
add_filter( 'generate_css_get_' . $typography . '_typography', 'Cheny_fluentcrm_normalize_avada_typography_color', 1 );
}
}
I dont know how to add code block here. i just dealed the issue what i meet in my use, i dont kown if there is any other issue with avada.