Skip to content

Trac: Refresh the Trac front-end assets - #755

Closed
obenland wants to merge 5 commits into
WordPress:trunkfrom
obenland:trac/style-refresh
Closed

Trac: Refresh the Trac front-end assets#755
obenland wants to merge 5 commits into
WordPress:trunkfrom
obenland:trac/style-refresh

Conversation

@obenland

@obenland obenland commented Aug 3, 2026

Copy link
Copy Markdown
Member

Takes the style/trac/ and template changes from #734 ahead of it, with fixes on top, so these assets deploy once and #734 shrinks to its build tooling.

From #734: trac/*.js and wp-trac.css reformatted; the jinja2 shim retired, its rules folded into wp-trac.css (verified #banner, #footer, #tabs); trac-search.js removed, dead since r7275; .success().done(). Excludes the build tooling and trac/README.md, which documents scripts that only exist once #734 lands.

Markup construction. .text(), .attr() and .val() decode entities, so values read back out of the DOM are not safe to concatenate into markup. postPreviewHacks(), nonGardeners(), the closed-milestone notice and the attachment autocomplete now build nodes or escape. linkMentions()/linkGutenbergIssues() index their placeholder tokens, which a comment containing the literal __PLACEHOLDER__ could previously desynchronise. The two existing $( '<span />' ).text( … ).html() uses become a named escapeHtml(), element-content only.

Defects found along the way

  • Style: Replace Grunt with @wordpress/scripts and modernize the build #734's textarea.trigger( 'focus' ) threw on a DOM element, silently breaking the PHP code block button.
  • Toolbar rules and that button's anchor targeted Trac 1.0.9 ids; 1.6 uses class="trac-wikitoolbar-<type>", so icons rendered as empty boxes and the button was never inserted. Pre-existing.
  • The jinja2 fold-in dropped #tab_keybindings and the non-gardener attachment-options rule. Both restored.
  • Style: Replace Grunt with @wordpress/scripts and modernize the build #734 rekeyed addDynamicAssetCacheBuster() to scripts_version, arming a function that had never fired. $.loadStyleSheet de-dupes on exact href, so a second trac.css landed after wp-trac.css and Trac's rules won. Restored to v=.
  • font: 700font-weight; handbook link to HTTPS.

Deployment: sandbox deploy of s.w.org/style/trac/, then bump scripts_version in both site_head.html and site_footer.html.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings August 3, 2026 16:28
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props obenland.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refreshes Trac front-end assets (JS/CSS + Trac templates) by consolidating the former Jinja2-compat shim into the main assets, modernizing markup construction to avoid unsafe HTML string concatenation, and removing dead client code.

Changes:

  • Refactors wp-trac.js to build DOM nodes / escape element content where needed, and adds several Trac UI/UX tweaks (auth links, notices, report/query behaviors).
  • Updates wp-trac.css to absorb the removed compat stylesheet and modernizes selectors/values.
  • Removes unused legacy assets (wp-trac-jinja-compat.*, trac-search.js) and updates template includes accordingly.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wordpress.org/public_html/style/trac/wp-trac.js Main Trac behavior script: refactors HTML construction/escaping, adds UI behaviors, removes reliance on compat shim.
wordpress.org/public_html/style/trac/wp-trac.css Consolidates/modernizes Trac styling; absorbs compat CSS behavior and updates selectors/weights.
wordpress.org/public_html/style/trac/wp-trac-jinja-compat.js Removed legacy Jinja2-compat client rewrite shim.
wordpress.org/public_html/style/trac/wp-trac-jinja-compat.css Removed legacy Jinja2-compat stylesheet.
wordpress.org/public_html/style/trac/trac-security.js Reformats and updates security-keyword gating UI on /newticket.
wordpress.org/public_html/style/trac/trac-search.js Removed dead related-ticket search script.
trac.wordpress.org/templates/site_head.html Stops loading removed compat CSS.
trac.wordpress.org/templates/site_footer.html Stops loading removed compat JS and updates jQuery AJAX callback to .done().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wordpress.org/public_html/style/trac/wp-trac.css Outdated
Comment thread wordpress.org/public_html/style/trac/trac-security.js
Comment thread wordpress.org/public_html/style/trac/wp-trac.js Outdated
Brings trac/ in line with the formatting and lint rules from WordPress#734, ahead of
that PR, so the same files do not need touching again when it lands and the
assets only need deploying once.

Retires the jinja2 compatibility shim: its rules now live in wp-trac.css and
the templates no longer load the removed script and stylesheet. trac-search.js
goes with it, unused since its include was removed in r7275.

Builds markup through the DOM rather than by string concatenation in the
attachment preview, the reopen notice, the non-gardener type field and the
attachment autocomplete, and restores the preserved attribute matches by index
so a comment cannot shift the restore queue.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@obenland
obenland force-pushed the trac/style-refresh branch from 8948750 to 0767d83 Compare August 3, 2026 16:33
encloseSelection() is handed a raw DOM element from $textarea[0], and uses
setSelectionRange/selectionStart/value on it throughout. The jQuery-style
textarea.trigger( 'focus' ) therefore threw a TypeError and broke the PHP code
block toolbar button; restores textarea.focus().

.atwho-view .cur strong declared `font: 700`, which is not a valid font
shorthand — it requires at least a size and a family — so browsers dropped the
declaration. Uses font-weight instead.

Points the security reporting handbook link at HTTPS.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (2)

wordpress.org/public_html/style/trac/wp-trac.css:433

  • The removed wp-trac-jinja-compat.css previously hid both #tab_advanced and #tab_keybindings. If the intent is to keep the same Preferences tabs behavior ("#tabs carried over" in the PR description), #tab_keybindings should be hidden here as well.
/* Sessions are tied to WP.org logins; hide the anonymous "Advanced" session tab. */
#content.prefs #tabs #tab_advanced {
	display: none;
}

wordpress.org/public_html/style/trac/wp-trac.css:1671

  • Missing comma at the end of this selector line causes the selector list to be parsed incorrectly, so the bbPress hover color rule won’t apply as intended.
body.bbpress #content.build h2.config :visited

obenland and others added 2 commits August 3, 2026 12:03
The preferences tab rule hid both #tab_advanced and #tab_keybindings; only the
first survived the merge, so the Keyboard Shortcuts tab became visible again.

The attachment form hid its "Replace existing attachment of the same name"
options from non-gardeners, keyed off a body class that the removed shim set.
wp-trac.js already tracks gardener status, so it sets the class instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The refreshed file matched the scripts_version query instead, which armed a
function that had never fired. $.loadStyleSheet then requested Trac's own
stylesheets at URLs the page had not loaded, so a second copy of trac.css was
appended after wp-trac.css and Trac's rules won the cascade — visible as
fieldset shadows and unstyled toolbar buttons returning on comment preview.

Matching `v=` again restores the previous behaviour. Busting only the dynamic
loads would not have fixed caching regardless: Trac emits those stylesheet
links unversioned from htdocs_location, so the cached copy still paints first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@obenland
obenland force-pushed the trac/style-refresh branch from 1f08ebd to f4aafb5 Compare August 3, 2026 19:27
Trac's wikitoolbar.js gave each button an id up to 1.0.9, which is what these
rules and the PHP button's insertion point were written against. Since 1.6 it
sets `class="trac-wikitoolbar-<type>"` and no id, so every dashicon rule
matched nothing and the buttons rendered as empty boxes, and
`find( '#code' ).after()` had nothing to attach to, so the PHP code block
button was never added at all.

The `#code-php` rule stays as it is; that id is one we set ourselves.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (1)

wordpress.org/public_html/style/trac/trac-security.js:81

  • has_overlap() intends to strip non-letter characters before splitting into words, but the character class /[^a-z|\s]/g accidentally allows the | character (because | is literal inside []). This can prevent detection when users paste payload-like strings containing | separators.
		has_overlap( str, arr ) {
			const words = str
					.toLowerCase()
					.replace( /[^a-z|\s]/g, '' )
					.split( ' ' ),
				overlap = this.intersect( words, arr );

@bazza bazza closed this in 62c5515 Aug 3, 2026
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.

2 participants