forked from PressApps/skelet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskelet.php
236 lines (176 loc) · 8.74 KB
/
skelet.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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
/**
* Skelet Framework
* @version 1.0.1
* @author PressApps <[email protected]>
*
*/
global $skelet_paths,
$skelet_path,
$skelet_shortcodes,
$skelet_metaboxes,
$skelet_customize,
$skelet_taxonomy;
$skelet_metaboxes = array();
$skelet_customize = array();
$skelet_taxonomy = array();
// Skelet class
include_once wp_normalize_path(dirname( __FILE__ ) .'/classes/skelet.class.php');
// Widget should be included on widgets init action.
include_once wp_normalize_path(dirname( __FILE__ ) .'/classes/widget.class.php');
if(! class_exists( 'Skelet_LoadConfig' ) ){
class Skelet_LoadConfig{
public static function instance(){
global $skelet_paths,$skelet_path;
// active modules
defined( 'SK_ACTIVE_FRAMEWORK' ) or define( 'SK_ACTIVE_FRAMEWORK', true );
defined( 'SK_ACTIVE_METABOX' ) or define( 'SK_ACTIVE_METABOX', true );
defined( 'SK_ACTIVE_SHORTCODE' ) or define( 'SK_ACTIVE_SHORTCODE', true );
defined( 'SK_ACTIVE_CUSTOMIZE' ) or define( 'SK_ACTIVE_CUSTOMIZE', true );
defined( 'SK_ACTIVE_WIDGET' ) or define( 'SK_ACTIVE_WIDGET', true );
defined( 'SK_ACTIVE_TAXONOMY' ) or define( 'SK_ACTIVE_TAXONOMY', true );
defined( 'SK_ACTIVE_TEMPLATE' ) or define( 'SK_ACTIVE_TEMPLATE', true );
foreach ($skelet_paths as $path) {
// ------------------------------------------------------------------------------------------------
include_once wp_normalize_path(dirname( __FILE__ ) .'/path.php');
// ------------------------------------------------------------------------------------------------
$arr_last = $path;
$path["basename"] = "skelet";
$path["option"] = $path["prefix"]."_options";
$path["customize"]= $path["prefix"]."_customize";
$skelet_path = $path;
// helpers
sk_locate_template ( 'functions/deprecated.php' ,$skelet_path);
sk_locate_template ( 'functions/helpers.php' ,$skelet_path);
sk_locate_template ( 'functions/actions.php' ,$skelet_path);
sk_locate_template ( 'functions/enqueue.php' ,$skelet_path);
sk_locate_template ( 'functions/sanitize.php' ,$skelet_path);
sk_locate_template ( 'functions/validate.php' ,$skelet_path);
sk_locate_template ( 'functions/customize.php' ,$skelet_path);
// classes
sk_locate_template ( 'classes/abstract.class.php' ,$skelet_path);
sk_locate_template ( 'classes/options.class.php' ,$skelet_path);
sk_locate_template ( 'classes/framework.class.php' ,$skelet_path);
sk_locate_template ( 'classes/metabox.class.php' ,$skelet_path);
sk_locate_template ( 'classes/shortcode.class.php' ,$skelet_path);
sk_locate_template ( 'classes/customize.class.php' ,$skelet_path);
sk_locate_template ( 'classes/taxonomy.class.php' ,$skelet_path);
sk_locate_template ( 'classes/template.class.php' ,$skelet_path);
// configs
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/framework.config.php'))){
sk_locate_template ( '../../includes/options/framework.config.php' ,$skelet_path);
}
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/metabox.config.php'))){
sk_locate_template ( '../../includes/options/metabox.config.php' ,$skelet_path);
}
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/shortcode.config.php'))){
sk_locate_template ( '../../includes/options/shortcode.config.php' ,$skelet_path);
}
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/customize.config.php'))){
sk_locate_template ( '../../includes/options/customize.config.php' ,$skelet_path);
}
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/taxonomy.config.php'))){
sk_locate_template ( '../../includes/options/taxonomy.config.php' ,$skelet_path);
}
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/template.config.php'))){
sk_locate_template ( '../../includes/options/template.config.php' ,$skelet_path);
}
if ($arr_last === end($skelet_paths)){
do_action("skelet_loaded");
}
}
}
}
add_action("init",array('Skelet_LoadConfig','instance'),10);
}
/**
* Load shortcodes after skelet loaded
*/
if (!function_exists("skelet_load_shortcodes")) {
function skelet_load_shortcodes(){
global $skelet_shortcodes;
SkeletFramework_Shortcode_Manager::instance( $skelet_shortcodes );
}
add_action( 'skelet_loaded', 'skelet_load_shortcodes', 10 );
}
/**
* Load metaboxes after skelet loaded
*/
if (!function_exists("skelet_load_metaboxes")) {
function skelet_load_metaboxes(){
global $skelet_metaboxes;
SkeletFramework_Metabox::instance( $skelet_metaboxes );
}
add_action( 'skelet_loaded', 'skelet_load_metaboxes', 10 );
}
/**
* Load customize after skelet loaded
*/
if (!function_exists("skelet_load_customize")) {
function skelet_load_customize(){
global $skelet_customize;
SkeletFramework_Customize::instance( $skelet_customize );
}
add_action( 'skelet_loaded', 'skelet_load_customize', 10 );
}
/**
* Load taxonomy after skelet loaded
*/
if (!function_exists("skelet_load_taxonomy")) {
function skelet_load_taxonomy(){
global $skelet_taxonomy;
SkeletFramework_Taxonomy::instance( $skelet_taxonomy );
}
add_action( 'skelet_loaded', 'skelet_load_taxonomy', 10 );
}
/**
* Skelet Widget Init
*/
if(!class_exists("Skelet_PA_Widget")){
class Skelet_PA_Widget{
function __construct(){
add_action( 'widgets_init', array($this,"widgetize"),2);
}
/**
* Register the widget for the admin area.
*
* @since 1.0.0
*/
public function widgetize(){
global $skelet_paths,$skelet_path;
foreach ($skelet_paths as $path) {
$skelet_path = $path;
if(file_exists( wp_normalize_path($skelet_path["dir"].'/options/widget.config.php'))){
include_once wp_normalize_path($skelet_path["dir"].'/options/widget.config.php');
}
}
}
}
new Skelet_PA_Widget;
}
/**
* Add PressApps Menu
*/
if(!class_exists("Skelet_PressApps_Menu")){
class Skelet_PressApps_Menu{
public static function pa_main_menu(){
global $skelet_paths, $submenu;
call_user_func("add_submenu_page", SK_PARENT_MENU, "Products", "Products", "manage_options", "pressapps-product", array("Skelet_PressApps_Menu","get_pa_general_pages"));
call_user_func("add_submenu_page", SK_PARENT_MENU, "Help", "Help", "manage_options", "pressapps-help", array("Skelet_PressApps_Menu","get_pa_general_pages"));
}
public static function get_pa_general_pages(){
if(!class_exists("PressApps"))
{
include_once wp_normalize_path(plugin_dir_path(__FILE__ ) .'/pressapps/pressapps.class.php');
$pa = new PressApps;
$route_param = isset( $_GET["page"] ) ? $_GET["page"] : "";
if ( strstr( PHP_VERSION, '5.2' ) ) {
call_user_func( 'PressApps::route', $route_param );
} else {
$pa::route( $route_param );
}
}
}
}
add_action("admin_menu",array("Skelet_PressApps_Menu","pa_main_menu"),999);
}