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

90 lines 2.1 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 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- EW_ is this plugin's abbreviated prefix; wrapped in class_exists() guard.
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-block-editor'),
50 ESSENTIAL_WIDGETS_VERSION,
51 true
52 );
53
54 // Styles.
55 wp_enqueue_style(
56 'ew-block-editor-css', // Handle.
57 plugins_url('ew-block/blocks.editor.build.css', dirname(__FILE__)), // Block editor CSS.
58 array('wp-edit-blocks'), // Dependency to include the CSS after it.
59 ESSENTIAL_WIDGETS_VERSION
60 );
61 } // End function catch_guten_cgb_editor_assets().
62
63 public function load_blocks()
64 {
65 require_once 'blocks/ew-archive/index.php';
66 require_once 'blocks/ew-author/index.php';
67 require_once 'blocks/ew-category/index.php';
68 require_once 'blocks/ew-page/index.php';
69 require_once 'blocks/ew-post/index.php';
70 require_once 'blocks/ew-tags/index.php';
71 require_once 'blocks/ew-menu/index.php';
72 }
73
74 /**
75 * @return EW_Blocks|null
76 */
77 public static function instance()
78 {
79 if (is_null(self::$instance)) {
80 self::$instance = new self();
81 }
82
83 return self::$instance;
84 }
85 }
86
87 EW_Blocks::instance();
88
89 endif;
90