Repository navigation
Expand file tree
/
Copy pathkavro-framework.php
More file actions
161 lines (151 loc) · 5.13 KB
/
Copy pathkavro-framework.php
File metadata and controls
161 lines (151 loc) · 5.13 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/**
* Plugin Name: Kavro Framework
* Plugin URI: https://github.com/hmbashar/kavro-framework
* Description: A modern, lightweight WordPress framework for building admin options, metaboxes, Customizer panels, taxonomy options, profile fields, menu item fields, widgets, comments, and shortcode UIs.
* Version: 1.0.1
* Requires at least: 5.8
* Tested up to: 7.0
* Requires PHP: 7.4
* Author: Md Abul Bashar
* Author URI: https://hmbashar.com
* Text Domain: kavro-framework
* Domain Path: /languages
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('ABSPATH')) {
exit;
}
if (!defined('KAVRO_VERSION')) {
define('KAVRO_VERSION', '1.0.1');
}
if (!defined('KAVRO_EDITION')) {
define('KAVRO_EDITION', 'free');
}
if (!defined('KAVRO_LOAD_EXAMPLES')) {
/**
* Examples are disabled by default for production and WordPress.org builds.
*
* Developers can enable the bundled demos in wp-config.php while testing:
* define( 'KAVRO_LOAD_EXAMPLES', true );
*/
define('KAVRO_LOAD_EXAMPLES', true);
}
define('KAVRO_FILE', __FILE__);
define('KAVRO_PATH', plugin_dir_path(__FILE__));
define('KAVRO_URL', plugin_dir_url(__FILE__));
$kavro_autoload = KAVRO_PATH . 'vendor/autoload.php';
if (file_exists($kavro_autoload)) {
require_once $kavro_autoload;
} else {
spl_autoload_register(function ($class) {
$maps = array(
'Kavro\\Fields\\' => KAVRO_PATH . 'fields/',
'Kavro\\' => KAVRO_PATH . 'classes/',
);
foreach ($maps as $prefix => $base) {
if (0 !== strpos($class, $prefix)) {
continue;
}
$relative = substr($class, strlen($prefix));
$file = $base . str_replace('\\', '/', $relative) . '.php';
if (file_exists($file)) {
require_once $file;
}
return;
}
});
}
require_once KAVRO_PATH . 'includes/functions.php';
if (!class_exists('KAVRO')) {
final class KAVRO
{
public static function boot()
{
return \Kavro\Framework::boot();
}
public static function registerModule($module, $class, $args = array())
{
return \Kavro\Framework::registerModule($module, $class, $args);
}
public static function getModules()
{
return \Kavro\Framework::getModules();
}
public static function isModuleAvailable($module)
{
return \Kavro\Framework::isModuleAvailable($module);
}
public static function isPro()
{
return \Kavro\Framework::isPro();
}
public static function edition()
{
return \Kavro\Framework::edition();
}
public static function createOptions($id, $args = array())
{
return \Kavro\Framework::createOptions($id, $args);
}
public static function createSection($id, $section)
{
return \Kavro\Framework::createSection($id, $section);
}
public static function createCustomizeOptions($id, $args = array())
{
return \Kavro\Framework::createCustomizeOptions($id, $args);
}
public static function createMetabox($id, $args = array())
{
return \Kavro\Framework::createMetabox($id, $args);
}
public static function createTaxonomyOptions($id, $args = array())
{
return \Kavro\Framework::createTaxonomyOptions($id, $args);
}
public static function createProfileOptions($id, $args = array())
{
return \Kavro\Framework::createProfileOptions($id, $args);
}
public static function createNavMenuOptions($id, $args = array())
{
return \Kavro\Framework::createNavMenuOptions($id, $args);
}
public static function createWidgetOptions($id, $args = array())
{
return \Kavro\Framework::createWidgetOptions($id, $args);
}
public static function createCommentOptions($id, $args = array())
{
return \Kavro\Framework::createCommentOptions($id, $args);
}
public static function createShortcode($id, $args = array())
{
return \Kavro\Framework::createShortcode($id, $args);
}
}
}
/**
* Load plugin translations at init or later.
*
* WordPress 6.7+ warns when translations are requested before `init`.
* Keeping textdomain loading here prevents early just-in-time translation notices.
*
* @return void
*/
function kavro_load_textdomain()
{
load_plugin_textdomain('kavro-framework', false, dirname(plugin_basename(KAVRO_FILE)) . '/languages');
}
add_action('init', 'kavro_load_textdomain', 0);
/**
* Register the Kavro runtime hooks.
*
* The runtime creates option/metabox instances on `init` priority 20. Demo files
* are loaded on `init` priority 10 below, so they always register their
* containers and sections before instances are built. This keeps translations
* safe for WordPress 6.7+ and fixes empty option panels caused by late demos.
*/
add_action('plugins_loaded', array('KAVRO', 'boot'));