PluginProbe
Essential Widgets / 3.0
Essential Widgets v3.0
3.2.1 3.3 3.2 trunk 1.0.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 1.9 2.0 2.1 2.2 All 31 releases
essential-widgets / includes / ew-block / index.php

index.php in Essential Widgets 3.0, at includes/ew-block/index.php

87 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 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly.
5 }
6
7 if (!class_exists('EW_Blocks')) :
8
9 class EW_Blocks
10 {
11
12 /**
13 * @var null
14 */
15 private static $instance = null;
16
17 public function __construct()
18 {
19 // Hook: Editor assets.
20 add_action('enqueue_block_editor_assets', [$this, 'ew_block_assets']);
21 // Add custom block category
22 add_filter(
23 'block_categories_all',
24 function ($categories, $post) {
25 return array_merge(
26 $categories,
27 array(
28 array(
29 'slug' => 'ew-block',
30 'title' => __('EW Blocks', 'essential-widgets'),
31 ),
32 )
33 );
34 },
35 10,
36 2
37 );
38
39 // Load all the blocks
40 $this->load_blocks();
41 }
42
43 public function ew_block_assets()
44 {
45 // Scripts.
46 wp_enqueue_script(
47 'ew-block-js', // Handle.
48 plugins_url('ew-block/blocks.build.js', dirname(__FILE__)), // Block.build.js: We register the block here. Built with Webpack.
49 array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor') //
50 );
51
52 // Styles.
53 wp_enqueue_style(
54 'ew-block-editor-css', // Handle.
55 plugins_url('ew-block/blocks.editor.build.css', dirname(__FILE__)), // Block editor CSS.
56 array('wp-edit-blocks') // Dependency to include the CSS after it.
57 );
58 } // End function catch_guten_cgb_editor_assets().
59
60 public function load_blocks()
61 {
62 require_once 'blocks/ew-archive/index.php';
63 require_once 'blocks/ew-author/index.php';
64 require_once 'blocks/ew-category/index.php';
65 require_once 'blocks/ew-page/index.php';
66 require_once 'blocks/ew-post/index.php';
67 require_once 'blocks/ew-tags/index.php';
68 require_once 'blocks/ew-menu/index.php';
69 }
70
71 /**
72 * @return EW_Blocks|null
73 */
74 public static function instance()
75 {
76 if (is_null(self::$instance)) {
77 self::$instance = new self();
78 }
79
80 return self::$instance;
81 }
82 }
83
84 EW_Blocks::instance();
85
86 endif;
87