PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 1.0
bBlocks – Essential Gutenberg Blocks & Patterns Collection v1.0
2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 106 releases
b-blocks / src / init.php

init.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection 1.0, at src/init.php

52 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function b_blocks_init() {
4 // Custom Block Category
5 function b_blocks_category( $categories ) {
6 return array_merge( [
7 array(
8 'slug' => 'bBlocks',
9 'title' => 'B Blocks',
10 ),
11 ], $categories );
12 }
13 add_filter( 'block_categories', 'b_blocks_category', 10, 2 );
14
15 // Register block styles for both frontend + backend.
16 wp_register_style( 'b_blocks-style-css', plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), is_admin() ? array( 'wp-editor' ) : null, null );
17
18 // Register block editor script for backend.
19 wp_register_script( 'b_blocks-js', plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-components', 'wp-block-editor', 'wp-api' ), null, true );
20
21 // Register block editor styles for backend.
22 wp_register_style( 'b_blocks-editor-css', plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), array( 'wp-edit-blocks' ), null );
23
24 // WP Localized globals. Use dynamic PHP stuff in JavaScript via `cgbGlobal` object.
25 wp_localize_script(
26 'b_blocks-js',
27 'bBlocksAdmin', // Array containing dynamic data for a JS Global.
28 [
29 'pluginDirPath' => plugin_dir_path( __DIR__ ),
30 'pluginDirUrl' => plugin_dir_url( __DIR__ ),
31 // Add more data here that you want to access from `cgbGlobal` object.
32 'siteUrl' => get_site_url(),
33 ]
34 );
35
36 // Register Gutenberg block on server-side.
37 register_block_type( 'wasek/b-blocks', array(
38 'style' => 'b_blocks-style-css',
39 'editor_script' => 'b_blocks-js',
40 'editor_style' => 'b_blocks-editor-css',
41 ) );
42 }
43 add_action( 'init', 'b_blocks_init' );
44
45 // Posts Block
46 require 'posts.php';
47 // require 'advance-posts.php';
48
49 function b_blocks_after_setup_theme() {
50 add_theme_support( 'align-wide' );
51 }
52 add_action( 'after_setup_theme', 'b_blocks_after_setup_theme' );