当我试图使用块编辑器编辑或添加帖子/页面时,它会向我显示一些奇怪的警告,然后它们会像消失一样出现,但当我查看页面时,我发现它们仍然存在。警告仅在我使用主题时出现。
Note 1: 大多数警告在wp-admin
或wp-includes
文件夹,我根本没碰过。
Note 2: 我安装了classic editor,它运行得很好。
Warnings:
1- Warning: array_values() expects parameter 1 to be array, null given in E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\theme.php on line 3995
2- Warning: array_merge(): Expected parameter 2 to be an array, null given in E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\theme.php on line 3996
3- Warning: Cannot modify header information - headers already sent by (output started at E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\theme.php:3995) in E:\\Coding\\WordPress\\blog\\app\\public\\wp-admin\\admin-header.php on line 9
4- Warning: Cannot modify header information - headers already sent by (output started at E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\theme.php:3995) in E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\option.php on line 1050
5- Warning: Cannot modify header information - headers already sent by (output started at E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\theme.php:3995) in E:\\Coding\\WordPress\\blog\\app\\public\\wp-includes\\option.php on line 1051
最合适的回答,由SO网友:kuroyza 整理而成
我创建了一个页面,用户可以在其中检查受支持的帖子格式,问题是如果用户没有检查任何帖子格式,它会返回false,而不是返回包含“standard”的数组,如下所示return [\'standard\']
, 我只使用了关键字return
停止函数运行。
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);