Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Forked from rafaehlers/gv-divi-widgets.php
Last active March 8, 2023 17:50
Show Gist options
  • Save zackkatz/e42de70d0869e0c7c148694ea59410b3 to your computer and use it in GitHub Desktop.
Save zackkatz/e42de70d0869e0c7c148694ea59410b3 to your computer and use it in GitHub Desktop.
Prevent a Divi-powered theme from disabling GravityView's widgets when the View is embedded in a page
<?php
/**
* Prevent Divi from using the "Grab the first post image" setting.
*
* It uses et_first_image() which uses apply_filters( 'the_content' ) which causes
* a conflict GravityView, which uses 'the_content' filter.
*
* @param bool $setting Is the setting enabled and the request is not Buddypress?
*
* @return bool If displaying a GravityView View, false. Otherwise, the original value.
*/
add_filter( 'et_grab_image_setting', function( $setting ) {
if ( function_exists( 'gravityview' ) && gravityview()->request->is_view() ) {
return false;
}
return $setting;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment