-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheditorskit-typography-addon.php
108 lines (96 loc) · 3.01 KB
/
editorskit-typography-addon.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Plugin Name: Editorskit Typography Addon
* Description: (Deprecated) Editorskit typography addon lets you apply typography on blocks and global level.
* Requires at least: 5.8
* Requires PHP: 7.0
* Version: 1.0.1
* Author: Munir Kamal
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: editorskit-typography-addon
*
*/
define('EDITORSKIT_TYPOGRAPHY_ADDON_URL', plugin_dir_url(__FILE__));
define('EDITORSKIT_TYPOGRAPHY_ADDON_DIR', plugin_dir_path(__FILE__));
class EditorsKit_Typography_Addon
{
private static $instance;
public static function instance()
{
if (!isset(self::$instance) && !(self::$instance instanceof EditorsKit_Typography_Addon)) {
self::$instance = new EditorsKit_Typography_Addon();
self::$instance->includes();
self::$instance->initFilters();
}
return self::$instance;
}
private function includes()
{
require_once EDITORSKIT_TYPOGRAPHY_ADDON_DIR . 'includes/class-editorskit-typography-addon-post-meta.php';
require_once EDITORSKIT_TYPOGRAPHY_ADDON_DIR . 'includes/class-editorskit-typography-addon-font-loader.php';
require_once EDITORSKIT_TYPOGRAPHY_ADDON_DIR . 'includes/class-editorskit-block-typography-addon-manager.php';
}
public static function initFilters()
{
add_action('init', function () {
global $pagenow;
if ($pagenow === "widgets.php") {
return;
}
wp_register_script(
"editorskit-typography-addon-script",
EDITORSKIT_TYPOGRAPHY_ADDON_URL . '/build/index.js',
array(
"wp-element",
"wp-compose",
"wp-hooks",
"wp-block-editor",
"wp-i18n",
"wp-api"
),
uniqid()
);
wp_register_style(
'editorskit-typography-addon-editor-style',
EDITORSKIT_TYPOGRAPHY_ADDON_URL . '/build/index.css',
array(),
uniqid()
);
wp_register_style(
'editorskit-typography-addon-frontend-style',
EDITORSKIT_TYPOGRAPHY_ADDON_URL . '/build/style-index.css',
array(),
uniqid()
);
});
add_action('enqueue_block_editor_assets', function () {
$global = array(
'plugin' => array(
'version' => '1.0.0',
'url' => EDITORSKIT_TYPOGRAPHY_ADDON_URL,
'dir' => EDITORSKIT_TYPOGRAPHY_ADDON_DIR,
),
);
wp_add_inline_script("editorskit-typography-addon-script", 'window.editorskitTypographyAddonInfo = ' . wp_json_encode($global) . ';', 'before');
wp_enqueue_script('editorskit-typography-addon-script');
wp_enqueue_style('editorskit-typography-addon-editor-style');
});
add_action('init', function () {
if (!is_admin()) {
wp_enqueue_style('editorskit-typography-addon-frontend-style');
}
});
}
}
function editorskit_typography_addon()
{
return EditorsKit_Typography_Addon::instance();
}
// Get Plugin Running.
if (function_exists('is_multisite') && is_multisite()) {
// Get Plugin Running. Load on plugins_loaded action to avoid issue on multisite.
add_action('plugins_loaded', 'editorskit');
} else {
editorskit_typography_addon();
}