-
Notifications
You must be signed in to change notification settings - Fork 2
/
rmb-recipe-block.php
54 lines (49 loc) · 1.65 KB
/
rmb-recipe-block.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Plugin Name: Recipe Block
* Plugin URI: https://github.com/ryelle/rmb-recipe-block
* Description: A block for displaying recipe content on your site.
* Version: 1.1.2
* Author: Kelly Choyce-Dwan
* Author URI: https://ryelle.codes
* Text Domain: rmb-recipe-block
*
* @package rmb-recipe-block
*/
defined( 'ABSPATH' ) || die();
define( 'RMB_RECIPE_VERSION', '1.1.2' );
/**
* Load up the assets if the assets file exists
*/
function rmb_recipe_initialize() {
$file_exists = file_exists( plugin_dir_path( __FILE__ ) . '/build/recipe-block.asset.php' );
if ( $file_exists ) {
add_action( 'init', 'rmb_recipe_register_block' );
}
}
add_action( 'plugins_loaded', 'rmb_recipe_initialize' );
/**
* Register the recipe block and its scripts.
*/
function rmb_recipe_register_block() {
$path = plugin_dir_path( __FILE__ ) . '/build/recipe-block.js';
$deps_path = plugin_dir_path( __FILE__ ) . '/build/recipe-block.asset.php';
$script_info = require $deps_path;
wp_register_script(
'recipe-block',
plugins_url( 'build/recipe-block.js', __FILE__ ),
$script_info['dependencies'],
$script_info['version']
);
wp_set_script_translations( 'recipe-block', 'rmb-recipe-block' );
wp_register_style(
'recipe-block',
plugins_url( 'build/recipe-block.css', __FILE__ ),
array(),
$script_info['version']
);
register_block_type( plugin_dir_path( __FILE__ ) . '/assets/js' );
register_block_type( plugin_dir_path( __FILE__ ) . '/assets/js/blocks/recipe-directions' );
register_block_type( plugin_dir_path( __FILE__ ) . '/assets/js/blocks/recipe-ingredients' );
register_block_type( plugin_dir_path( __FILE__ ) . '/assets/js/blocks/recipe-meta' );
}