This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
config.php
83 lines (70 loc) · 2.43 KB
/
config.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
<?php
/** no direct access **/
defined('_WPLEXEC') or die('Restricted access');
/**
* WPL import function. It used for importing overrided files automatically
* @author Howard <[email protected]>
* @param string $include
* @param boolean $override
* @param boolean $return_path
* @return mixed
*/
function _wpl_import($include, $override = true, $return_path = false)
{
$original_exploded = explode('.', $include);
$path = WPL_ABSPATH . implode(DS, $original_exploded) . '.php';
if($override)
{
$overrided_exploded = explode('.', 'overrides.'.$include);
$overrided_path = WPL_ABSPATH . implode(DS, $overrided_exploded) . '.php';
if(file_exists($overrided_path)) $path = $overrided_path;
/** theme overrides just for tmpl files **/
if(strpos($include, '.tmpl.') !== false)
{
/** main theme **/
$wp_theme_path = get_template_directory();
$overrided_file_in_theme = str_replace('views.', 'wplhtml.', $include);
$overrided_file_in_theme = str_replace('tmpl.', '', $overrided_file_in_theme);
if(substr($overrided_file_in_theme, 0, 8) == 'widgets.') $overrided_file_in_theme = 'wplhtml.'.$overrided_file_in_theme;
$theme_exploded = explode('.', $overrided_file_in_theme);
$theme_path = $wp_theme_path .DS. implode(DS, $theme_exploded) . '.php';
if(file_exists($theme_path)) $path = $theme_path;
/** child theme **/
if(is_child_theme())
{
$wp_stylesheet_path = get_stylesheet_directory();
$child_theme_path = $wp_stylesheet_path .DS. implode(DS, $theme_exploded) . '.php';
if(file_exists($child_theme_path)) $path = $child_theme_path;
}
}
}
if($return_path)
{
return $path;
}
if(file_exists($path)) require_once $path;
}
/**
* Imports wordpress files
* @author Howard <[email protected]>
* @param string $include
* @param boolean $override
* @param boolean $return_path
* @return string
*/
function _wp_import($include, $override = true, $return_path = false)
{
$original_exploded = explode('.', $include);
$path = ABSPATH . implode(DS, $original_exploded) . '.php';
if($override)
{
$overrided_exploded = explode('.', 'overrides.'.$include);
$overrided_path = ABSPATH . implode(DS, $overrided_exploded) . '.php';
if(file_exists($overrided_path)) $path = $overrided_path;
}
if($return_path)
{
return $path;
}
if(file_exists($path)) require_once $path;
}