# slider-blocks/2.2.2/includes/classes/class-blocks-category.php

GutSlider – All in One Slider and Carousel Blocks for Gutenberg, version 2.2.2. 45 lines.

- Page: https://pluginprobe.com/plugins/slider-blocks/2.2.2/code/includes/classes/class-blocks-category.php
- Raw: https://pluginprobe.com/plugins/slider-blocks/2.2.2/raw/includes/classes/class-blocks-category.php
- Modified: 2023-10-24T15:52:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/slider-blocks/2.2.2/code/includes/classes/class-blocks-category.php#L10-L20`.

```php
<?php 
/**
 * Register Blocks Category
 * @package GutSliderBlocks
 */

 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.

 if( ! class_exists( 'GutSlider_Blocks_Category' ) ) {

    class GutSlider_Blocks_Category {

        /**
         * Constructor
         * return void 
         */
        public function __construct() {
            if( version_compare( $GLOBALS['wp_version'], '5.7', '<' ) ) {
                add_filter( 'block_categories', [ $this, 'register_block_category' ], 10, 2, 9999 );
            } else {
                add_filter( 'block_categories_all', [ $this, 'register_block_category' ], 10, 2, 9999 );
            }
        }

        /**
         * Register Block Category
         * return array
         */
        public function register_block_category( $categories, $post ) {
            return array_merge(
                array(
                    array(
                        'slug'  => 'slider-blocks',
                        'title' => __( 'GutSlider Blocks', 'slider-blocks' ),
                    ),
                ),
                $categories,
            );
        }

    }

 }

    new GutSlider_Blocks_Category();    // Initialize the class
```
