From 3951b0d3b01d8c1c6d00b9af8054c23ec1ecaf15 Mon Sep 17 00:00:00 2001 From: abaicus Date: Mon, 7 Aug 2023 14:09:15 +0300 Subject: [PATCH 1/3] fix: trailing commas in function calls triggering fatal error [closes #629] --- inc/admin.php | 2 +- inc/dam.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index 66529342..e26d7567 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -832,7 +832,7 @@ public function add_settings_subpage() { __( 'Settings', 'optimole-wp' ), 'manage_options', 'optimole#settings', - [ $this, 'render_dashboard_page' ], + [ $this, 'render_dashboard_page' ] ); } diff --git a/inc/dam.php b/inc/dam.php index a0613232..d2f8b263 100644 --- a/inc/dam.php +++ b/inc/dam.php @@ -536,7 +536,7 @@ public function add_menu() { __( 'Cloud Library', 'optimole-wp' ), 'manage_options', 'optimole-dam', - [ $this, 'render_dashboard_page' ], + [ $this, 'render_dashboard_page' ] ); } From 45f1c8f960e646e37838dfbbd8e7a57b5cc94e0c Mon Sep 17 00:00:00 2001 From: abaicus Date: Mon, 7 Aug 2023 14:13:45 +0300 Subject: [PATCH 2/3] chore: remove console.log --- assets/src/dashboard/utils/helpers.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/src/dashboard/utils/helpers.js b/assets/src/dashboard/utils/helpers.js index 5aed7458..ea26a15d 100644 --- a/assets/src/dashboard/utils/helpers.js +++ b/assets/src/dashboard/utils/helpers.js @@ -65,8 +65,6 @@ const highlightSidebarLink = () => { }; const toggleDashboardSidebarSubmenu = ( show = true ) => { - console.log( '%c toggleDashboardSidebarSubmenu', 'color: #fff; background: #f00; font-size: 16px; padding: 4px 8px; border-radius: 4px;' ); - const topLevel = document.querySelector( 'li#toplevel_page_optimole' ); let existingList = document.querySelector( 'li#toplevel_page_optimole .wp-submenu' ); From ca02dd2ea6b5b906b16e4f7d8e62f2e45a856dc2 Mon Sep 17 00:00:00 2001 From: abaicus Date: Mon, 7 Aug 2023 15:44:38 +0300 Subject: [PATCH 3/3] fix: typo in code causing warning when image with height but no width is inserted [closes #631] --- inc/tag_replacer.php | 2 +- tests/test-replacer.php | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/inc/tag_replacer.php b/inc/tag_replacer.php index e48942f7..bd974717 100644 --- a/inc/tag_replacer.php +++ b/inc/tag_replacer.php @@ -287,7 +287,7 @@ private function parse_dimensions_from_tag( $tag, $image_sizes, $args = [] ) { } } if ( preg_match( '#height=["|\']?([\d%]+)["|\']?#i', $tag, $height_string ) ) { - if ( ctype_digit( $width_string[1] ) === true ) { + if ( ctype_digit( $height_string[1] ) === true ) { $args['height'] = $height_string[1]; } } diff --git a/tests/test-replacer.php b/tests/test-replacer.php index 8f854bf1..5045085a 100644 --- a/tests/test-replacer.php +++ b/tests/test-replacer.php @@ -775,4 +775,27 @@ public function test_strip_metadata() { $this->assertEquals( 27, substr_count( $replaced_content, '/sm:0/' ) ); } + public function test_tag_replacer_process_image_tags_missing_width_height() { + $test_data = [ + [ + 'content' => '
', + 'expected' => '/w:auto/h:40/', + ], + [ + 'content' => '
', + 'expected' => '/w:50/h:auto/', + ], + [ + 'content' => '
', + 'expected' => '/w:70/h:60/', + ] + ]; + + foreach ( $test_data as $data ) { + $images = Optml_Manager::parse_images_from_html( $data['content'] ); + $replaced_content = Optml_Tag_Replacer::instance()->process_image_tags( $data['content'], $images ); + + $this->assertStringContainsString( $data['expected'], $replaced_content ); + } + } } \ No newline at end of file