Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#11379 closed defect (bug) (invalid)

Getting "Warning: Cannot modify header information - headers already sent by (output started at..." because of locale plugins

Reported by: waclawjacek's profile waclawjacek Owned by: nbachiyski's profile nbachiyski
Milestone: Priority: normal
Severity: major Version: 2.8.6
Component: I18N Keywords:
Focuses: Cc:

Description

I've written a plugin (to be put as wp-content/languages/pl_PL.php) providing additional localized features for the Polish translation of WordPress as I get "Warning: Cannot modify header information - headers already sent by (output started at..." on pages dealing with sessions (the reason is the filter). Here's the code:

<?php

/* wp-config.php modifications */
$wp_default_secret_key = 'wprowadz tutaj unikatowa fraze';

/* filters */
add_filter( 'date_i18n', 'date_declension' );

/* functions */
function date_declension( $date )
{

        $month_names = array( '%Styczeń%', '%Luty%', '%Marzec%', '%Kwiecień%', '%Maj%', '%Czerwiec%', '%Lipiec%', '%Sierpień%', '%Wrzesień%', '%Październik%', '%Listopad%', '%Grudzień%' );
        $month_names_genitive = array( 'stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia' );
        $month_names_locative = array( 'styczniu', 'lutym', 'marcu', 'kwietniu', 'maju', 'czerwcu', 'lipcu', 'sierpniu', 'wrześniu', 'październiku', 'listopadzie', 'grudniu' );

        /* "1 Styczeń..." -> "1 stycznia..." */
        $pattern = '%^\d{1,2}\ \w+%';
        if ( preg_match( $pattern, $date ) == 1 ) return preg_replace( $month_names, $month_names_genitive, $date );

        return $date;
}

?>

Change History (2)

#1 @Denis-de-Bernardy
15 years ago

  • Milestone Unassigned deleted
  • Resolution set to invalid
  • Status changed from new to closed

you probably have trailing spaces at the end of your php file.

#2 @waclawjacek
15 years ago

Oh, right! I forgot it counts as HTML data. :) Thanks!

Note: See TracTickets for help on using tickets.