Skip to content

Commit

Permalink
fix: improve compatibility with Divi builder
Browse files Browse the repository at this point in the history
  • Loading branch information
preda-bogdan authored and selul committed Dec 17, 2019
1 parent bf9f058 commit 7d1c469
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/compatibilities/divi_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function ( $all_watchers ) {
$all_watchers[] = '.et_pb_slides > .et_pb_slide';
$all_watchers[] = '.et_parallax_bg';
$all_watchers[] = '.et_pb_video_overlay';
$all_watchers[] = '.et_pb_module';
$all_watchers[] = '.et_pb_module:not(.et_pb_blog_grid_wrapper)';
$all_watchers[] = '.et_pb_row';
$all_watchers[] = '.et_pb_with_background';
return $all_watchers;
Expand Down
60 changes: 60 additions & 0 deletions inc/conflicts/divi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* Class Optml_Divi
*
* An example of a conflict.
*/
class Optml_Divi extends Optml_abstract_conflict {

/**
* Optml_Divi constructor.
*/
public function __construct() {
$this->priority = 2;
$this->severity = self::SEVERITY_HIGH;
parent::__construct();
}

/**
* Set the message property
*
* @since 2.2.6
* @access public
*/
public function define_message() {
$this->message = sprintf( __( 'It seems your are using %1$sDivi%2$s right now. %3$s In order for Optimole to replace the images in your Divi pages, you will need to go to %4$sDivi -> Theme Options -> Builder -> Advanced -> Static CSS File Generations%5$s and click on Clear for the images to be processed. ', 'optimole-wp' ), '<b>', '</b>', '<br/>', '<a target="_blank" href="' . admin_url( 'admin.php?page=et_divi_options' ) . '">', '</a>' );
}


/**
* Determine if conflict is applicable.
*
* @return bool
* @since 2.2.6
* @access public
*/
public function is_conflict_valid() {
$show_message = false;
$theme = wp_get_theme( 'Divi' );
if ( $theme->exists() && strcmp( $theme->get( 'Name' ), 'Divi' ) === 0 ) {
$show_message = true;
}

if ( is_plugin_active( 'divi-builder/divi-builder.php' ) ) {
$show_message = true;
}
if ( get_template_directory() !== get_stylesheet_directory() && strcmp( wp_get_theme( get_template() )->get( 'Author' ), 'Divi' ) === 0 ) {
$show_message = true;
}

if ( ! function_exists( 'et_get_option' ) ) {
return false;
}
if ( 'off' === et_get_option( 'et_pb_static_css_file', 'on' ) ) {
return false;
}

return $show_message;
}
}
1 change: 1 addition & 0 deletions inc/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static function register_conflicts( $conflicts_to_register = array() ) {
'Optml_Jetpack_Photon',
'Optml_Jetpack_Lazyload',
'Optml_Wprocket',
'Optml_Divi',
)
);

Expand Down

0 comments on commit 7d1c469

Please sign in to comment.