From 652b0ecf52f2be5410ac74b1fa17e898e54f86d7 Mon Sep 17 00:00:00 2001 From: selul Date: Wed, 18 Nov 2026 11:01:10 +0200 Subject: [PATCH 1/2] fix: stop adding a language code to optimole.com links optimole.com has no translated pages, but the plugin passed its links through tsdk_translate_link(), which puts the language code in the path for de, es, fr, it, ja, nl and ro users. Three upgrade links were translated twice and pointed to /de/de/upgrade, which is a 404. The upgrade, contact, home, pricing, terms, privacy and badge links now have no language code. Links to dashboard.optimole.com are unchanged. Co-Authored-By: Claude Fable 5.2 --- inc/admin.php | 21 +-- inc/manager.php | 2 +- tests/test-optimole-links.php | 271 ++++++++++++++++++++++++++++++++++ 3 files changed, 283 insertions(+), 11 deletions(-) create mode 100644 tests/test-optimole-links.php diff --git a/inc/admin.php b/inc/admin.php index 0641d259..0736a225 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -717,7 +717,7 @@ public function add_notice_upgrade() { ?>

- @@ -772,11 +772,12 @@ public function should_show_upgrade() { /** * Build upgrade URL with current user's encoded email. * + * The URL is not localized with tsdk_translate_link() because optimole.com has no translated pages. + * * @return string Upgrade URL. */ public static function get_upgrade_base_link() { - $base_url = 'https://optimole.com/upgrade'; - $base_url = tsdk_translate_link( $base_url ); + $base_url = 'https://optimole.com/upgrade/'; $email = self::get_account_email(); if ( ! empty( $email ) ) { @@ -792,7 +793,7 @@ public static function get_upgrade_base_link() { * @return string Contact URL. */ public static function get_contact_base_link() { - return tsdk_translate_link( 'https://optimole.com/contact' ); + return 'https://optimole.com/contact/'; } /** @@ -1531,11 +1532,11 @@ private function localize_dashboard_app() { 'site_settings' => $site_settings, 'offload_limit' => $this->settings->get( 'offload_limit' ), 'home_url' => home_url(), - 'optimoleHome' => tsdk_translate_link( 'https://optimole.com/' ), + 'optimoleHome' => 'https://optimole.com/', 'optimoleDashHome' => tsdk_translate_link( 'https://dashboard.optimole.com/', 'query' ), 'optimoleDashBilling' => tsdk_translate_link( 'https://dashboard.optimole.com/settings/billing', 'query' ), 'optimoleDashMetrics' => tsdk_translate_link( tsdk_utmify( 'https://dashboard.optimole.com/metrics', 'wp-plugin', 'shortcut' ) ), - 'offload_upgrade_url' => tsdk_translate_link( tsdk_utmify( 'https://optimole.com/pricing/', 'offload' ) ), + 'offload_upgrade_url' => tsdk_utmify( 'https://optimole.com/pricing/', 'offload' ), 'days_since_install' => round( ( time() - get_option( 'optimole_wp_install', 0 ) ) / DAY_IN_SECONDS ), 'is_offload_media_available' => $is_offload_media_available, 'auto_connect' => $auto_connect, @@ -1741,7 +1742,7 @@ public function get_bf_notices( $user_plan ) { '' . $promo_code . '', '' . __( '25% discount', 'optimole-wp' ) . '' ), - 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm', 'sidebarnotice' ) ), + 'cta_link' => esc_url_raw( tsdk_utmify( self::get_upgrade_base_link(), 'bfcm', 'sidebarnotice' ) ), ]; // The banner shares the SDK dismissal, which resets every year. @@ -1914,7 +1915,7 @@ private function get_dashboard_strings() { 'notice_disabled_account' => sprintf( /* translators: 1 anchor tag to pricing, 2 is the ending endin anchor tag, 3 is the bold tag start, 4 ending bold tag, 5 new line tag */ __( '%3$sYour account has been disabled due to exceeding quota.%4$s All images are being redirected to the original unoptimized URL. %5$sPlease %1$supgrade%2$s to re-activate the account.', 'optimole-wp' ), - '', + '', '', '', '', @@ -1923,8 +1924,8 @@ private function get_dashboard_strings() { 'signup_terms' => sprintf( /* translators: 1 is starting anchor tag to terms, 2 is starting anchor tag to privacy link and 3 is ending anchor tag. */ __( 'By signing up, you agree to our %1$sTerms of Service %3$s and %2$sPrivacy Policy %3$s.', 'optimole-wp' ), - '', - '', + '', + '', '' ), 'dashboard_menu_item' => __( 'Dashboard', 'optimole-wp' ), diff --git a/inc/manager.php b/inc/manager.php index b55c2de3..b9110484 100644 --- a/inc/manager.php +++ b/inc/manager.php @@ -247,7 +247,7 @@ public function banner() { $logo = OPTML_URL . 'assets/img/logo.svg'; - $link = tsdk_translate_link( 'https://optimole.com/wordpress/?from=badgeOn' ); + $link = 'https://optimole.com/wordpress/?from=badgeOn'; $css = ''; diff --git a/tests/test-optimole-links.php b/tests/test-optimole-links.php new file mode 100644 index 00000000..0f795cae --- /dev/null +++ b/tests/test-optimole-links.php @@ -0,0 +1,271 @@ +initial_service_data = $settings->get( 'service_data' ); + $this->initial_banner_frontend = $settings->get( 'banner_frontend' ); + + $settings->update( + 'service_data', + [ + 'cdn_key' => 'example', + 'cdn_secret' => 'test', + 'whitelist' => [ 'example.org' ], + 'user_email' => self::ACCOUNT_EMAIL, + 'plan' => 'free', + 'visitors_limit' => 2000, + 'visitors_left' => 100, + ] + ); + } + + /** + * Restore the settings, which outlive the database rollback because they are cached statically. + */ + public function tearDown(): void { + $settings = new Optml_Settings(); + $settings->update( 'service_data', $this->initial_service_data ); + $settings->update_frontend_banner_from_remote( 'enabled' === $this->initial_banner_frontend ); + + remove_all_filters( 'themeisle_sdk_is_black_friday_sale' ); + remove_all_filters( 'themeisle_sdk_current_date' ); + set_current_screen( 'front' ); + + parent::tearDown(); + } + + /** + * Locales for which the SDK adds a language code to a link, with that code. + * + * @return array + */ + public function localized_locales(): array { + return [ + 'de_DE' => [ 'de_DE', 'de' ], + 'de_DE_formal' => [ 'de_DE_formal', 'de' ], + 'es_ES' => [ 'es_ES', 'es' ], + 'fr_FR' => [ 'fr_FR', 'fr' ], + 'it_IT' => [ 'it_IT', 'it' ], + 'ja' => [ 'ja', 'ja' ], + 'nl_NL' => [ 'nl_NL', 'nl' ], + 'nl_NL_formal' => [ 'nl_NL_formal', 'nl' ], + 'ro_RO' => [ 'ro_RO', 'ro' ], + ]; + } + + /** + * Log in an administrator who uses the given locale, and check the SDK really localizes links for them. + * + * @param string $locale User locale. + * @param string $code Language code the SDK uses for that locale. + */ + private function login_admin_with_locale( string $locale = 'de_DE', string $code = 'de' ): void { + wp_set_current_user( + self::factory()->user->create( + [ + 'role' => 'administrator', + 'locale' => $locale, + ] + ) + ); + + $this->assertSame( $locale, get_user_locale() ); + $this->assertSame( "https://example.org/$code/page/", tsdk_translate_link( 'https://example.org/page/' ) ); + } + + /** + * Assert a link is the upgrade page without a language code, carrying the encoded account email. + * + * @param string $link Link to check. + * @param string $message Failure message. + */ + private function assert_upgrade_link( string $link, string $message = '' ): void { + $this->assertStringStartsWith( 'https://optimole.com/upgrade/?email=', $link, $message ); + + parse_str( (string) wp_parse_url( $link, PHP_URL_QUERY ), $query ); + $this->assertSame( self::ACCOUNT_EMAIL, base64_decode( $query['email'] ), $message ); + } + + /** + * Get the optimole.com links of some markup. + * + * @param string $html Markup. + * + * @return string[] + */ + private function get_optimole_links( string $html ): array { + preg_match_all( '~href="(https://optimole\.com/[^"]*)"~', $html, $matches ); + + return array_map( 'html_entity_decode', $matches[1] ); + } + + /** + * The upgrade link is the same for every locale: no language code, and the account email is kept. + * + * @dataProvider localized_locales + * + * @param string $locale User locale. + * @param string $code Language code the SDK uses for that locale. + */ + public function test_upgrade_link_has_no_language_prefix( string $locale, string $code ): void { + $this->login_admin_with_locale( $locale, $code ); + + $this->assert_upgrade_link( Optml_Admin::get_upgrade_base_link() ); + } + + /** + * Without an account email the upgrade link is the bare upgrade page. + */ + public function test_upgrade_link_without_account_email_has_no_language_prefix(): void { + $this->login_admin_with_locale(); + ( new Optml_Settings() )->update( 'service_data', [] ); + + $this->assertSame( 'https://optimole.com/upgrade/', Optml_Admin::get_upgrade_base_link() ); + } + + /** + * The contact link has no language code. + */ + public function test_contact_link_has_no_language_prefix(): void { + $this->login_admin_with_locale(); + + $this->assertSame( 'https://optimole.com/contact/', Optml_Admin::get_contact_base_link() ); + } + + /** + * The Media Library upgrade notice links to the upgrade page without a language code. + */ + public function test_upgrade_notice_link_has_no_language_prefix(): void { + $this->login_admin_with_locale(); + set_current_screen( 'upload' ); + + ob_start(); + ( new Optml_Admin() )->add_notice_upgrade(); + $output = (string) ob_get_clean(); + + $links = $this->get_optimole_links( $output ); + + $this->assertCount( 1, $links ); + $this->assert_upgrade_link( $links[0] ); + } + + /** + * Both Black Friday notices link to the upgrade page without a language code, and keep the account email. + */ + public function test_black_friday_links_have_no_language_prefix(): void { + $this->login_admin_with_locale(); + add_filter( 'themeisle_sdk_is_black_friday_sale', '__return_true' ); + add_filter( + 'themeisle_sdk_current_date', + static function () { + return new DateTime( 'last Friday of November ' . gmdate( 'Y' ) ); + } + ); + + $notices = ( new Optml_Admin() )->get_bf_notices( 'free' ); + + foreach ( [ 'sidebar', 'banner' ] as $notice ) { + $this->assertArrayHasKey( $notice, $notices ); + $this->assert_upgrade_link( $notices[ $notice ]['cta_link'], "Wrong upgrade link in the $notice notice." ); + } + } + + /** + * Nothing the dashboard app receives links to a localized optimole.com page. + */ + public function test_dashboard_data_has_no_localized_optimole_links(): void { + $this->login_admin_with_locale(); + + $localize = new ReflectionMethod( Optml_Admin::class, 'localize_dashboard_app' ); + $localize->setAccessible( true ); + $data = $localize->invoke( new Optml_Admin() ); + + $this->assertSame( 'https://optimole.com/', $data['optimoleHome'] ); + $this->assert_upgrade_link( $data['upgrade_url'] ); + $this->assertStringStartsWith( 'https://optimole.com/pricing/?', $data['offload_upgrade_url'] ); + $this->assertStringStartsWith( 'https://optimole.com/contact/?', $data['report_issue_url'] ); + $this->assertSame( + [ 'https://optimole.com/terms/', 'https://optimole.com/privacy-policy/' ], + $this->get_optimole_links( $data['strings']['signup_terms'] ) + ); + + $disabled_account_links = $this->get_optimole_links( $data['strings']['notice_disabled_account'] ); + $this->assertCount( 1, $disabled_account_links ); + $this->assert_upgrade_link( $disabled_account_links[0] ); + + array_walk_recursive( + $data, + function ( $value, $key ) { + if ( is_string( $value ) ) { + $this->assertDoesNotMatchRegularExpression( self::LOCALIZED_LINK_PATTERN, $value, "Localized optimole.com link in '$key'." ); + } + } + ); + + // Links to dashboard.optimole.com carry the language as a query argument and are left as they are. + $this->assertSame( 'https://dashboard.optimole.com/?lang=de', $data['optimoleDashHome'] ); + } + + /** + * The frontend badge links to optimole.com without a language code. + */ + public function test_frontend_badge_link_has_no_language_prefix(): void { + if ( defined( 'REST_REQUEST' ) ) { + $this->markTestSkipped( 'The badge is not rendered during a REST request.' ); + } + + $this->login_admin_with_locale(); + ( new Optml_Settings() )->update_frontend_banner_from_remote( true ); + + ob_start(); + Optml_Manager::instance()->banner(); + $output = (string) ob_get_clean(); + + $this->assertSame( [ 'https://optimole.com/wordpress/?from=badgeOn' ], $this->get_optimole_links( $output ) ); + } +} From b20e25fb828510e2b2611575bc09d24fa4f87694 Mon Sep 17 00:00:00 2001 From: selul Date: Wed, 18 Nov 2026 11:35:39 +0200 Subject: [PATCH 2/2] fix: keep the language code on optimole.com links and add it only once Restores the localized optimole.com links that the previous commit removed, so they are ready if translated pages are added. The upgrade link is localized once, inside get_upgrade_base_link(). The Media Library upgrade notice, the Black Friday sidebar offer and the disabled-account notice no longer localize it a second time, which produced /de/de/upgrade (a 404). Co-Authored-By: Claude Fable 5.2 --- inc/admin.php | 15 +-- inc/manager.php | 2 +- ...timole-links.php => test-upgrade-link.php} | 114 ++++++------------ 3 files changed, 45 insertions(+), 86 deletions(-) rename tests/{test-optimole-links.php => test-upgrade-link.php} (52%) diff --git a/inc/admin.php b/inc/admin.php index 0736a225..4438d099 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -772,12 +772,13 @@ public function should_show_upgrade() { /** * Build upgrade URL with current user's encoded email. * - * The URL is not localized with tsdk_translate_link() because optimole.com has no translated pages. + * The URL is already localized, so callers must not pass it through tsdk_translate_link() again. * * @return string Upgrade URL. */ public static function get_upgrade_base_link() { - $base_url = 'https://optimole.com/upgrade/'; + $base_url = 'https://optimole.com/upgrade'; + $base_url = tsdk_translate_link( $base_url ); $email = self::get_account_email(); if ( ! empty( $email ) ) { @@ -793,7 +794,7 @@ public static function get_upgrade_base_link() { * @return string Contact URL. */ public static function get_contact_base_link() { - return 'https://optimole.com/contact/'; + return tsdk_translate_link( 'https://optimole.com/contact' ); } /** @@ -1532,11 +1533,11 @@ private function localize_dashboard_app() { 'site_settings' => $site_settings, 'offload_limit' => $this->settings->get( 'offload_limit' ), 'home_url' => home_url(), - 'optimoleHome' => 'https://optimole.com/', + 'optimoleHome' => tsdk_translate_link( 'https://optimole.com/' ), 'optimoleDashHome' => tsdk_translate_link( 'https://dashboard.optimole.com/', 'query' ), 'optimoleDashBilling' => tsdk_translate_link( 'https://dashboard.optimole.com/settings/billing', 'query' ), 'optimoleDashMetrics' => tsdk_translate_link( tsdk_utmify( 'https://dashboard.optimole.com/metrics', 'wp-plugin', 'shortcut' ) ), - 'offload_upgrade_url' => tsdk_utmify( 'https://optimole.com/pricing/', 'offload' ), + 'offload_upgrade_url' => tsdk_translate_link( tsdk_utmify( 'https://optimole.com/pricing/', 'offload' ) ), 'days_since_install' => round( ( time() - get_option( 'optimole_wp_install', 0 ) ) / DAY_IN_SECONDS ), 'is_offload_media_available' => $is_offload_media_available, 'auto_connect' => $auto_connect, @@ -1924,8 +1925,8 @@ private function get_dashboard_strings() { 'signup_terms' => sprintf( /* translators: 1 is starting anchor tag to terms, 2 is starting anchor tag to privacy link and 3 is ending anchor tag. */ __( 'By signing up, you agree to our %1$sTerms of Service %3$s and %2$sPrivacy Policy %3$s.', 'optimole-wp' ), - '', - '', + '', + '', '' ), 'dashboard_menu_item' => __( 'Dashboard', 'optimole-wp' ), diff --git a/inc/manager.php b/inc/manager.php index b9110484..b55c2de3 100644 --- a/inc/manager.php +++ b/inc/manager.php @@ -247,7 +247,7 @@ public function banner() { $logo = OPTML_URL . 'assets/img/logo.svg'; - $link = 'https://optimole.com/wordpress/?from=badgeOn'; + $link = tsdk_translate_link( 'https://optimole.com/wordpress/?from=badgeOn' ); $css = ''; diff --git a/tests/test-optimole-links.php b/tests/test-upgrade-link.php similarity index 52% rename from tests/test-optimole-links.php rename to tests/test-upgrade-link.php index 0f795cae..f713f59a 100644 --- a/tests/test-optimole-links.php +++ b/tests/test-upgrade-link.php @@ -9,12 +9,12 @@ */ /** - * Class Test_Optimole_Links. + * Class Test_Upgrade_Link. * - * optimole.com has no localized pages, so its links must never get a language code in the path, - * whatever the locale of the current user. Links to dashboard.optimole.com keep their `?lang=` argument. + * The upgrade link gets the language code of the current user once. A second code in the path + * (`/de/de/upgrade`) leads to a page that does not exist. */ -class Test_Optimole_Links extends WP_UnitTestCase { +class Test_Upgrade_Link extends WP_UnitTestCase { /** * Email of the connected Optimole account. @@ -22,9 +22,9 @@ class Test_Optimole_Links extends WP_UnitTestCase { const ACCOUNT_EMAIL = 'jane@example.com'; /** - * Matches an optimole.com link whose path starts with a language code the SDK knows about. + * Matches an optimole.com link whose path starts with two language codes. */ - const LOCALIZED_LINK_PATTERN = '~//optimole\.com/(?:de|es|fr|it|ja|nl|ro)(?![a-z0-9-])~i'; + const DOUBLED_LANGUAGE_PATTERN = '~//optimole\.com/(?:de|es|fr|it|ja|nl|ro)/(?:de|es|fr|it|ja|nl|ro)(?![a-z0-9-])~i'; /** * Service data before the test. @@ -33,22 +33,14 @@ class Test_Optimole_Links extends WP_UnitTestCase { */ private $initial_service_data; - /** - * Frontend badge setting before the test. - * - * @var mixed - */ - private $initial_banner_frontend; - /** * Connect a free account that is close to its visits limit. */ public function setUp(): void { parent::setUp(); - $settings = new Optml_Settings(); - $this->initial_service_data = $settings->get( 'service_data' ); - $this->initial_banner_frontend = $settings->get( 'banner_frontend' ); + $settings = new Optml_Settings(); + $this->initial_service_data = $settings->get( 'service_data' ); $settings->update( 'service_data', @@ -68,9 +60,7 @@ public function setUp(): void { * Restore the settings, which outlive the database rollback because they are cached statically. */ public function tearDown(): void { - $settings = new Optml_Settings(); - $settings->update( 'service_data', $this->initial_service_data ); - $settings->update_frontend_banner_from_remote( 'enabled' === $this->initial_banner_frontend ); + ( new Optml_Settings() )->update( 'service_data', $this->initial_service_data ); remove_all_filters( 'themeisle_sdk_is_black_friday_sale' ); remove_all_filters( 'themeisle_sdk_current_date' ); @@ -99,10 +89,10 @@ public function localized_locales(): array { } /** - * Log in an administrator who uses the given locale, and check the SDK really localizes links for them. + * Log in an administrator who uses the given locale, and check how the SDK localizes links for them. * * @param string $locale User locale. - * @param string $code Language code the SDK uses for that locale. + * @param string $code Language code the SDK uses for that locale, empty when it uses none. */ private function login_admin_with_locale( string $locale = 'de_DE', string $code = 'de' ): void { wp_set_current_user( @@ -115,17 +105,23 @@ private function login_admin_with_locale( string $locale = 'de_DE', string $code ); $this->assertSame( $locale, get_user_locale() ); - $this->assertSame( "https://example.org/$code/page/", tsdk_translate_link( 'https://example.org/page/' ) ); + $this->assertSame( + '' === $code ? 'https://example.org/page/' : "https://example.org/$code/page/", + tsdk_translate_link( 'https://example.org/page/' ) + ); } /** - * Assert a link is the upgrade page without a language code, carrying the encoded account email. + * Assert a link is the upgrade page with the language code once, carrying the encoded account email. * * @param string $link Link to check. + * @param string $code Expected language code, empty for none. * @param string $message Failure message. */ - private function assert_upgrade_link( string $link, string $message = '' ): void { - $this->assertStringStartsWith( 'https://optimole.com/upgrade/?email=', $link, $message ); + private function assert_upgrade_link( string $link, string $code = 'de', string $message = '' ): void { + $path = '' === $code ? '/upgrade' : "/$code/upgrade"; + + $this->assertStringStartsWith( "https://optimole.com$path?email=", $link, $message ); parse_str( (string) wp_parse_url( $link, PHP_URL_QUERY ), $query ); $this->assertSame( self::ACCOUNT_EMAIL, base64_decode( $query['email'] ), $message ); @@ -145,42 +141,32 @@ private function get_optimole_links( string $html ): array { } /** - * The upgrade link is the same for every locale: no language code, and the account email is kept. + * The upgrade link has the language code of the user once, and keeps the account email. * * @dataProvider localized_locales * * @param string $locale User locale. * @param string $code Language code the SDK uses for that locale. */ - public function test_upgrade_link_has_no_language_prefix( string $locale, string $code ): void { + public function test_upgrade_link_has_the_language_code_once( string $locale, string $code ): void { $this->login_admin_with_locale( $locale, $code ); - $this->assert_upgrade_link( Optml_Admin::get_upgrade_base_link() ); - } - - /** - * Without an account email the upgrade link is the bare upgrade page. - */ - public function test_upgrade_link_without_account_email_has_no_language_prefix(): void { - $this->login_admin_with_locale(); - ( new Optml_Settings() )->update( 'service_data', [] ); - - $this->assertSame( 'https://optimole.com/upgrade/', Optml_Admin::get_upgrade_base_link() ); + $this->assert_upgrade_link( Optml_Admin::get_upgrade_base_link(), $code ); } /** - * The contact link has no language code. + * A locale the SDK does not localize gets the upgrade link without a language code. */ - public function test_contact_link_has_no_language_prefix(): void { - $this->login_admin_with_locale(); + public function test_upgrade_link_has_no_language_code_for_other_locales(): void { + $this->login_admin_with_locale( 'en_US', '' ); - $this->assertSame( 'https://optimole.com/contact/', Optml_Admin::get_contact_base_link() ); + $this->assert_upgrade_link( Optml_Admin::get_upgrade_base_link(), '' ); } /** - * The Media Library upgrade notice links to the upgrade page without a language code. + * The Media Library upgrade notice does not add the language code a second time. */ - public function test_upgrade_notice_link_has_no_language_prefix(): void { + public function test_upgrade_notice_link_has_the_language_code_once(): void { $this->login_admin_with_locale(); set_current_screen( 'upload' ); @@ -195,9 +181,9 @@ public function test_upgrade_notice_link_has_no_language_prefix(): void { } /** - * Both Black Friday notices link to the upgrade page without a language code, and keep the account email. + * Neither Black Friday notice adds the language code a second time. */ - public function test_black_friday_links_have_no_language_prefix(): void { + public function test_black_friday_links_have_the_language_code_once(): void { $this->login_admin_with_locale(); add_filter( 'themeisle_sdk_is_black_friday_sale', '__return_true' ); add_filter( @@ -211,28 +197,21 @@ static function () { foreach ( [ 'sidebar', 'banner' ] as $notice ) { $this->assertArrayHasKey( $notice, $notices ); - $this->assert_upgrade_link( $notices[ $notice ]['cta_link'], "Wrong upgrade link in the $notice notice." ); + $this->assert_upgrade_link( $notices[ $notice ]['cta_link'], 'de', "Wrong upgrade link in the $notice notice." ); } } /** - * Nothing the dashboard app receives links to a localized optimole.com page. + * Nothing the dashboard app receives links to optimole.com with two language codes. */ - public function test_dashboard_data_has_no_localized_optimole_links(): void { + public function test_dashboard_data_has_no_doubled_language_code(): void { $this->login_admin_with_locale(); $localize = new ReflectionMethod( Optml_Admin::class, 'localize_dashboard_app' ); $localize->setAccessible( true ); $data = $localize->invoke( new Optml_Admin() ); - $this->assertSame( 'https://optimole.com/', $data['optimoleHome'] ); $this->assert_upgrade_link( $data['upgrade_url'] ); - $this->assertStringStartsWith( 'https://optimole.com/pricing/?', $data['offload_upgrade_url'] ); - $this->assertStringStartsWith( 'https://optimole.com/contact/?', $data['report_issue_url'] ); - $this->assertSame( - [ 'https://optimole.com/terms/', 'https://optimole.com/privacy-policy/' ], - $this->get_optimole_links( $data['strings']['signup_terms'] ) - ); $disabled_account_links = $this->get_optimole_links( $data['strings']['notice_disabled_account'] ); $this->assertCount( 1, $disabled_account_links ); @@ -242,30 +221,9 @@ public function test_dashboard_data_has_no_localized_optimole_links(): void { $data, function ( $value, $key ) { if ( is_string( $value ) ) { - $this->assertDoesNotMatchRegularExpression( self::LOCALIZED_LINK_PATTERN, $value, "Localized optimole.com link in '$key'." ); + $this->assertDoesNotMatchRegularExpression( self::DOUBLED_LANGUAGE_PATTERN, $value, "Doubled language code in '$key'." ); } } ); - - // Links to dashboard.optimole.com carry the language as a query argument and are left as they are. - $this->assertSame( 'https://dashboard.optimole.com/?lang=de', $data['optimoleDashHome'] ); - } - - /** - * The frontend badge links to optimole.com without a language code. - */ - public function test_frontend_badge_link_has_no_language_prefix(): void { - if ( defined( 'REST_REQUEST' ) ) { - $this->markTestSkipped( 'The badge is not rendered during a REST request.' ); - } - - $this->login_admin_with_locale(); - ( new Optml_Settings() )->update_frontend_banner_from_remote( true ); - - ob_start(); - Optml_Manager::instance()->banner(); - $output = (string) ob_get_clean(); - - $this->assertSame( [ 'https://optimole.com/wordpress/?from=badgeOn' ], $this->get_optimole_links( $output ) ); } }