This question already has an answer here:
Context: WordPress 4.5.2; PHP 5.x; Linux (probably, given directory structure)
At the risk of having this question marked as a duplicate of something else ...
A couple of years back I wrote a plugin to handle landing pages via a 404 handler. It's been working on a variety of client sites running relatively recent versions of WordPress. Today it was installed (from the zip used for everyone else) on a WordPress 4.0.11 site. Navigating to a landing page worked but only partially. One of the more important parts near the top of the plugin failed to function, viz
<?php
get_header();
$pos = strpos($_SERVER['REQUEST_URI'], "/lp/");
$headertext = 'HTTP/1.1 ' . (($pos !== false) ? '200 OK' : '404 Not Found');
header($headertext);
Looking in the error_log file gave (after a while of testing) many lines like
[07-Jun-2016 16:11:51 UTC] PHP Warning: Cannot modify header information - headers already sent by
(output started at /home/pp/public_html/wp-includes/class.wp-styles.php:237)
in /home/pp/public_html/wp-content/themes/pp/404.php on line 24
The item on line 24 of 404.php is, naturally enough, the header()
function call. What makes me curious is the first part: line 237 of wp-includes/class.wp-styles.php
is in the middle of nowhere -- in the comments above public function do_item( $handle, $group = false ) {
I encouraged the client to install a more recent version of WordPress in the expectation that the problem lay there. However, after updating the problem remained.
Now I have checked the plugin source for spaces after the ?>
markup and all that. Nevertheless, I'll have another look. Earlier entries in error_log have the wp-includes errors falling at another place in class.wp-styles.php
and also in wp-includes/general-template.php:2191
. Might actually regenerate the installer .zip, uninstall and reinstall.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire