Skip to content

A Divi Fix (Hopefully, Short-Term)

I ran into an odd problem the other day here at The Job. On our multisite installation, blogs that were running the Divi theme would intermittently throw 500 server errors. Reloading the page (sometimes 3 or 4 times) would eventually bring things back, but still.

Looking at the server’s PHP error logs I found entries like this:


[10-Jan-2019 13:59:32 UTC] PHP Fatal error:
Call to undefined function et_core_is_gutenberg_active()
in /opt/rh/httpd24/root/var/www/html/wp-content/themes/Divi/includes/builder/feature \
/BlockEditorIntegration.php
on line 572

And looking a little deeper I understood that this can’t be correct. The function actually did exist, in Divi/core/functions.php. So why was it undefined?

The good folks at PressJitsu had come across the same problem, and fortunately (for me) they did the detective work. They suggested

An upstream update to bloom core will be imminent. An update to the ET core loader will probably also happen. Meanwhile copying the ET core from Divi/core to bloom/core will most certainly solve the issue.

But I was a little hesitant to copy over the entire directory without looking a little more deeply at the code. I found it was sufficient to copy-and-paste two functions from Divi/core/functions.php into monarch/core/functions.php. I added this to the very end of the file:


/* Cloned in from Divi/core/functions.php to try and
eliminate the function not found error */
/**
* Is Gutenberg active and enabled for the current post
* WP 5.0 WARNING - don't use before global post has been set
*
* @since 3.19.2 Renamed from {@see et_is_gutenberg_enabled()} and moved to core.
* @since 3.18
*
* @return bool True - if the plugin is active and enabled.
*/
if ( ! function_exists( 'et_core_is_gutenberg_enabled' ) ):
function et_core_is_gutenberg_enabled() {
if ( function_exists( 'is_gutenberg_page' ) ) {
return et_core_is_gutenberg_active()
&& is_gutenberg_page()
&& has_filter( 'replace_editor', 'gutenberg_init' );
}

return et_core_is_gutenberg_active()
&& function_exists( 'use_block_editor_for_post' )
&& use_block_editor_for_post( null );
}
endif;

/**
* Is Gutenberg active?
*
* @since 3.19.2 Renamed from {@see et_is_gutenberg_active()} and moved to core.
* @since 3.18
*
* @return bool True - if the plugin is active
*/
if ( ! function_exists( 'et_core_is_gutenberg_active' ) ):
function et_core_is_gutenberg_active() {
global $wp_version;

static $has_wp5_plus = null;

if ( is_null( $has_wp5_plus ) ) {
$has_wp5_plus = version_compare( $wp_version, '5.0-alpha1', '>=' );
}

return $has_wp5_plus || function_exists( 'is_gutenberg_page' );
}
endif;

And the error messages went away.

Another solution from elsewhere on the web suggested commenting out the last few lines of Divi/includes/builder/feature/BlockEditorIntegration.php, but that’s neither necessary nor sufficient.

Interestingly

Am I being paranoid?

There were a number of support threads on the Elegant Themes site* [subscriber access only] from people facing this (or a similar problem). I posted my solution, and when I went to the thread this morning to see if there was any follow-up the entire thread had been removed. Along with any other threads referencing the problem of the missing function.

I re-upped it today, so we’ll see what happens.


* See what I did there?

8 Comments

  1. Thanks for posting this. ET seems to think it is an issue with my site and a plugin but I don’t see that. I also use multi-site.

    Thanks again!

  2. Tom Tom

    You’re welcome. Every day I’m surprised that ET hasn’t issued this simple patch…

  3. Hello, thanks a lot for this solution. You saved my a** (life)

  4. Thanks. This saved me.

  5. This helped with Chrome and FF but both IE and Edge are still showing:

    Fatal error: Call to undefined function et_core_is_gutenberg_active() in /home/content/p3pnexwpnas12_data03/57/41868757/html/wp-content/themes/Divi/includes/builder/feature/BlockEditorIntegration.php on line 570

  6. Tom Tom

    Hm. Are you running any other ET plugins? I think the original solution I read about had to do with their Bloom plugin.

  7. Kelvin Kelvin

    Hello

    Thank you for uploading the post. This article helped a lot.

  8. Worked for me (in Bloom)! Thanks a bunch.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share This