PluginProbe
Essential Widgets / 1.8
Essential Widgets v1.8
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 1.8, at includes/ew-block/index.php

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