[Smush Pro] Smush Pro send in crash the new Divi 4.0 Theme Builder

Smush Pro send in crash the new Divi 4.0 Theme Builder in all my sites.
I have deactivated all plugins, and activate them one by one, and the issue is generated by Smush Pro.

  • Aditya
    • Staff

    Hi GiaNet Media

    Hope you are doing great. :slight_smile:

    I just downloaded the latest version of Divi Version: 4.0.2 and tested with the latest version of Smush Pro Version 3.3.0 which didn’t break my site. Can you try to re-install both Divi and Smush Pro by downloading the fresh files of both and have a recheck?

    Also, take a backup of the complete site before re-installing the plugins/themes so as to be prepared just in case there are some changes made because of it.

    Please let us know how it goes. :slight_smile:

    Best,
    Aditya Shah

  • Patrick Freitas
    • Staff

    Hi GiaNet Media

    Sorry to hear you had this problem.

    We found an issue on the Divi compatibility module, it seems was already reported to Divi on wp.org and we are working to further investigate the problem.

    Can you try this fixe suggest by our developer?

    For now, this can be resolved by going to wp-content/themes/Divi/includes/builder/plugin-compat/wp-smushit.php, downlaod the wp-smushit.php file as a backup then edit the file and on line 50 replacing:

    remove_action( 'wp_enqueue_scripts', array( WP_Smush::get_instance()->core()->mod->lazy, 'enqueue_assets' ) );

    with:

    remove_action( 'wp_enqueue_scripts', array( Smush\WP_Smush::get_instance()->core()->mod->lazy, 'enqueue_assets' ) );

    Let us know the result you got.
    Best Regards
    Patrick Freitas

  • Patrick Freitas
    • Staff

    Hi GiaNet Media

    Hope you are doing well.

    Yes, the issue is on Lazy Load module, can you verify if the suggested fix was implemented?

    https://premium.wpmudev.org/forums/topic/smush-pro-smush-pro-send-in-crash-the-new-divi-4-0-theme-builder/#post-3689482

    Can you replicate the same problem on different WordPress multisite?

    If so, please, report this to Divi support about the multisite problem too.

    Let us know if you need any further help with this.
    Best Regards
    Patrick Freitas

    • GiaNet Media
      • Site Builder, Child of Zeus

      Hi Patrick,
      with the new update to ver. 4.0.3 the code into the file wp-content/themes/Divi/includes/builder/plugin-compat/wp-smushit.php is changed and I cannot edit the line you have showed me because I cannot find it…
      See the wp-smushit.php code of the 4.0.3 version

      <?php
      
      if ( ! defined( 'ABSPATH' ) ) {
      	exit; // Exit if accessed directly
      }
      
      /**
       * Plugin compatibility for Smush
       *
       * @since 3.17.1
       *
       * @link https://wordpress.org/plugins/wp-smushit/
       */
      class ET_Builder_Plugin_Compat_Smush extends ET_Builder_Plugin_Compat_Base {
      	/**
      	 * Constructor
      	 */
      	public function __construct() {
      		$this->plugin_id = 'wp-smushit/wp-smush.php';
      		$this->init_hooks();
      	}
      
      	/**
      	 * Hook methods to WordPress
      	 *
      	 * Latest plugin version: 1601
      	 *
      	 * @return void
      	 */
      	public function init_hooks() {
      		// Bail if there's no version found
      		if ( ! $this->get_plugin_version() ) {
      			return;
      		}
      
      		$enabled = array(
      			// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
      			'vb'  => et_()->array_get( $_GET, 'et_fb' ),
      			'bfb' => et_()->array_get( $_GET, 'et_bfb' ),
      			'tb'  => et_()->array_get( $_GET, 'et_tb' ),
      			// phpcs:enable
      		);
      
      		add_filter( 'wp_smush_should_skip_parse', array( $this, 'maybe_skip_parse' ), 11 );
      
      		if ( $enabled['vb'] || $enabled['bfb'] || $enabled['tb'] ) {
      			// Plugin's <code>enqueue</code> function will cause a PHP notice unless
      			// early exit is forced using the following custom filter
      			add_filter( 'wp_smush_enqueue', '__return_false' );
      
      			$class = $this->get_smush_class();
      
      			if ( ! empty( $class ) ) {
      				$lazyload = call_user_func( array( $class, 'get_instance' ) )->core()->mod->lazy;
      
      				remove_action( 'wp_enqueue_scripts', array( $lazyload, 'enqueue_assets' ) );
      			}
      		}
      	}
      
      	/**
      	 * Disable Smush page parsing in VB.
      	 *
      	 * @param boolean $skip
      	 *
      	 * @return boolean
      	 */
      	public function maybe_skip_parse( $skip ) {
      		if ( et_core_is_fb_enabled() ) {
      			return true;
      		}
      
      		return $skip;
      	}
      
      	/**
      	 * Get the base Smush class name.
      	 *
      	 * @since ??
      	 *
      	 * @return string
      	 */
      	public function get_smush_class() {
      		$classes = array(
      			'WP_Smush',
      			// @since 3.3.0
      			'Smush\\WP_Smush',
      		);
      
      		foreach ( $classes as $test ) {
      			if ( class_exists( $test ) ) {
      				return $test;
      			}
      		}
      
      		return '';
      	}
      }
      
      new ET_Builder_Plugin_Compat_Smush();
      
  • Patrick Freitas
    • Staff

    Hi GiaNet Media

    Thank you for the code.

    I was able to replicate on my multisite this problem, and I can see if we disable the Lazy Load then edit a normal page the console browser still return a Lazy Load error for Divi function.

    I forwarded the multisite issue to Smush developer and check if we can find a temporary solution, however, I suggest you report to Divi support about this behaviour after update.

    Best Regards
    Patrick Freitas

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.