| 1 |
<?php |
| 2 |
/** |
| 3 |
* Theme Name: Divi |
| 4 |
* Theme URI: https://www.elegantthemes.com/gallery/divi/ |
| 5 |
* |
| 6 |
* Compatibility Description: Ensures compatibility with Divi themes Builder Export addon. |
| 7 |
* https://github.com/wpCloud/wp-stateless/issues/224 |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace wpCloud\StatelessMedia { |
| 12 |
|
| 13 |
if( !class_exists( 'wpCloud\StatelessMedia\Divi' ) ) { |
| 14 |
|
| 15 |
class Divi extends ICompatibility { |
| 16 |
protected $id = 'divi'; |
| 17 |
protected $title = 'Divi'; |
| 18 |
protected $constant = 'WP_STATELESS_COMPATIBILITY_DIVI'; |
| 19 |
protected $description = 'Ensures compatibility with Divi theme.'; |
| 20 |
protected $theme_name = 'Divi'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Cache Busting call stack conditions to disable. |
| 24 |
* Fixing the issue with multiple cache files being created on each page load. |
| 25 |
* @see https://github.com/wpCloud/wp-stateless/issues/430 |
| 26 |
* @var array |
| 27 |
*/ |
| 28 |
private $cache_busting_disable_conditions = array( |
| 29 |
array( 'stack_level' => 7, 'function' => '__construct', 'class' => 'ET_Core_PageResource' ), |
| 30 |
array( 'stack_level' => 7, 'function' => 'get_cache_filename', 'class' => 'ET_Builder_Element' ) |
| 31 |
); |
| 32 |
|
| 33 |
/** |
| 34 |
* Initialize compatibility module |
| 35 |
* @param $sm |
| 36 |
*/ |
| 37 |
public function module_init( $sm ) { |
| 38 |
// exclude randomize_filename from export |
| 39 |
if( !empty( $_GET[ 'et_core_portability' ] ) || wp_doing_ajax() && ( !empty( $_POST[ 'action' ] ) |
| 40 |
&& $_POST[ 'action' ] == 'et_core_portability_export' ) || ( !empty( $_POST[ 'et_core_portability_export' ] ) |
| 41 |
&& $_POST[ 'et_core_portability_export' ] == 'et_core_portability_export' ) ) { |
| 42 |
remove_filter( 'sanitize_file_name', array( "wpCloud\StatelessMedia\Utility", 'randomize_filename' ), 10 ); |
| 43 |
} |
| 44 |
|
| 45 |
// maybe skip cache busting |
| 46 |
add_filter( 'stateless_skip_cache_busting', array( $this, 'maybe_skip_cache_busting' ), 10, 2 ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Maybe skip cache busting |
| 51 |
* @param $null |
| 52 |
* @param $filename |
| 53 |
* @return bool | string |
| 54 |
*/ |
| 55 |
public function maybe_skip_cache_busting( $null, $filename ) { |
| 56 |
$callstack = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 8 ); |
| 57 |
if( Utility::isCallStackMatches( $callstack, $this->cache_busting_disable_conditions ) ) return $filename; |
| 58 |
return $null; |
| 59 |
} |
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
} |
| 66 |
|