Skip to:

Attachments (2)

3078.diff (900 bytes) - added by milindmore22 7 years ago.
Added closing tags
3078-1.diff (10.0 KB) - added by milindmore22 7 years ago.
Patch will remove all closing tags from extra templates added new line to prevent Subversion from showing the "No new line at end of file" output.

Download all attachments as: .zip

Change History (11)

7 years ago

Added closing tags

#1 @milindmore22
7 years ago

  • Keywords has-patch added
  • Priority changed from normal to lowest
  • Severity changed from normal to trivial

Although It's unnecessary but all other templates have a closing tag at the end, submitted a patch to cover both files.

#2 @Otto42
7 years ago

Actually, end of PHP files should not have closing tags, because of spaces after then potentially creating header already sent errors.

#3 @johnjamesjacoby
7 years ago

Otto is correct. The correct thing to do here is remove all of the very last closing PHP tags, preferably with an empty line at the end to prevent Subversion from showing the "No new line at end of file" output.

#4 @netweb
7 years ago

  • Keywords good-first-bug needs-patch added; has-patch removed
  • Summary changed from Add missing ?> tag to Remove EOF closing ?> tags

I've renamed the ticket "Remove EOF closing ?> tags"

Previously #1850 / r3964

A quick search reveals he following "extras" templates all include closing EOF ?> PHP tags that we should remove:


7 years ago

Patch will remove all closing tags from extra templates added new line to prevent Subversion from showing the "No new line at end of file" output.

#5 @milindmore22
7 years ago

  • Keywords has-patch added; needs-patch removed

Submitted patch with removing all closing tag listed.

but PHP is an embeddable scripting language designed to allow you to embed logic in the form of PHP scripting into content, which is typically HTML. In that context, the opening and closing tags make sense, such as in WordPress' theme template files and all template files are having closing tags.


any thoughts on this?

#6 @netweb
7 years ago

I've just read #WP12307 / core:changeset:19712, see also #WP23505 core:changeset:28678 #WP30534 core:changeset:34887

And my take away summaries from that are:

  1. It is now (previously before the above WP ticket it was not) WordPress coding standard to exclude closing PHP tags on files that are not expected to be edited. That includes a theme's functions.php and wp-config.php.
  1. Omitting from the r19712 commit is any changes to themes, i.e wp-content/themes/*, as such at the time, and still till today twenty ten and eleven still contain closing tags

The PHP coding standards state:

"Omitting the closing PHP tag at the end of a file is preferred. If you use the tag, make sure you remove trailing whitespace."

And from the PHP manual:

"If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script."

I've created a new core ticket #WP40039 to discuss the removal of closing PHP tags from the bundled themes

#7 @johnjamesjacoby
7 years ago

  • Keywords commit added

Seems a-OK to commit -1.diff.

Should double check that it covers all of our template parts.

Thanks @milindmore22 for helping!

#8 @johnjamesjacoby
7 years ago

  • Owner set to johnjamesjacoby
  • Resolution set to fixed
  • Status changed from new to closed

In 6366:

General: Remove end-of-file ?> tags from extra templates.

These templates are theme drop-ins, and apparently were missed in previous clean-up efforts.

Props milindmore22. Fixes #3078.

#9 @netweb
7 years ago

In 6371:

General: Following [6366] use a single blank line for end-of-file extras templates.

See #3078.

Note: See TracTickets for help on using tickets.