-
Notifications
You must be signed in to change notification settings - Fork 3
/
block-navigation.php
66 lines (60 loc) · 1.3 KB
/
block-navigation.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
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Plugin Name: Block Navigation
* Plugin URI: https://wordpress.org/plugins/block-navigation/
* Description: Block Navigation sidebar panel for the new Block editor.
* Author: melonpan
* Version: 4.1.1
* License: GPL3+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
*/
namespace BLOCKNAVIGATION;
// Exit if accessed directly.
if (!defined("ABSPATH")) {
exit();
}
/**
* Enqueue the plugin styles and scripts.
*
* @since 1.0.0
*/
\add_action("enqueue_block_editor_assets", __NAMESPACE__ . '\enqueue');
function enqueue()
{
$plugin_name = "block-navigation";
$plugin_version = "4.1.1";
$dist_dir = \plugins_url("dist/", __FILE__);
// This check will prevent the script from loading in a screen
// that is not a post/cpt edit screen, like the widgets screen.
if (
function_exists("get_current_screen") &&
empty(\get_current_screen()->post_type)
) {
return;
}
\wp_enqueue_style(
$plugin_name,
$dist_dir . $plugin_name . ".css",
[],
$plugin_version
);
\wp_enqueue_script(
$plugin_name,
$dist_dir . $plugin_name . ".js",
[
"lodash",
"wp-block-editor",
"wp-blocks",
"wp-components",
"wp-data",
"wp-edit-post",
"wp-element",
"wp-hooks",
"wp-i18n",
"wp-plugins",
"wp-rich-text",
],
$plugin_version,
true // Enqueue in the footer.
);
}