Block editors annoying warnings

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:\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

Topic block-editor warnings theme-development posts themes Wordpress

Category Web


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);

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.