-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel7platform.php
More file actions
180 lines (144 loc) · 4.62 KB
/
level7platform.php
File metadata and controls
180 lines (144 loc) · 4.62 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
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
<?php
/*
Plugin Name: Level 7 Systems integration plugin
Plugin URI: http://level7systems.co.uk
Description: This is a Level 7 Systems integration plugin which will help you to manage your white label communication service.
Author: Level 7 Systems Ltd.
Author URI: http://level7systems.co.uk
Version: 1.0.6
*/
if (defined('LEVEL7PLATFORM_VERSION'))
return;
define('LEVEL7_PATH', dirname(__FILE__));
class Level7Platform
{
const VERSION = '1.0.6';
/**
* @var L7P_Query $query
*/
public $query = null;
/**
* @var WooCommerce The single instance of the class
* @since 2.1
*/
protected static $_instance = null;
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct()
{
// Auto-load classes on demand
if (function_exists("__autoload")) {
spl_autoload_register("__autoload");
}
spl_autoload_register(array($this, 'autoload'));
// constants
$this->define_constants();
// session initialization
$this->init_session();
// include required files
$this->includes();
// integration with other plugins
add_action('plugins_loaded', array('L7P_PluginIntegration', 'setup'), 10);
add_action('plugins_loaded', array($this, 'init'), 0);
// Loaded action
do_action('level7platform_loaded');
}
public function autoload($class)
{
$path = null;
$file = $class . '.php';
if (strpos($class, 'L7P_Admin') === 0) {
$path = $this->plugin_path() . '/includes/admin/';
}
if ($path && is_readable($path . $file)) {
include_once( $path . $file );
return;
}
// Fallback
if (strpos($class, 'L7P_') === 0) {
$path = $this->plugin_path() . '/includes/';
}
if ($path && is_readable($path . $file)) {
include_once( $path . $file );
return;
}
}
public function init()
{
// Set up localisation
$this->load_plugin_textdomain();
}
private function define_constants()
{
define('L7P_PLUGIN_FILE', __FILE__);
define('L7P_PLUGIN_BASENAME', plugin_basename(__FILE__));
define('L7P_VERSION', self::VERSION);
if (!defined('L7P_LOG_DIR')) {
define('L7P_LOG_DIR', ABSPATH . 'l7p-logs/');
}
}
/**
* Include required core files used in admin and on the frontend.
*/
private function includes()
{
// common functions
include_once('includes/L7P_Exceptions.php');
include_once('includes/L7P_Functions.php');
include_once('includes/L7P_Form.php');
include_once('includes/L7P_Block.php');
// installer
include_once('includes/L7P_Install.php');
// integrations
include_once('includes/L7P_PluginIntegration.php');
if (is_admin()) {
// ajax hooks needs to be loaded here
include_once('includes/L7P_Ajax.php');
include_once('includes/admin/L7P_Functions.php');
include_once('includes/L7P_Admin.php');
} else { // Frontend
include_once('includes/frontend/L7P_Content.php');
include_once('includes/frontend/L7P_Inline.php');
include_once('includes/L7P_Frontend.php');
}
// Query class
$this->query = include( 'includes/L7P_Query.php' );
// Post Types
include_once('includes/L7P_Post_Types.php');
// XmlRpc Api
include_once('includes/L7P_XmlRpc_Api.php');
}
public function load_plugin_textdomain()
{
load_plugin_textdomain('level7platform', false, dirname(plugin_basename(__FILE__)) . '/i18n');
}
public function plugin_url()
{
return untrailingslashit(plugins_url('/', __FILE__));
}
public function plugin_path()
{
return untrailingslashit(plugin_dir_path(__FILE__));
}
private function init_session()
{
// do not start session for level7 theme
if (defined('L7_CONFIG_PATH')) {
return;
}
if (!session_id()) {
session_start();
}
}
}
function L7P()
{
return Level7Platform::instance();
}
// Global for backwards compatibility.
$GLOBALS['level7platform'] = L7P();