| @@ -12,9 +12,9 @@ | ||
| 12 | 12 | * Should we load the integration logic. |
| 13 | 13 | * |
| 14 | 14 | * @return bool Should we load. |
| 15 | 15 | */ |
| 16 | - function should_load() { | |
| 16 | + public function should_load() { | |
| 17 | 17 | return ( |
| 18 | 18 | strcmp( wp_get_theme(), 'Divi' ) === 0 || |
| 19 | 19 | is_plugin_active( 'divi-builder/divi-builder.php' ) |
| 20 | 20 | ); |
| @@ -24,11 +24,11 @@ | ||
| 24 | 24 | * Register integration details. |
| 25 | 25 | */ |
| 26 | 26 | public function register() { |
| 27 | 27 | |
| 28 | - add_action( 'et_core_static_file_created', [$this, 'optimize_divi_static_files'] ); | |
| 28 | + add_action( 'et_core_static_file_created', [ $this, 'optimize_divi_static_files' ] ); | |
| 29 | 29 | |
| 30 | - add_action( 'optml_settings_updated', [$this, 'clear_divi_static_files'] ); | |
| 30 | + add_action( 'optml_settings_updated', [ $this, 'clear_divi_static_files' ] ); | |
| 31 | 31 | |
| 32 | 32 | add_filter( |
| 33 | 33 | 'optml_lazyload_bg_selectors', |
| 34 | 34 | function ( $all_watchers ) { |
| @@ -46,19 +46,19 @@ | ||
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Replace image urls upon divi's static css files creation |
| 49 | 49 | * |
| 50 | - * @param ET_Core_PageResource $resource ET_Core_PageResource object. | |
| 50 | + * @param ET_Core_PageResource $page_resource ET_Core_PageResource object. | |
| 51 | 51 | * @return void |
| 52 | 52 | */ |
| 53 | - public function optimize_divi_static_files( $resource ) { | |
| 53 | + public function optimize_divi_static_files( $page_resource ) { | |
| 54 | 54 | if ( class_exists( 'ET_Core_PageResource' ) && null !== ET_Core_PageResource::$wpfs ) { |
| 55 | - if ( isset( $resource->path ) ) { | |
| 56 | - $data = $resource->get_data( 'file' ); | |
| 55 | + if ( isset( $page_resource->path ) ) { | |
| 56 | + $data = $page_resource->get_data( 'file' ); | |
| 57 | 57 | |
| 58 | 58 | if ( ! empty( $data ) ) { |
| 59 | - $data = Optml_Main::instance()->manager->replace_content( $data ); | |
| 60 | - ET_Core_PageResource::$wpfs->put_contents( $resource->path, $data, 0644 ); | |
| 59 | + $data = Optml_Main::instance()->manager->replace_content( $data, true ); | |
| 60 | + ET_Core_PageResource::$wpfs->put_contents( $page_resource->path, $data, 0644 ); | |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |