3 * Plugin Name: danixland gravatar block
4 * Description: Simple Gutemberg Block to insert a gravatar inside a post or page.
6 * Author: Danilo 'danix' Macri
7 * Author URI: https://danix.xyz
8 * License: GPL-2.0-or-later
9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 * Text Domain: dnxvatar
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 * Registers all block assets so that they can be enqueued through the block editor
22 * in the corresponding context.
24 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
26 function dnxvatar_danixland_gravatar_block_init() {
27 $dir = dirname( __FILE__
);
29 $script_asset_path = "$dir/build/index.asset.php";
30 if ( ! file_exists( $script_asset_path ) ) {
32 'You need to run `npm start` or `npm run build` for the "dnxvatar/danixland-gravatar" block first.'
35 $index_js = 'build/index.js';
36 $script_asset = require( $script_asset_path );
38 'dnxvatar-danixland-gravatar-block-editor',
39 plugins_url( $index_js, __FILE__
),
40 $script_asset['dependencies'],
41 $script_asset['version']
43 wp_set_script_translations( 'dnxvatar-danixland-gravatar-block-editor', 'dnxvatar' );
45 $editor_css = 'build/index.css';
47 'dnxvatar-danixland-gravatar-block-editor',
48 plugins_url( $editor_css, __FILE__
),
50 filemtime( "$dir/$editor_css" )
53 $style_css = 'build/style-index.css';
55 'dnxvatar-danixland-gravatar-block',
56 plugins_url( $style_css, __FILE__
),
58 filemtime( "$dir/$style_css" )
61 register_block_type( 'dnxvatar/danixland-gravatar', array(
62 'editor_script' => 'dnxvatar-danixland-gravatar-block-editor',
63 'editor_style' => 'dnxvatar-danixland-gravatar-block-editor',
64 'style' => 'dnxvatar-danixland-gravatar-block',
67 add_action( 'init', 'dnxvatar_danixland_gravatar_block_init' );