Inventory_Presser_Blocks

Inventory_Presser_Blocks

Description Description

Creates blocks


Top ↑

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',

Top ↑

Methods Methods