From e7dc3c6bec24e06ecd9a8bf370fb8c59115a6267 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Thu, 26 Mar 2026 18:03:01 +0200 Subject: [PATCH 1/3] Fix hardcoded wp-admin URLs --- src/@types/assets/window.d.ts | 1 + src/UI/class-site-health.php | 7 ++- .../common/class-content-helper-feature.php | 2 +- .../editor-sidebar/class-editor-sidebar.php | 7 +++ .../editor-sidebar/tabs/sidebar-tools-tab.tsx | 15 ++++++- tests/Integration/UI/SettingsPageTest.php | 19 ++++++++ tests/Integration/UI/SiteHealthTest.php | 43 +++++++++++++++++++ tests/e2e/specs/front-end-metadata.spec.ts | 2 +- .../settings-track-post-types-as.spec.ts | 2 +- .../editor-sidebar/sidebar-tools-tab.test.tsx | 32 ++++++++++++++ 10 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 tests/js/content-helper/editor-sidebar/sidebar-tools-tab.test.tsx diff --git a/src/@types/assets/window.d.ts b/src/@types/assets/window.d.ts index 174d60fda7..e6cbe6c19a 100644 --- a/src/@types/assets/window.d.ts +++ b/src/@types/assets/window.d.ts @@ -23,6 +23,7 @@ declare global { onReady?: () => unknown, }, + wpParselyAdminUrl: string; wpParselyContentHelperPermissions: string; wpParselyContentHelperSettings: string; wpParselyDependencies: { [key: string]: string }; diff --git a/src/UI/class-site-health.php b/src/UI/class-site-health.php index 3b9f34a32c..963f10a0b8 100644 --- a/src/UI/class-site-health.php +++ b/src/UI/class-site-health.php @@ -84,7 +84,11 @@ public function check_site_id( array $tests ): array { if ( $this->parsely->site_id_is_missing() ) { $result['status'] = 'critical'; $result['label'] = __( 'You need to provide the Site ID', 'wp-parsely' ); - $result['actions'] = __( 'The site ID can be set in the Parse.ly Settings Page.', 'wp-parsely' ); + $result['actions'] = sprintf( + /* translators: %s: URL to the Parse.ly settings page */ + __( 'The site ID can be set in the Parse.ly Settings Page.', 'wp-parsely' ), + esc_url( Parsely::get_settings_url() ) + ); } return $result; @@ -100,6 +104,7 @@ public function check_site_id( array $tests ): array { 'label' => __( 'Parse.ly Site ID', 'wp-parsely' ), 'test' => $test, ); + $tests['direct'] = $direct; return $tests; } diff --git a/src/content-helper/common/class-content-helper-feature.php b/src/content-helper/common/class-content-helper-feature.php index 0c1c115afe..9a31bf964c 100644 --- a/src/content-helper/common/class-content-helper-feature.php +++ b/src/content-helper/common/class-content-helper-feature.php @@ -207,7 +207,7 @@ protected function get_credentials_not_set_message(): string { 'Existing Parse.ly customers can enable this feature by setting their Site ID and API Secret in ', 'wp-parsely' ) . ' - ' . + ' . __( 'wp-parsely options.', 'wp-parsely' ) . '

diff --git a/src/content-helper/editor-sidebar/class-editor-sidebar.php b/src/content-helper/editor-sidebar/class-editor-sidebar.php index c0b3ea354a..cda7e06667 100644 --- a/src/content-helper/editor-sidebar/class-editor-sidebar.php +++ b/src/content-helper/editor-sidebar/class-editor-sidebar.php @@ -170,6 +170,13 @@ public function run(): void { ); } + // Inject the admin URL for generating admin page links. + wp_add_inline_script( + static::get_script_id(), + 'window.wpParselyAdminUrl = ' . wp_json_encode( admin_url() ) . ';', + 'before' + ); + // Inject the trackable statuses. $trackable_statuses = Parsely::get_trackable_statuses(); wp_add_inline_script( diff --git a/src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx b/src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx index 154a49b7a7..040d8025a7 100644 --- a/src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx +++ b/src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx @@ -19,6 +19,19 @@ import { RelatedPostsPanel } from '../related-posts/component'; import { SmartLinkingPanel, SmartLinkingPanelContext } from '../smart-linking/component'; import { TitleSuggestionsPanel } from '../title-suggestions/component'; +/** + * Builds the Boost Engagement button URL from the admin base URL and post ID. + * + * @since 3.22.1 + * + * @param {string} adminUrl The WordPress admin base URL. + * @param {number} postId The current post ID. + * @return {string} The full URL to the engagement-boost page for the given post. + */ +export function getBoostEngagementUrl( adminUrl: string, postId: number ): string { + return `${ adminUrl }admin.php?page=parsely-dashboard-page#/engagement-boost/${ postId }`; +} + /** * SidebarToolsTab component props. * @@ -146,7 +159,7 @@ export const SidebarToolsTab = ( { postId > 0 && isPostTrackable && permissions.TrafficBoost &&