Skip to content

Commit ded2039

Browse files
ilicfilipclaude
andauthored
Fix plugin-check CI: pin dist-archive-command to v3.1.0 (#757)
* WIP * filter out the activity category * tweak when onboarding tasks should show, pp-hosts compat * Replace hardcoded Ravi icon with branding system icon Use get_admin_menu_icon() from the branding system instead of hardcoded icon_progress_planner.svg references, so hosts with custom branding automatically get their own icon everywhere. Closes #51 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix coding standards: add backslash prefix to global functions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix e2e onboarding test: remove pre-set license key and mock remote API The blueprint was pre-setting progress_planner_license_key, which made is_privacy_policy_accepted() return true and the welcome screen never appeared. The onboarding test couldn't find .prpl-welcome. Fix: remove the license key from the blueprint so the fresh install onboarding screen shows, and mock the remote progressplanner.com API calls (get-nonce + onboard) since Playground can't reach them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix onboarding test: wait for page reload after form submission After the form submit triggers the JS flow (remote API → save license key → window.location.reload()), explicitly wait for the page load event before checking for the dashboard widget. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix onboarding test: bypass remote API with direct AJAX call Previous approaches using page.route() failed because Playwright's route mocking doesn't intercept XMLHttpRequest in WP Playground. Instead, use page.evaluate() to call the local WP AJAX save endpoint directly, then reload the page to verify the dashboard appears. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix onboarding test: use XMLHttpRequest instead of fetch The fetch() API fails in Playground's service worker environment with "TypeError: Failed to fetch". Use XMLHttpRequest instead, which is the same mechanism the actual onboarding JS uses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix e2e onboarding test for WP Playground environment The onboarding test was broken since the Docker→Playground migration: 1. Blueprint pre-set the license key, hiding the welcome screen 2. page.route() cannot intercept requests handled by Playground's service worker, so the remote API (progressplanner.com) calls in the JS onboarding flow silently fail Fix by: - Removing pre-set license key from blueprint (keep demo_data_generated to prevent Playground class from auto-generating one) - Using Playwright's page.request.post() to call the local WP AJAX endpoint directly — this bypasses the service worker entirely while sharing the page's auth cookies Works in both Playground (e2e-tests) and Docker (yoast-premium-tests). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * apply branding to dashboard widget titles * Pin dist-archive-command to v3.1.0 for WP-CLI 2.12 compat dist-archive-command v3.2.0 requires wp-cli ^2.13 but the CI runner (shivammathur/setup-php) provides 2.12.0, causing plugin-check to fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c53a43e commit ded2039

30 files changed

Lines changed: 150 additions & 58 deletions

.github/workflows/plugin-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
tools: wp-cli
1818

1919
- name: Install latest version of dist-archive-command
20-
run: wp package install wp-cli/dist-archive-command:@stable
20+
run: wp package install wp-cli/dist-archive-command:v3.1.0
2121

2222
- name: Build plugin
2323
run: |

assets/css/page-widgets/todo.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
display: inline-block;
4040
width: 24px;
4141
height: 24px;
42-
background-image: url("../../images/icon_progress_planner.svg");
42+
background-image: var(--prpl-icon-url);
4343
background-size: contain;
4444
background-repeat: no-repeat;
4545
}
@@ -136,7 +136,7 @@
136136
display: inline-block;
137137
width: 24px;
138138
height: 24px;
139-
background-image: url("../../images/icon_progress_planner.svg");
139+
background-image: var(--prpl-icon-url);
140140
background-size: contain;
141141
background-repeat: no-repeat;
142142
}

assets/js/focus-element.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
const prplGetIndicatorElement = ( content, taskId, points ) => {
99
// Create an <img> element.
1010
const imgEl = document.createElement( 'img' );
11-
imgEl.src =
12-
progressPlannerFocusElement.base_url +
13-
'/assets/images/icon_progress_planner.svg';
11+
imgEl.src = progressPlannerFocusElement.iconUrl;
1412
imgEl.alt = points
1513
? prplL10n( 'fixThisIssue' ).replace( '%d', points )
1614
: '';

assets/js/yoast-focus-element.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ProgressPlannerYoastFocus {
1414
constructor() {
1515
this.container = document.querySelector( '#yoast-seo-settings' );
1616
this.tasks = progressPlannerYoastFocusElement.tasks;
17-
this.baseUrl = progressPlannerYoastFocusElement.base_url;
17+
this.iconUrl = progressPlannerYoastFocusElement.iconUrl;
1818

1919
if ( this.container ) {
2020
this.init();
@@ -219,7 +219,7 @@ class ProgressPlannerYoastFocus {
219219

220220
// Create an icon image.
221221
const iconImg = document.createElement( 'img' );
222-
iconImg.src = this.baseUrl + '/assets/images/icon_progress_planner.svg';
222+
iconImg.src = this.iconUrl;
223223
iconImg.alt = 'Ravi';
224224
iconImg.width = 16;
225225
iconImg.height = 16;

classes/admin/class-dashboard-widget-score.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Dashboard_Widget_Score extends Dashboard_Widget {
2727
* @return string
2828
*/
2929
protected function get_title() {
30-
return \esc_html__( 'Progress Planner', 'progress-planner' );
30+
return \esc_html( \progress_planner()->get_ui__branding()->get_admin_menu_name() );
3131
}
3232

3333
/**

classes/admin/class-dashboard-widget-todo.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class Dashboard_Widget_Todo extends Dashboard_Widget {
2727
* @return string
2828
*/
2929
protected function get_title() {
30-
return \esc_html__( 'To-do list Progress Planner', 'progress-planner' );
30+
/* translators: %s: plugin name */
31+
return \sprintf( \esc_html__( 'To-do list %s', 'progress-planner' ), \progress_planner()->get_ui__branding()->get_admin_menu_name() );
3132
}
3233

3334
/**

classes/admin/class-enqueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function localize_script( $handle, $localize_data = [] ) {
301301
$localize_data = [
302302
'name' => 'prplCelebrate',
303303
'data' => [
304-
'raviIconUrl' => \constant( 'PROGRESS_PLANNER_URL' ) . '/assets/images/icon_progress_planner.svg',
304+
'raviIconUrl' => \progress_planner()->get_ui__branding()->get_admin_menu_icon(),
305305
'confettiOptions' => $confetti_options,
306306
],
307307
];

classes/admin/class-page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function maybe_enqueue_focus_el_script( $hook ) {
261261
'tasks' => $tasks_details,
262262
'totalPoints' => $total_points,
263263
'completedPoints' => $completed_points,
264-
'base_url' => \constant( 'PROGRESS_PLANNER_URL' ),
264+
'iconUrl' => \progress_planner()->get_ui__branding()->get_admin_menu_icon(),
265265
'l10n' => [
266266
/* translators: %d: The number of points. */
267267
'fixThisIssue' => \esc_html__( 'Fix this issue to get %d point(s) in Progress Planner', 'progress-planner' ),

classes/admin/widgets/class-todo.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ final class ToDo extends Widget {
2626
*/
2727
protected $width = 2;
2828

29+
/**
30+
* Enqueue styles.
31+
*
32+
* @return void
33+
*/
34+
public function enqueue_styles() {
35+
parent::enqueue_styles();
36+
\wp_add_inline_style(
37+
"progress-planner/page-widgets/{$this->id}",
38+
':root { --prpl-icon-url: url("' . \progress_planner()->get_ui__branding()->get_admin_menu_icon() . '"); }'
39+
);
40+
}
41+
2942
/**
3043
* Print the widget content.
3144
*

classes/class-badges.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,19 @@ public function __construct() {
8383
* @return \Progress_Planner\Badges\Badge[]
8484
*/
8585
public function get_badges( $context ) {
86-
return isset( $this->$context ) ? $this->$context : [];
86+
// phpcs:ignore Generic.Commenting.DocComment.MissingShort -- Inline @var for PHPStan.
87+
/** @var \Progress_Planner\Badges\Badge[] $badges */
88+
$badges = isset( $this->$context ) ? $this->$context : [];
89+
90+
/**
91+
* Filter the badges for a context.
92+
*
93+
* @param \Progress_Planner\Badges\Badge[] $badges The badges.
94+
* @param string $context The badges context.
95+
*
96+
* @return \Progress_Planner\Badges\Badge[]
97+
*/
98+
return \apply_filters( 'progress_planner_badges', $badges, $context );
8799
}
88100

89101
/**
@@ -101,7 +113,18 @@ public function get_badge( $badge_id ) {
101113
}
102114
}
103115
}
104-
return null;
116+
117+
/**
118+
* Filter for retrieving a single badge by ID.
119+
*
120+
* Allows external plugins to provide custom badges.
121+
*
122+
* @param \Progress_Planner\Badges\Badge|null $badge The badge object or null.
123+
* @param string $badge_id The badge ID.
124+
*
125+
* @return \Progress_Planner\Badges\Badge|null
126+
*/
127+
return \apply_filters( 'progress_planner_get_badge', null, $badge_id );
105128
}
106129

107130
/**
@@ -183,6 +206,8 @@ public function get_latest_completed_badge() {
183206
// Get the settings for badges (stores completion dates).
184207
$settings = \progress_planner()->get_settings()->get( 'badges', [] );
185208

209+
// phpcs:ignore Generic.Commenting.DocComment.MissingShort -- Inline @var for PHPStan.
210+
/** @var string|null $latest_date */
186211
$latest_date = null;
187212

188213
// Loop through all badge contexts to find the most recently completed badge.
@@ -204,20 +229,30 @@ public function get_latest_completed_badge() {
204229
if ( null === $latest_date ) {
205230
$this->latest_completed_badge = $badge;
206231
if ( isset( $settings[ $badge->get_id() ]['date'] ) ) {
207-
$latest_date = $settings[ $badge->get_id() ]['date'];
232+
$latest_date = (string) $settings[ $badge->get_id() ]['date'];
208233
}
209234
continue;
210235
}
211236

212237
// Compare completion dates as Unix timestamps to find the most recent.
213238
// Using >= ensures that if multiple badges complete simultaneously, the last one processed wins.
214-
if ( \DateTime::createFromFormat( 'Y-m-d H:i:s', $settings[ $badge->get_id() ]['date'] )->format( 'U' ) >= \DateTime::createFromFormat( 'Y-m-d H:i:s', $latest_date )->format( 'U' ) ) {
215-
$latest_date = $settings[ $badge->get_id() ]['date'];
239+
if ( \DateTime::createFromFormat( 'Y-m-d H:i:s', (string) $settings[ $badge->get_id() ]['date'] )->format( 'U' ) >= \DateTime::createFromFormat( 'Y-m-d H:i:s', $latest_date )->format( 'U' ) ) {
240+
$latest_date = (string) $settings[ $badge->get_id() ]['date'];
216241
$this->latest_completed_badge = $badge;
217242
}
218243
}
219244
}
220245

246+
/**
247+
* Filter the latest completed badge.
248+
*
249+
* @param \Progress_Planner\Badges\Badge|null $badge The latest completed badge.
250+
* @param string|null $latest_date The latest completion date.
251+
*
252+
* @return \Progress_Planner\Badges\Badge|null
253+
*/
254+
$this->latest_completed_badge = \apply_filters( 'progress_planner_latest_completed_badge', $this->latest_completed_badge, $latest_date );
255+
221256
return $this->latest_completed_badge;
222257
}
223258
}

0 commit comments

Comments
 (0)