Quantcast
Channel: WordPress.org Forums » [Native Gettext for Wordpress] Support
Viewing all articles
Browse latest Browse all 4

headers already sent in …

$
0
0

Replies: 3

This is really neat. Thank you @colinleroy!

Only one warning reappears sometimes.
PHP Warning: Cannot modify header information - headers already sent in .../plugins/native-gettext/classes/class-native-mo.php on line 119

And right now I’m not able to reproduce triggering this warning. Unlikely.

So I thought about, what could be the reason, had a look into line 119 and so on and came up with:

add_filter( 'override_load_textdomain', array( $this, 'nltd_load_textdomain_override' ), 0, 3 );

Because all of the plugins logic happens inside the running filter hook, we’re not allowed to output anything here, even headers. But what if you use wp_headers instead?

I tested it replacing your existing line 119 by the following lines, what – indeed – is an ugly hack, but worked.

add_filter( 'wp_headers', function ( array $headers ) : array
{
    $headers[] = "X-Native-Gettext: 1";
    return $headers;
} );

What do you think?

  • This topic was modified 1 year, 11 months ago by Carsten Bach.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images