-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponsive-screenshots-block.php
More file actions
71 lines (61 loc) · 2.09 KB
/
responsive-screenshots-block.php
File metadata and controls
71 lines (61 loc) · 2.09 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
Plugin Name: Responsive Screenshots Block
Plugin URI: https://wordpress.org/plugins/responsive-screenshots-block/
Description: A Gutenberg block to show off responsive, in-device screenshots of a website directly in the content.
Version: 1.0
Author: Alpha Particle
Author URI: https://alphaparticle.com
Text Domain: rs-block
License: GPL-3.0+
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
*/
// Exit if accessed directly.
defined('ABSPATH') || exit;
/**
* Enqueue block editor only JavaScript and CSS
*/
function rsblock_editor_scripts() {
$blockPath = '/assets/js/editor.blocks.js';
$editorStylePath = '/assets/css/blocks.editor.css';
// Enqueue the bundled block JS file
wp_enqueue_script(
'rsblock-js',
plugins_url( $blockPath, __FILE__ ),
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' ],
filemtime( plugin_dir_path(__FILE__) . $blockPath )
);
// Enqueue optional editor only styles
wp_enqueue_style(
'rsblock-blocks-editor-css',
plugins_url( $editorStylePath, __FILE__),
[],
filemtime( plugin_dir_path( __FILE__ ) . $editorStylePath )
);
}
// Hook scripts function into block editor hook
add_action( 'enqueue_block_editor_assets', 'rsblock_editor_scripts' );
/**
* Enqueue front end and editor JavaScript and CSS
*/
function rsblock_scripts()
{
$blockPath = '/assets/js/frontend.blocks.js';
// Make paths variables so we don't write em twice ;)
$stylePath = '/assets/css/blocks.style.css';
// Enqueue the bundled block JS file
wp_enqueue_script(
'rsblock-blocks-frontend-js',
plugins_url( $blockPath, __FILE__ ),
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api', 'wp-editor' ],
filemtime( plugin_dir_path(__FILE__) . $blockPath )
);
// Enqueue frontend and editor block styles
wp_enqueue_style(
'rsblock-blocks-css',
plugins_url($stylePath, __FILE__),
null,
filemtime(plugin_dir_path(__FILE__) . $stylePath )
);
}
add_action('enqueue_block_assets', 'rsblock_scripts');