When I am trying to edit or add a post/page using block editor, it shows me some weird warnings then they act like they disappear, but when I inspect the page, I see that they are still there. The warnings appear just when I am using my theme.
Note 1: Most of the warnings are eather in the wp-admin or wp-includes folder, which I haven’t touched at all.
Note 2: I’ve installed classic editor and it works just fine.
Warnings:
1-
Warning: array_values() expects parameter 1 to be array, null given in E:CodingWordPressblogapppublicwp-includestheme.php on line 39952-
Warning: array_merge(): Expected parameter 2 to be an array, null given in E:CodingWordPressblogapppublicwp-includestheme.php on line 39963-
Warning: Cannot modify header information - headers already sent by (output started at E:CodingWordPressblogapppublicwp-includestheme.php:3995) in E:CodingWordPressblogapppublicwp-adminadmin-header.php on line 94-
Warning: Cannot modify header information - headers already sent by (output started at E:CodingWordPressblogapppublicwp-includestheme.php:3995) in E:CodingWordPressblogapppublicwp-includesoption.php on line 10505-
Warning: Cannot modify header information - headers already sent by (output started at E:CodingWordPressblogapppublicwp-includestheme.php:3995) in E:CodingWordPressblogapppublicwp-includesoption.php on line 1051
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I’ve made a page where the user can check the supported post formats, and the problem was that in case the user haven’t checked any post format it returns false, and instead of returning an array that contains ‘standard’ like the following return ['standard'], I used only the keyword return to stop the function from running.
Here is what I am talking about:
function get_supported_post_formats(){
$options = get_option('post-supports-handler');
if (empty($options)) {
return ['standard'];
}
$formats = [
'standard',
'aside',
'gallery',
'link',
'image',
'quote',
'video',
'status',
'audio',
'chat',
];
$output = [];
foreach ($formats as $format) {
$output[] = (@$options[$format] == '1' ? $format : '');
}
return $output;
}
$output = get_supported_post_formats();
add_theme_support('post-formats', $output);
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0