-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopub-functions.php
More file actions
108 lines (81 loc) · 2.12 KB
/
popub-functions.php
File metadata and controls
108 lines (81 loc) · 2.12 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
<?php
// DEFINES
define('DATETIME_NOW', date('Y-m-d h-m-s'));
define('DATE_NOW', date('Y-m-d'));
define('TIME_NOW', date('h-m-s'));
// FUNCTIONS
function popub_dirname()
{
return dirname( __FILE__ );
}
function popub_plugin_basename()
{
return plugin_basename( __FILE__ );
}
function popub_plugin_dir_path()
{
return plugin_dir_path( __FILE__ );
}
function popub_plugins_url($url, $file = __FILE__)
{
return plugins_url($url, $file);
}
function popub_config($file, $line = false)
{
$config_path = popub_plugin_dir_path() . 'config/';
$config_file = $config_path . $file . '.php';
if(! file_exists($config_file) )
return;
$content = require($config_file);
if( is_string($line) && isset( $content[$line] ) )
return $content[$line];
return $content;
}
function popub_include($file = '', $once = false)
{
$include_path = popub_plugin_dir_path() . $file;
if(! file_exists($include_path) )
return false;
if(! $once )
return include $include_path;
return include_once $include_path;
}
function popub_require($file = '', $once = false)
{
$require_path = popub_plugin_dir_path() . $file;
if(! file_exists($require_path) )
return false;
if(! $once )
return require $require_path;
return require_once $require_path;
}
function popub_render($template, array $data = [])
{
$path_template = popub_plugin_dir_path() . "templates/{$template}.php";
if(! file_exists($path_template) )
return die('Template not exists');
if( count($data) ) extract($data);
return include $path_template;
}
function popub_admin_url($page, array $params = [])
{
return Inc\Core\Locator::adminUrl($page, $params);
}
function popub_admin_post_url()
{
return Inc\Core\Locator::adminPostUrl();
}
function popub_datetime_now()
{
$timezone_format = _x('Y-m-d H:i:s', 'timezone date format');
return date_i18n( $timezone_format ) ; //date('d-m-Y h:i:s')
}
function popub_token()
{
return strrev( sha1( time() ) );
}
// FRONTSIDE
function popub_showtime()
{
return Inc\Controllers\HomeController::showtime();
}