Inventory_Presser_Blocks::register_block_types()

register_block_types

Description Description

Registers block types


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-blocks.php

	function register_block_types() {
		if ( ! function_exists( 'register_block_type' ) ) {
			// running on WordPress < 5.0.0, no blocks for you
			return;
		}

		$asset_file = include plugin_dir_path( INVP_PLUGIN_FILE_PATH ) . 'build/index.asset.php';

		wp_enqueue_script(
			'invp-blocks',
			plugins_url( 'build/index.js', INVP_PLUGIN_FILE_PATH ),
			$asset_file['dependencies'],
			$asset_file['version']
		);

		$settings = INVP::settings();

		// Provide the vehicle post type meta keys and prefix to JavaScript
		wp_add_inline_script(
			'invp-blocks',
			'const invp_blocks = ' . wp_json_encode(
				array(
					'keys'                        => INVP::keys_and_types(),
					'meta_prefix'                 => INVP::meta_prefix(),
					'use_carfax'                  => $settings['use_carfax'],
					'use_carfax_provided_buttons' => $settings['use_carfax_provided_buttons'],
				)
			),
			'before'
		);
	}