-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
63 lines (61 loc) · 1.54 KB
/
functions.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
<?php
/*
Functions file
@package: WordPress
@subpackage: MineStack
*/
function getHeaders($file) {
$default_headers = array(
'Name' => 'Stack Name',
'PluginURI' => 'Stack URI',
'Version' => 'Version',
'Description' => 'Description',
'Author' => 'Author',
'AuthorURI' => 'Author URI',
'License' => 'License'
);
$headers = get_file_data($file, $default_headers);
//return(!empty($headers['Name']))? $headers : false;
return $headers;
}
function includeStacks() {
$stacks = getStacks();
if($stacks){
foreach($stacks as $stack){
if(!isRegisterStack($stack['Name'])) add_option($stack['Name'], false);
if(get_option($stack['Name'])) include($stack['path']);
}
}
}
function isRegisterStack($name){
return (get_option($name, 0) != 0)? true : false;
}
function stack_dir_path($file){
return trailingslashit(dirname($file));
}
function getStacks() {
$result = array();
if($handle = opendir(PLUGIN_PATH.'/stacks')){
while (false !== ($entry = readdir($handle))) {
if($entry != "." && $entry != "..") {
if(is_dir(PLUGIN_PATH.'/stacks/'.$entry)){
$entry_handle = opendir(PLUGIN_PATH.'/stacks/'.$entry);
while(false !== ($file = readdir($entry_handle))){
if($file != "." && $file != "..") {
$path = PLUGIN_PATH.'stacks/'.$entry.'/'.$file;
}
}
} else {
$path = PLUGIN_PATH.'/stacks/'.$entry;
}
$stack = getHeaders($path);
echo $path;
if(!empty($stack['Name'])){
$stack[path] = $path;
array_push($result, $stack);
} else $result = false;
}
}
}
return $result;
}