PluginProbe
Countdown Timer Block – build urgency for events and launches / 1.3.0
Countdown Timer Block – build urgency for events and launches v1.3.0
1.3.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 32 releases
countdown-time / includes / pattern.php

pattern.php in Countdown Timer Block – build urgency for events and launches 1.3.0, at includes/pattern.php

40 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace CTB;
3
4 if ( !defined( 'ABSPATH' ) ) { exit; }
5
6 class Pattern{
7 public function __construct(){
8 add_action('init', [$this, 'onPluginsLoaded']);
9 }
10
11 function onPluginsLoaded(){
12 $patterns = wp_json_file_decode( __DIR__ . '/pattern.json', [ 'associative' => true ] );
13 $patterns = ctbIsPremium() ? $patterns : array_filter( $patterns, function( $item ) {
14 return !isset($item['pro']) || !$item['pro'];
15 } );
16
17 // Register Pattern Category
18 if ( function_exists( 'register_block_pattern_category' ) ) {
19 register_block_pattern_category( 'ctbPattern', [ 'label' => __( 'Countdown Time', 'countdown-time' ) ] );
20 }
21
22 // Register Pattern
23 if ( !empty( $patterns ) ) {
24 foreach ( $patterns as $pattern ) {
25 if ( function_exists( 'register_block_pattern' ) ) {
26 register_block_pattern( $pattern['name'], [
27 'title' => $pattern['title'],
28 'content' => $pattern['content'],
29 'description' => $pattern['description'],
30 'categories' => [ 'ctbPattern' ],
31 'keywords' => $pattern['keywords'],
32 'blockTypes' => $pattern['blockTypes'],
33 'viewportWidth' => 1200
34 ] );
35 }
36 }
37 }
38 }
39 }
40 new Pattern();