<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
function boostify_blocks_add_new_block_category($block_categories, $editor_context)
{
    if (!empty($editor_context->post)) {
        array_unshift(
            $block_categories,
            array(
                'slug'  => 'boostify-blocks',
                'title' => __('Boostify', 'boostify-blocks'),
                'icon'  => null,
            ),
        );
    }
    return $block_categories;
}

add_filter('block_categories_all', 'boostify_blocks_add_new_block_category', 9999999, 2);

// 

function boostify_blocks_add_rest_method($endpoints)
{
    if (is_wp_version_compatible('5.5')) {
        return $endpoints;
    }

    foreach ($endpoints as $route => $handler) {
        if (isset($endpoints[$route][0])) {
            $endpoints[$route][0]['methods'] = [WP_REST_Server::READABLE, WP_REST_Server::CREATABLE];
        }
    }

    return $endpoints;
}
add_filter('rest_endpoints', 'boostify_blocks_add_rest_method');
