• I found an inability to write a cookie in a theme template file and traced the WP startup from index.php through my theme, to find where output was getting generated. There are a couple of files in the WP core that are generating whitespace:

    wp-blog-header.php
    wp-load.php
    wp-trackback.php
    wp-includes/template-loader.php

    I recommend removing the closing PHP tag, per the Zend coding standard:

    For files that contain only PHP code, the closing tag (“?>”) is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing white space into the response.

    I searched on the bug trac but couldn’t find this one. Should I submit it? Or can an admin confirm? Thanks –

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I think it would fall under this: http://core.trac.wordpress.org/ticket/10633

    So that would be a won’t fix.

    Thread Starter salientdigital

    (@salientdigital)

    Interesting… from the thread on that bug report, dd32 said:

    Whitespace immediately following a ?> is ignored by PHP and not rendered, However, Multiple new lines are not ignored (Single is fine, multiple is not).

    I wonder where that information comes from.

    Anyway I just set up a test with 3 simple PHP files and verified this is indeed the case on 5.3.6 however I am surprised that the WP Core devs wouldn’t want the cleanest code to the highest standard possible.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I think the problem is it’s not an all around standard. The way I learned in school was that whenever possible, you END your code with a closing tag, if you used an opening tag. Also not everyone uses Zend framework 😉

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Trailing whitespace in WP Core Files’ is closed to new replies.