| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 |
|
| 4 |
if ( ! class_exists( 'ewdufaqPatterns' ) ) { |
| 5 |
/** |
| 6 |
* Class to handle plugin Gutenberg blocks |
| 7 |
* |
| 8 |
* @since 2.1.16 |
| 9 |
*/ |
| 10 |
class ewdufaqPatterns { |
| 11 |
|
| 12 |
/** |
| 13 |
* Add hooks |
| 14 |
* @since 2.1.16 |
| 15 |
*/ |
| 16 |
public function __construct() { |
| 17 |
|
| 18 |
add_action( 'init', array( $this, 'ewd_ufaq_add_pattern_category' ) ); |
| 19 |
add_action( 'init', array( $this, 'ewd_ufaq_add_patterns' ) ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Register block patterns |
| 24 |
* @since 2.1.16 |
| 25 |
*/ |
| 26 |
public function ewd_ufaq_add_patterns() { |
| 27 |
|
| 28 |
$block_patterns = array( |
| 29 |
'faqs', |
| 30 |
'featured-faqs', |
| 31 |
'search', |
| 32 |
'submit', |
| 33 |
); |
| 34 |
|
| 35 |
foreach ( $block_patterns as $block_pattern ) { |
| 36 |
$pattern_file = EWD_UFAQ_PLUGIN_DIR . '/includes/patterns/' . $block_pattern . '.php'; |
| 37 |
|
| 38 |
register_block_pattern( |
| 39 |
'ultimate-faqs/' . $block_pattern, |
| 40 |
require $pattern_file |
| 41 |
); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Create a new category of block patterns to hold our pattern(s) |
| 47 |
* @since 2.1.16 |
| 48 |
*/ |
| 49 |
public function ewd_ufaq_add_pattern_category() { |
| 50 |
|
| 51 |
register_block_pattern_category( |
| 52 |
'ewd-ufaq-block-patterns', |
| 53 |
array( |
| 54 |
'label' => __( 'Ultimate FAQs', 'ultimate-faqs' ) |
| 55 |
) |
| 56 |
); |
| 57 |
} |
| 58 |
} |
| 59 |
} |