Opened 2 months ago
Closed 7 weeks ago
#65497 closed enhancement (wontfix)
Replace unnecessary PHP comment with HTML comment in wp-admin/customize.php
| Reported by: | harishtewari | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Customize | Version: | 4.9 |
| Severity: | normal | Keywords: | has-patch reporter-feedback close |
| Cc: | Focuses: |
Description (last modified by )
In src/wp-admin/customize.php (around line 227 and 266), there is a PHP opening tag used solely for an inline comment:
<ul class="customize-pane-parent"><?php // Panels and sections are managed here via JavaScript ?></ul>
Since no PHP code is being executed, the PHP tag is unnecessary. This can be replaced with an HTML comment to improve code readability and maintainability.
WordPress coding standards generally prefer avoiding unnecessary PHP tags when no PHP code is being executed
Change History (7)
This ticket was mentioned in PR #12241 on WordPress/wordpress-develop by @harishtewari.
2 months ago
#1
#2
@
2 months ago
- Component General → Customize
- Description modified (diff)
- Summary Unnecessary PHP comment with HTML comment in wp-admin/customize.php → Replace unnecessary PHP comment with HTML comment in wp-admin/customize.php
- Type defect (bug) → enhancement
- Version 7.0 → 4.9
#3
follow-up:
↓ 5
@
2 months ago
@harishtewari thanks for the proposal. it’s worth pointing out that this change modifies the rendered page and leaves what was previously a private comment in the public view.
did you find that the PHP tag was problematic in some way, or dig up that the comments were supposed to be part of the rendered page?
#5
in reply to: ↑ 3
@
2 months ago
Replying to dmsnell:
@harishtewari thanks for the proposal. it’s worth pointing out that this change modifies the rendered page and leaves what was previously a private comment in the public view.
did you find that the PHP tag was problematic in some way, or dig up that the comments were supposed to be part of the rendered page?
+1 to this concern. To add some context that may help close the loop here:
The <?php // ... ?> tags aren't dead code — they're doing exactly what they should. A PHP comment is stripped on the server and never sent to the browser, whereas an HTML comment is emitted into the page output. So this change doesn't remove an "unnecessary" tag; it converts two private, developer-facing notes into public markup on every Customizer load. That's a behavior change, not a cleanup.
There's also a functional angle. Both <ul> elements (customize-pane-parent and customize-outer-pane-parent) are populated by JS via api.Section / api.Panel, and the second comment was committed in r41626 specifically with the note *"to avoid any
side-effect in api.Section."* An HTML comment is a real DOM node (childNodes/firstChild), so swapping it in reintroduces exactly the kind of side-effect that line was written to prevent. The empty-by-design output is intentional.
WordPress Coding Standards also don't call for removing inline PHP comment tags in templates — <?php // ... ?> as a server-only annotation inside markup is a long-standing, accepted idiom in core.
Given that the comments were added deliberately (r30102 and r41626) and the PHP tag isn't causing any problem, I'd suggest closing this as wontfix. And I don't think there's a change worth making here, but I'll leave the final call to the committers. Thanks for the proposal though, @harishtewari — it's a reasonable thing to question at first glance.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
https://core.trac.wordpress.org/ticket/65497
In
src/wp-admin/customize.php(around line 227 and 266), there is a PHP opening tag used solely for an inline comment:<ul class="customize-pane-parent"><?php Panels and sections are managed here via JavaScript ?></ul>
Since no PHP code is being executed, the PHP tag is unnecessary. This can be replaced with an HTML comment to improve code readability and maintainability.
WordPress coding standards generally prefer avoiding unnecessary PHP tags when no PHP code is being executed
Trac ticket:
## Use of AI Tools