Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "Headers already sent" error in PHP #1114

Merged
merged 2 commits into from
Feb 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ function qtranxf_detect_language_front( &$url_info ) {
function qtranxf_setcookie_language( $lang, $cookie_name, $cookie_path ) {
global $q_config;

// Sometimes wp_cron.php SEEMS to be the source of headers being sent prematurely.
if ( headers_sent() && wp_doing_cron() ) {
return;
}

// SameSite only available with options API from PHP 7.3.0
if ( version_compare( PHP_VERSION, '7.3.0' ) >= 0 ) {
setcookie( $cookie_name, $lang, [
Expand Down