Skip to content

Add Branding::enqueue_inline_css() so partner CSS can attach to any handle#762

Merged
ilicfilip merged 1 commit intodevelopfrom
filip/branding-inline-css-helper
May 5, 2026
Merged

Add Branding::enqueue_inline_css() so partner CSS can attach to any handle#762
ilicfilip merged 1 commit intodevelopfrom
filip/branding-inline-css-helper

Conversation

@ilicfilip
Copy link
Copy Markdown
Collaborator

Summary

  • Adds Branding::enqueue_inline_css( string $handle ) — attaches the partner branding custom_css to any registered/enqueued style handle, idempotent per handle per request.
  • Refactors Page::enqueue_styles() to use it, removing the now-redundant Page::$branding_inline_styles_added static (the per-request dedupe still exists, just inside the new method).

Why

Partner branding CSS is currently injected only on PP admin pages, because it's hardcoded into Page::enqueue_styles(). Other surfaces that should carry partner branding — the pp-hosts guided tour, which runs on the block editor, site editor, frontend, and non-PP admin screens — have no clean way to opt in.

This is a no-behavior-change refactor for PP itself: the same handle (progress-planner/admin) gets the same inline CSS as before, with the same once-per-request dedupe (which matters because dashboard widgets like Dashboard_Widget_Score and Dashboard_Widget_Todo call enqueue_styles() multiple times per request).

For external integrations, it makes the inline-CSS attachment a one-liner: \progress_planner()->get_ui__branding()->enqueue_inline_css( 'my-handle' );.

Test plan

  • Visit the Progress Planner admin page on a site with a branded PROGRESS_PLANNER_BRANDING_ID — partner custom CSS still applies (no visual change).
  • Verify the inline CSS appears exactly once in the page source even when both score and todo dashboard widgets are rendered.
  • On a site without branding (default ID), confirm no inline <style> is added (the early-return on empty get_custom_css() covers this).
  • PHPStan + stylelint + eslint pass (verified locally via the pre-commit hook).

🤖 Generated with Claude Code

…andle

Allows external integrations (e.g. pp-hosts guided tour, which runs on
the block editor, site editor, frontend, and non-PP admin screens) to
apply the partner branding custom CSS to their own stylesheets, instead
of being limited to the PP admin pages where Page::enqueue_styles()
runs.

The new method is idempotent per style handle, so the per-request
dedupe that previously lived on Page (via the
$branding_inline_styles_added static — needed because dashboard
widgets call enqueue_styles() multiple times per request) now lives
with the branding class itself and works for any handle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🔍 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://wpvip.com/documentation/performance-improvements-by-removing-usage-of-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://wpvip.com/documentation/performance-improvements-by-removing-usage-of-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://wpvip.com/documentation/performance-improvements-by-removing-usage-of-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://wpvip.com/documentation/performance-improvements-by-removing-usage-of-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://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
📁 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.
📁 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.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ Code Coverage Report

Metric Value
Total Coverage 31.41% 📉
Base Coverage 31.43%
Difference 📉 -0.02%

⚠️ Coverage below recommended 40% threshold

📊 File-level Coverage Changes (2 files)

📈 Coverage Improved

Class Before After Change
Progress_Planner\Admin\Page 30.95% 31.33% +0.38%

📉 Coverage Decreased

Class Before After Change
Progress_Planner\UI\Branding 31.82% 29.91% -1.91%
ℹ️ 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 ilicfilip merged commit a15bf2d into develop May 5, 2026
21 of 22 checks passed
@ilicfilip ilicfilip deleted the filip/branding-inline-css-helper branch May 5, 2026 11:34
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