-
Notifications
You must be signed in to change notification settings - Fork 3
/
kmm-hacks.php
80 lines (60 loc) · 1.61 KB
/
kmm-hacks.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
<?php
/**
* Plugin Name: KMM Hacks
* Description: This is a short description of what the plugin does.
* Plugin URI: http://github.com/KroneMultiMedia/plugin-hacks
* Version: %TRAVIS_TAG%
* Author: Krone.at
* Author URI: http://www.krone.at
* Licence: MIT
* Text Domain: kmm-hacks
* Domain Path: /languages
*/
namespace KMM\Hacks;
use KMM\Hacks\Core;
if (! function_exists('add_filter')) {
return;
}
/**
* Ensure that autoload is already loaded or loads it if available.
*
* @param string $class_name
*
* @return bool
*/
function ensure_class_loaded($class_name)
{
$class_exists = class_exists($class_name);
$autoload_found = file_exists(ABSPATH . '/vendor/autoload.php');
// If the class does not exist, and the vendor file is there
// maybe the plugin was installed separately via Composer, let's try to load autoload
if (! $class_exists && $autoload_found) {
@require_once ABSPATH . '/vendor/autoload.php';
}
return $class_exists || ( $autoload_found && class_exists($class_name) );
}
// Exit if classes are not available
if (! ensure_class_loaded(__NAMESPACE__ . '\Core')) {
return;
}
add_action('plugins_loaded', __NAMESPACE__ . '\main');
/**
* @wp-hook plugins_loaded
*/
function main()
{
$i18n = 'kmm-hacks';
load_plugin_textdomain(
$i18n,
false,
dirname(plugin_basename(__FILE__)) . '/languages'
);
new Core($i18n);
if (is_admin()) {
// Backend
// TODO: register your backend-code here...
} else {
// Frontend
// TODO: register frontend-code here...
}
}