PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.6.1
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.6.1
3.1.0 3.0.0 2.13.2 2.13.1 2.13.0 trunk 1.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.1 2.5.3 2.5.4 2.5.5 2.6.1 All 56 releases
slider-blocks / includes / classes / class-register-blocks.php

class-register-blocks.php in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 2.6.1, at includes/classes/class-register-blocks.php

67 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Register Blocks
4 * @package GutSliderBlocks
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
8
9 if( ! class_exists( 'GutSlider_Register_Blocks' ) ) {
10
11 class GutSlider_Register_Blocks {
12
13 /**
14 * Constructor
15 * return void
16 */
17 public function __construct() {
18 add_action( 'init', [ $this, 'register_blocks' ] );
19 }
20
21 /**
22 * Register Blocks
23 * return void
24 */
25 public function register_blocks() {
26 $blocks = [
27 'content-slider',
28 'any-content',
29 'testimonial-slider',
30 'post-slider',
31 'photo-carousel',
32 'logo-carousel',
33 'before-after'
34 ];
35
36 $active_blocks = [];
37
38 $block_options = [
39 'content-slider' => 'gut_fixed_content_slider',
40 'any-content' => 'gut_any_content_slider',
41 'testimonial-slider' => 'gut_testimonial_slider',
42 'post-slider' => 'gut_post_slider',
43 'photo-carousel' => 'gut_photo_carousel',
44 'logo-carousel' => 'gut_logo_carousel',
45 'before-after' => 'gut_before_after_slider'
46 ];
47
48 foreach ($blocks as $block) {
49 $option_name = $block_options[$block];
50 $block_enabled = get_option($option_name, true);
51
52 if ($block_enabled) {
53 $active_blocks[] = $block;
54 }
55 }
56
57 if ( ! empty( $active_blocks ) ) {
58 foreach ( $active_blocks as $block ) {
59 register_block_type( trailingslashit( GUTSLIDER_DIR ) . '/build/blocks/' . $block);
60 }
61 }
62 }
63 }
64
65 }
66
67 new GutSlider_Register_Blocks(); // Initialize the class