Inventory_Presser_Blocks
On This Page
Description Description
Creates blocks
Source Source
File: includes/class-blocks.php
class Inventory_Presser_Blocks { /** * Adds a block category to hold all our blocks * * @param array $block_categories * @return array */ public function add_category( $block_categories ) { return array_merge( $block_categories, array( array( 'slug' => 'inventory-presser', 'title' => __( 'Inventory Presser', 'inventory-presser' ), 'icon' => 'dashicons-admin-network', // it's a key. ), ) ); } /** * Adds hooks * * @return void */ public function add_hooks() { add_action( 'init', array( $this, 'register_block_types' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) ); add_filter( 'block_categories_all', array( $this, 'add_category' ), 10, 1 ); } /** * Enqueues block editor assets * * @return void */ public function enqueue_block_editor_assets() { wp_enqueue_script( 'invp-blocks' ); } /** * Registers block types * * @return void */ public function register_block_types() { if ( ! function_exists( 'register_block_type' ) ) { // running on WordPress < 5.0.0, no blocks for you. return; } register_block_type( dirname( INVP_PLUGIN_FILE_PATH ) . '/build/blocks/year-make-model-and-trim' ); // These are meta keys that can be managed by a simple text box. $simple_meta_keys = array( 'body_style', 'color', 'down_payment', 'engine', 'interior_color', 'last_modified', 'make', 'model', 'msrp', 'odometer', 'payment', 'price', 'stock_number', 'title_status', 'transmission_speeds',
Expand full source codeCollapse full source codeView on Github
Methods Methods
- add_category — Adds a block category to hold all our blocks
- add_hooks — Adds hooks
- register_block_types — register_block_types