-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor-ui-tools.php
More file actions
87 lines (77 loc) · 2.22 KB
/
Copy patheditor-ui-tools.php
File metadata and controls
87 lines (77 loc) · 2.22 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Plugin Name: Editor UI Tools
* Plugin URI: https://github.com/murshed/editor-ui-tools
* Description: Tools for the WordPress Block Editor. Pin sidebars, toggle sidebar position (Left/Right), and Expand/Collapse All items in Document Overview.
* Version: 1.0.0
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: FahimMurshed
* Author URI: https://fahimm.com
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: editor-ui-tools
* Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Define Plugin Constants
define( 'EDITOR_UI_TOOLS_VERSION', '1.0.0' );
define( 'EDITOR_UI_TOOLS_FILE', __FILE__ );
define( 'EDITOR_UI_TOOLS_PATH', plugin_dir_path( __FILE__ ) );
define( 'EDITOR_UI_TOOLS_URL', plugin_dir_url( __FILE__ ) );
/**
* Main Plugin Class
*/
final class Editor_UI_Tools {
/**
* Single instance of the class.
*
* @var Editor_UI_Tools|null
*/
private static $instance = null;
/**
* Main Instance.
*
* @return Editor_UI_Tools
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
private function __construct() {
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ) );
}
/**
* Enqueue Block Editor Assets.
*/
public function enqueue_editor_assets() {
$css_file = file_exists( EDITOR_UI_TOOLS_PATH . 'assets/css/editor-ui-tools.min.css' )
? 'editor-ui-tools.min.css'
: 'editor-ui-tools.css';
$js_file = file_exists( EDITOR_UI_TOOLS_PATH . 'assets/js/editor-ui-tools.min.js' )
? 'editor-ui-tools.min.js'
: 'editor-ui-tools.js';
wp_enqueue_style(
'editor-ui-tools-css',
EDITOR_UI_TOOLS_URL . 'assets/css/' . $css_file,
array( 'wp-components' ),
EDITOR_UI_TOOLS_VERSION
);
wp_enqueue_script(
'editor-ui-tools-js',
EDITOR_UI_TOOLS_URL . 'assets/js/' . $js_file,
array( 'wp-element', 'wp-components', 'wp-data', 'wp-dom-ready' ),
EDITOR_UI_TOOLS_VERSION,
true
);
}
}
// Initialize Plugin
Editor_UI_Tools::get_instance();