Skip to content

Commit 741ab0d

Browse files
authored
release: fixes
- Fix DAM image selection issue in Gallery Block - Fix incorrect optimization status display when account is inactive - Update dependencies. - Fix various compatibilities when viewport lazyload is on.
2 parents 473ca01 + 554a800 commit 741ab0d

File tree

11 files changed

+169
-99
lines changed

11 files changed

+169
-99
lines changed

assets/src/dashboard/parts/connected/OptimizationStatus.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { Icon } from '@wordpress/components';
22
import { closeSmall, check } from '@wordpress/icons';
33

44
const OptimizationStatus = ({ settings }) => {
5-
const lazyloadEnabled = 'enabled' === settings?.lazyload;
6-
const imageHandlingEnabled = 'enabled' === settings?.image_replacer;
5+
const userStatus = optimoleDashboardApp.user_status ? optimoleDashboardApp.user_status : 'inactive';
6+
const lazyloadEnabled = 'enabled' === settings?.lazyload && 'active' === userStatus ;
7+
const imageHandlingEnabled = 'enabled' === settings?.image_replacer && 'active' === userStatus;
78
const statuses = [
89
{
910
active: imageHandlingEnabled,

assets/src/media/modal/messageHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class MessageHandler {
150150
attachment.fetch().then( ( r ) => {
151151
attachmentsQueue.push( r );
152152

153-
if ( idx === result.data.length - 1 ) {
153+
if ( attachmentsQueue.length === result.data.length ) {
154154
this.sendMessage({ status: 'done' });
155155

156156
// Add the attachments to the selection.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"require-dev": {
4242
"squizlabs/php_codesniffer": "^3.3",
4343
"wp-coding-standards/wpcs": "^3.1.0",
44-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
44+
"dealerdirect/phpcodesniffer-composer-installer": "^1.1.2",
4545
"yoast/phpunit-polyfills": "^4.0",
4646
"phpstan/phpstan": "^1.10",
4747
"szepeviktor/phpstan-wordpress": "^1.3",

composer.lock

Lines changed: 108 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/compatibilities/beaver_builder.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ function ( $all_watchers ) {
3232
return $all_watchers;
3333
}
3434
);
35-
add_filter( 'fl_builder_render_css', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 );
36-
add_filter( 'fl_builder_render_js', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 );
35+
add_filter( 'fl_builder_render_css', [ $this, 'replace_static_content' ], PHP_INT_MAX, 1 );
36+
add_filter( 'fl_builder_render_js', [ $this, 'replace_static_content' ], PHP_INT_MAX, 1 );
37+
}
38+
39+
/**
40+
* Replace urls in static content.
41+
*
42+
* @param string $content Content to replace.
43+
*
44+
* @return string Altered content.
45+
*/
46+
public function replace_static_content( $content ) {
47+
return Optml_Main::instance()->manager->replace_content( $content, true );
3748
}
3849
}

inc/compatibilities/divi_builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function optimize_divi_static_files( $page_resource ) {
5656
$data = $page_resource->get_data( 'file' );
5757

5858
if ( ! empty( $data ) ) {
59-
$data = Optml_Main::instance()->manager->replace_content( $data );
59+
$data = Optml_Main::instance()->manager->replace_content( $data, true );
6060
ET_Core_PageResource::$wpfs->put_contents( $page_resource->path, $data, 0644 );
6161
}
6262
}

inc/compatibilities/elementor_builder_late.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function replace_meta( $metadata, $object_id, $meta_key, $single ) {
4848
return $metadata;
4949
}
5050

51-
return Optml_Main::instance()->manager->replace_content( $current_meta );
51+
return Optml_Main::instance()->manager->replace_content( $current_meta, true );
5252
}
5353

5454
// Return original if the check does not pass

inc/compatibilities/facetwp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function api_replacement_filter( $output, $data ) {
3939
$output = json_decode( $output );
4040

4141
if ( isset( $output->template ) ) {
42-
$output->template = Optml_Main::instance()->manager->replace_content( $output->template );
42+
$output->template = Optml_Main::instance()->manager->replace_content( $output->template, true );
4343
}
4444

4545
// Ignore invalid UTF-8 characters in PHP 7.2+
@@ -48,7 +48,7 @@ public function api_replacement_filter( $output, $data ) {
4848
} else {
4949
$output = json_encode( $output, JSON_INVALID_UTF8_IGNORE );
5050
}
51-
$output = Optml_Main::instance()->manager->replace_content( $output );
51+
$output = Optml_Main::instance()->manager->replace_content( $output, true );
5252
return $output;
5353
}
5454
/**
@@ -65,7 +65,7 @@ public function api_replacement_action( $output ) {
6565
if ( ! isset( $output['template'] ) || ! function_exists( 'FWP' ) ) {
6666
return;
6767
}
68-
$output['template'] = Optml_Main::instance()->manager->replace_content( $output['template'] );
68+
$output['template'] = Optml_Main::instance()->manager->replace_content( $output['template'], true );
6969
FWP()->request->output = $output;
7070
}
7171
/**

inc/compatibilities/yith_quick_view.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ public function should_load() {
2323
*/
2424
public function register() {
2525
Optml_Url_Replacer::instance()->init();
26-
add_filter( 'woocommerce_single_product_image_thumbnail_html', [ Optml_Main::instance()->manager, 'replace_content' ] );
26+
add_filter(
27+
'woocommerce_single_product_image_thumbnail_html',
28+
function ( $html ) {
29+
return Optml_Main::instance()->manager->replace_content( $html, true );
30+
}
31+
);
2732
}
2833

2934
/**

inc/main.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public static function instance() {
106106
add_filter( 'optimole_wp_feedback_review_message', [ __CLASS__, 'change_review_message' ] );
107107
add_filter( 'optimole_wp_logger_heading', [ __CLASS__, 'change_review_message' ] );
108108
add_filter( 'optml_register_conflicts', [ __CLASS__, 'register_conflicts' ] );
109+
add_filter( 'optimole_wp_logger_data', [ __CLASS__, 'add_settings' ] );
109110
self::$_instance = new self();
110111
self::$_instance->manager = Optml_Manager::instance();
111112
self::$_instance->rest = new Optml_Rest();
@@ -145,6 +146,20 @@ public static function register_conflicts( $conflicts_to_register = [] ) {
145146
return $conflicts_to_register;
146147
}
147148

149+
/**
150+
* Add settings to the logger data.
151+
*
152+
* @param array $data Logger data.
153+
*
154+
* @return array
155+
*/
156+
public static function add_settings( $data ): array {
157+
$saved_data = ( new Optml_Settings() )->get_raw_settings();
158+
unset( $saved_data['service_data'] );
159+
unset( $saved_data['api_key'] );
160+
161+
return array_merge( $data, $saved_data );
162+
}
148163
/**
149164
* Change review message.
150165
*

0 commit comments

Comments
 (0)