Skip to content

Give the streak and content badges their own popovers - #813

Draft
ilicfilip wants to merge 6 commits into
filip/monthly-badges-popoverfrom
filip/streak-content-popovers
Draft

ilicfilip wants to merge 6 commits into
filip/monthly-badges-popoverfrom
filip/streak-content-popovers

Conversation

@ilicfilip

@ilicfilip ilicfilip commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Implements https://github.com/ProgressPlanner/progress-planner-pro/issues/190

Stacked on #812 (monthly badges popover). Merge #812 first; this PR then retargets to develop.

Design: Figma popover-badges — widgets (stats page streak, stats page content badge), popovers (popover streak, stats page popover streak freeze, stats page popover streak completed, popover content badge), hover (streak animation, content badge animation).

What this does

Widgets (streak + content)

  • Gauge counts towards the next badge in weeks / posts (e.g. "9 weeks" of 26, "10 posts" of 30) instead of a percentage. The badge shown is the next one to earn (it was always the first badge).
  • No info icon; "Show all badges" is replaced by "How can I collect these badges?", which opens the widget's own popover.
  • Streak widget: a streak freeze line ("You have one streak freeze" / "You've already used your streak freeze").
  • Typo fix: "meaninful" → "meaningful".

Popovers (one per widget)

  • Intro card + two numbers: "N weeks/posts to go till your next badge" and "N week streak!" / "N posts or pages written".
  • A track from 0 to the last badge with a circle per badge (earned: badge + check), the current value, and a snowflake where the streak freeze was used.
  • The three badges with what each takes; hovering (or tabbing to) one not yet earned shows it in colour, wobbles briefly (off for reduced motion) and shows "N weeks / posts/pages to go".
  • Streak freeze section; "Well done! You've collected all 3 streak/content badges!" once all are earned.

Clean-up

  • The old combined streak popover is removed; its progress_planner_popover_after_streak_sections action still fires in the new streak popover.
  • The monthly popover no longer lists content and streak badges. progress_planner_popover_after_badge_groups still fires at its bottom, so pp-hosts' onboarding badges keep showing there.
  • Shared number-card styles moved to admin.css (used by all three popovers).
  • Tour: the "badge progress" step pointed at an info icon that no longer matched any element; it now points at the streak widget's link.

Streak calculation fixes (Goal_Recurring::get_streak())

  • It now reports freeze_used and freeze_week, needed for the freeze line and the snowflake.
  • It counted the allowed break on the cached goal object, so the second and third streak badges could see a smaller streak than the first in the same request. It now uses a copy.
  • The current week is not over yet: a week without activity so far no longer uses the freeze or breaks the streak.

New tests cover the freeze reporting, repeat calls, and the current week.

Notes for design

  • Colour: the "N … to go" text is bound to --prpl-color-button-primary in Figma (red in PP). Brands set that to their button colour — on Zonnet it is purple. Used as designed; flagging in case a dedicated text colour is wanted.
  • Colour: the snowflake blue (#5EA0D2) has no variable; it lives in the icon file.
  • Colour: the content popover's number cards are bound to --prpl-background-streak in Figma (pink); this uses the content colour (--prpl-background-content-badge). One-line change if pink is intended.
  • Copy: Content Curator reads "20 existing or 10 new posts/pages" (the design's "20 or 10 posts/pages*" has no footnote).
  • Copy: the content popover keeps "Every week of hard work brings you closer to your next milestone!" as in the design.
  • Copy: the "freeze already used" text is a placeholder ("Text to be decided" in Figma).
  • Where pp-hosts' onboarding badges should live long-term is open; for now they stay at the bottom of the monthly popover.

Follow-up outside this repo

  • branding-api tokens.json: add progress-planner to readBy of --prpl-color-alert-success and --prpl-font-size-xl (the tokens check warns).

Testing

  1. Open the Progress Planner dashboard: the streak and content widgets show weeks / posts, the freeze line, and "How can I collect these badges?".
  2. Open each popover: numbers, track, badges; hover a badge not yet earned.
  3. Narrow the window: cards and badges stack without overflowing.

Checked in the browser on the Zonnet brand at 1400px and 420px; console clean. The "all collected" variant was checked by temporarily marking the streak badges as earned (settings restored afterwards). Full PHPUnit suite passes (479 tests); composer check-cs, PHPStan and CSS lint pass.

Screenshots

Screenshot 2026-11-25 at 12 27 09

The streak and content widgets now show progress in weeks and posts
instead of a percentage, towards the next badge. The info icon and the
"Show all badges" link are replaced by "How can I collect these
badges?", which opens a popover for that widget: a track from zero to
the last badge, each badge with what it takes, and on hover how many
weeks or posts are left. The streak popover also shows the streak
freeze, and when it was used.

To tell whether the freeze was used, the streak calculation now reports
it. It also counted breaks on the cached goal object, so a second call
in the same request could return a different streak; it now works on a
copy. The current week is still running, so a week without activity so
far no longer uses the freeze or breaks the streak.

The old combined streak popover is removed, and the monthly popover no
longer lists the content and streak badges. Plugins that add badge
groups to it (pp-hosts' onboarding badges) still can.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Plugin readme preview

Open preview · Commit 9b2b32c

35 passed · 0 warnings · 2 notes

Notes (2)
  • screenshot-8.png has no caption in the Screenshots section.
  • screenshot-9.png has no caption in the Screenshots section.
Passed checks (35)
  • 144 / 150 characters in the short description.
  • Plugin name header recognized.
  • License header recognized: GPL3+.
  • 4 tags accepted within the five-tag limit.
  • Description is within the parser’s word limit.
  • Installation is within the parser’s word limit.
  • Faq is within the parser’s word limit.
  • Changelog is within the parser’s word limit.
  • Tested up to 7.1, the latest WordPress major release.
  • Stable tag is declared: 1.10.1.
  • The PHP Version header is declared: 1.10.1.
  • Stable tag matches the PHP Version header: 1.10.1.
  • The readme “Requires at least” value is valid: 6.7.
  • The PHP “Requires at least” header is a numeric version: 6.7.
  • “Requires at least” matches between the readme and PHP header: 6.7.
  • The readme “Requires PHP” value is valid: 7.4.
  • The PHP “Requires PHP” header is a numeric version: 7.4.
  • “Requires PHP” matches between the readme and PHP header: 7.4.
  • “Tested up to” 7.1 meets the minimum WordPress version 6.7.
  • Installation content is present.
  • FAQ content is present.
  • Changelog content is present.
  • Screenshot captions are present.
  • The first changelog release matches Stable tag: 1.10.1.
  • The first changelog release matches PHP Version: 1.10.1.
  • Banner image loaded.
  • Plugin icon loaded.
  • Screenshot 1 has a matching image and caption.
  • Screenshot 2 has a matching image and caption.
  • Screenshot 3 has a matching image and caption.
  • Screenshot 4 has a matching image and caption.
  • Screenshot 5 has a matching image and caption.
  • Screenshot 6 has a matching image and caption.
  • Screenshot 7 has a matching image and caption.
  • Plugin PHP header loaded.

Readme and PHP-header checks only; this does not test plugin runtime compatibility.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Test on Playground
Test this pull request on the Playground
or download the zip

@github-actions

Copy link
Copy Markdown
Contributor

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
10 0 10

⚠️ Warnings (10)

📁 classes/suggested-tasks/data-collector/class-unpublished-content.php (1 warning)
📍 Line 🔖 Check 💬 Message
103 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
📁 classes/suggested-tasks/providers/class-content-review.php (4 warnings)
📍 Line 🔖 Check 💬 Message
232 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
377 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
381 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
388 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
📁 classes/activities/class-query.php (2 warnings)
📍 Line 🔖 Check 💬 Message
71 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $table_name used in $wpdb->query()\n$table_name assigned unsafely at line 58.
163 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $where_args used in $wpdb->get_results()\n$where_args assigned unsafely at line 153.
📁 classes/suggested-tasks/data-collector/class-yoast-orphaned-content.php (1 warning)
📍 Line 🔖 Check 💬 Message
111 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_row()\n$query assigned unsafely at line 98.
📁 classes/suggested-tasks/data-collector/class-terms-without-description.php (1 warning)
📍 Line 🔖 Check 💬 Message
108 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_results()\n$query assigned unsafely at line 106.
📁 classes/suggested-tasks/data-collector/class-terms-without-posts.php (1 warning)
📍 Line 🔖 Check 💬 Message
120 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_results()\n$query assigned unsafely at line 118.

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Code Coverage Report

Metric Value
Total Coverage 35.59% 📉
Base Coverage 35.69%
Difference 📉 -0.10%

⚠️ Coverage below recommended 40% threshold

📊 File-level Coverage Changes (3 files)

🆕 New Files

Class Coverage Lines
🔴 Progress_Planner\Badges\Badge_Content 0.00% 0/1

📈 Coverage Improved

Class Before After Change
Progress_Planner\Goals\Goal_Recurring 91.49% 92.42% +0.93%

📉 Coverage Decreased

Class Before After Change
Progress_Planner\Badges\Badge_Maintenance 97.06% 94.29% -2.77%
ℹ️ About this report
  • All tests run in a single job with Xdebug coverage
  • Security tests excluded from coverage to prevent output issues
  • Coverage calculated from line coverage percentages

ilicfilip and others added 4 commits November 25, 2026 12:36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Streak badges keep their saved progress for up to two days, while the
  track used the streak worked out just now, so the bar could stand on a
  badge the card still called "1 week to go". Earned and weeks-to-go for
  streak badges now come from the same live streak.
- The streak freeze is one break for the whole history. get_streak() now
  reports where it falls only when it is part of the best streak (the one
  the bar shows), so the snowflake is not placed on the wrong streak.
- get_streak() and get_track() remember their result for the request;
  the widget and its popover share it.
- Each badge class has a TARGET constant (Content Curator also
  TARGET_EXISTING) and get_target(), instead of the numbers being written
  out again in the widget class. The badge maths uses the constants; the
  Content Curator percentage for existing posts is unchanged.
- get_track() takes no argument; each widget knows its own context.
- The popover template keeps the streak and content texts in one list,
  and texts with a number use _n() so every language gets the right plural.
- The wobble is one shared rule for "in progress" and "to go" badges, and
  "N to go" also shows on focus, so a tap on a touch screen reveals it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ilicfilip

Copy link
Copy Markdown
Collaborator Author

Review pass: what changed and why

Re-checked against pro#190, Mijke's comment there ("size and padding consistent with #191") and the Figma frames, and had the code reviewed again. #812's fixes are merged in.

Spacing (0358d2e)

  • 32px inside the streak and content popovers (var(--prpl-gap)), the same as the monthly popover.

Streak numbers agree with each other (db2cf46)

  • Streak badges keep their saved progress for up to two days, but the bar used the streak worked out on the spot. So the bar could stand on a badge the card still called "1 week to go".
  • Earned and weeks-to-go for streak badges now come from the same live streak.

Snowflake on the right streak (db2cf46)

  • The streak freeze is one break for the site's whole history. If it was used in an earlier streak that later broke, the snowflake was still drawn on the bar.
  • get_streak() now reports where the freeze falls only when it's part of the best streak, which is the one the bar shows.

Work done once per page (db2cf46)

  • get_streak() (one query per week since activation) and get_track() now remember their result for the request, so the widget and its popover share it.
  • On my test site there was no measurable difference: saved progress and the object cache already hid the repeat work, and the site has 9 weeks of history. The gain is on a cold cache with a long history.

Readability (db2cf46)

  • Each badge class has a TARGET constant (Content Curator also TARGET_EXISTING) and get_target(). The numbers were written out a second time in the widget class.
  • The badge maths uses the constants. Content Curator's percentage for existing posts (floor( posts / 2 )) is left exactly as it was. It looks off (10 existing posts = 5%), but changing it is a separate decision.
  • get_track() takes no argument, since each widget knows its own context.
  • The popover template keeps the streak and content texts in one list instead of an if/else per sentence.
  • Texts with a number ("26 week streak", "30 new posts/pages", "collected all 3 badges") use _n(), so languages with several plural forms are covered.

CSS (db2cf46)

  • One shared wobble rule for "in progress" and "to go" badges, including the reduced-motion version.
  • "N to go" also shows on focus, so a tap on a touch screen reveals it.

Not changed

  • The .prpl-badge-streak rules look unused in this repo but are used by pp-hosts' onboarding badges in the monthly popover.

Open question (product, not code)

  • The streak freeze is one per site, ever. Once used, the widget says "You've already used your streak freeze" for good. That's how the plugin has always counted it; this PR only shows it. Is that the intended rule?

New test: a freeze in an earlier, broken streak isn't placed on the best streak. The full suite passes (482 tests), PHPCS and PHPStan pass, and both widgets and popovers were checked in the browser, including tap/focus.

@ilicfilip

Copy link
Copy Markdown
Collaborator Author

CI: the e2e tour fix from #812 (9bf62d3, where the popover covered the tour's Next button on short screens) is merged in here. Checked in the browser at 1280×720: every tour step points at an element on the page and can be clicked through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant