Мой сайт работал нормально с версией WordPress 4.9.8, но после обновления версии до 5.4 функция загрузки CSV перестала работать. В журнале отладки отображается предупреждение Невозможно изменить информацию заголовка - заголовки уже отправлены . Пожалуйста, введите код go и помогите мне решить эту ошибку -
<?php if(isset($_GET['process'])){
if($_GET['process'] === 'download'){
global $wpdb;
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=refreshertracker.csv');
ob_end_clean();
$ptp_id = $_GET['topic'];
$pct_nm = $_GET['center'];
if(!empty($pct_nm))
$query = 'select * from wp_refresher_tracker where post_id ='.$ptp_id.' and centre_name = "'.$pct_nm.'"';
else
$query = 'select * from wp_refresher_tracker where post_id ='.$ptp_id;
//echo $query;
$presult = $wpdb->get_results($query);
//print_r($presult);
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
fputcsv($output, array('Sr_no', 'Name', 'EID', 'Center', 'Topic', 'Brand', 'LOB', 'Skill', 'TrainerName', 'Obt_Marks', 'Total_Marks','Score_%', 'ETime','RefDate'));
$cnt = 0;
$refdata = array();
foreach($presult as $prt){
$cnt=$cnt+1;
$refdata['Sr_no']= $cnt;
$refdata['Name']= $prt->name;
$refdata['EID']= $prt->eid;
$refdata['Center']= $prt->centre_name;
$refdata['Topic']= $prt->topic;
$refdata['Brand']= $prt->brand;
$refdata['LOB']= $prt->lob;
$refdata['Skill']= $prt->skill;
$refdata['TrainerName']= $prt->trainer;
$refdata['Obt_Marks']= $prt->obt_marks;
$refdata['Total_Marks']= $prt->total_marks;
$refdata['Score_%'] = round(($prt->obt_marks/$prt->total_marks)*100,2)." %";
$refdata['Time']= $prt->etime;
$refdata['RefDate']= $prt->Post_Pub_Date;;
//print_r($refdata);
fputcsv($output, $refdata);
}
fclose($output);
exit;
}}?>
Пожалуйста, помогите, поскольку я не могу найти проблему.