Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 90
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
BlockStyles
0.00% covered (danger)
0.00%
0 / 90
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 register_block_styles
0.00% covered (danger)
0.00%
0 / 89
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3namespace NewfoldLabs\WP\Module\Patterns;
4
5/**
6 * Class BlockStyles
7 *
8 * Registers custom block styles for the WordPress block editor.
9 * Provides additional styling options for core blocks.
10 */
11class BlockStyles {
12
13    /**
14     * Constructor to hook into WordPress.
15     */
16    public function __construct() {
17        add_action( 'init', array( $this, 'register_block_styles' ) );
18    }
19
20    /**
21     * Register custom block styles for the core/group block.
22     */
23    public function register_block_styles() {
24
25        $image_styles = array(
26            array(
27                'name'  => 'nfd-dots-bottom-left',
28                'label' => __( 'Dots BL', 'nfd-wonder-blocks' ),
29            ),
30            array(
31                'name'  => 'nfd-waves-bottom-left',
32                'label' => __( 'Waves BL', 'nfd-wonder-blocks' ),
33            ),
34            array(
35                'name'  => 'nfd-dots-bottom-right',
36                'label' => __( 'Dots BR', 'nfd-wonder-blocks' ),
37            ),
38            array(
39                'name'  => 'nfd-waves-bottom-right',
40                'label' => __( 'Waves BR', 'nfd-wonder-blocks' ),
41            ),
42            array(
43                'name'  => 'nfd-dots-top-left',
44                'label' => __( 'Dots TL', 'nfd-wonder-blocks' ),
45            ),
46            array(
47                'name'  => 'nfd-waves-top-left',
48                'label' => __( 'Waves TL', 'nfd-wonder-blocks' ),
49            ),
50            array(
51                'name'  => 'nfd-dots-top-right',
52                'label' => __( 'Dots TR', 'nfd-wonder-blocks' ),
53            ),
54            array(
55                'name'  => 'nfd-waves-top-right',
56                'label' => __( 'Waves TR', 'nfd-wonder-blocks' ),
57            ),
58        );
59
60        $theme_styles = array(
61            array(
62                'name'  => 'nfd-theme-white',
63                'label' => __( 'White', 'nfd-wonder-blocks' ),
64            ),
65            array(
66                'name'  => 'nfd-theme-light',
67                'label' => __( 'Light', 'nfd-wonder-blocks' ),
68            ),
69            array(
70                'name'  => 'nfd-theme-dark',
71                'label' => __( 'Dark', 'nfd-wonder-blocks' ),
72            ),
73            array(
74                'name'  => 'nfd-theme-darker',
75                'label' => __( 'Darker', 'nfd-wonder-blocks' ),
76            ),
77            array(
78                'name'  => 'nfd-theme-primary',
79                'label' => __( 'Primary', 'nfd-wonder-blocks' ),
80            ),
81            array(
82                'name'  => 'nfd-theme-primary-15',
83                'label' => __( 'Primary Light', 'nfd-wonder-blocks' ),
84            ),
85        );
86
87        $heading_styles = array(
88            array(
89                'name'  => 'nfd-heading-boxed',
90                'label' => __('Boxed', 'nfd-wonder-blocks'),
91            ),
92            array(
93                'name'  => 'nfd-heading-highlight',
94                'label' => __('Highlight', 'nfd-wonder-blocks'),
95            ),
96            array(
97                'name'  => 'nfd-heading-underline',
98                'label' => __('Underline', 'nfd-wonder-blocks'),
99            )
100        );
101
102        foreach ( $image_styles as $image_style ) {
103            register_block_style(
104                array( 'core/group', 'core/image' ),
105                $image_style
106            );
107        }
108
109        foreach ( $theme_styles as $theme_style ) {
110            register_block_style(
111                'core/group',
112                $theme_style
113            );
114        }
115
116        foreach ( $heading_styles as $heading_style ) {
117            register_block_style(
118                'core/heading',
119                $heading_style
120            );
121        }
122    }
123}