-
Notifications
You must be signed in to change notification settings - Fork 0
/
memberships-by-hubloy.php
224 lines (192 loc) · 4.86 KB
/
memberships-by-hubloy.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
/**
* Plugin Name: Memberships by Hubloy
* Plugin URI: https://www.hubloymembership.com
* Description: A complete membership and subscription experience.
* Version: 1.1.1
* Author: Hubloy
* Author URI: https://www.hubloy.com
* License: GPLv2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: memberships-by-hubloy
* Domain Path: /languages/
*
* @package HubloyMembership
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'HubloyMembership' ) ) :
/**
* Main plugin class
*
* Main entry point of the plugin
* Definess variables and constants needed to run the plugin and loads
* the main plugin class
*
* @since 1.0.0
*/
final class HubloyMembership {
/**
* Current plugin version.
*
* @since 1.0.0
*
* @var string
*/
public $version = '1.1.1';
/**
* The single instance of the class
*
* @since 1.0.0
*
* @var object
*/
protected static $_instance = null;
/**
* The query object
*
* @since 1.0.0
*
* @var object
*/
private $query = null;
/**
* The api object
*
* @since 1.0.0
*
* @var object
*/
private $api = null;
/**
* Get the instance
*
* @since 1.0.0
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Main plugin constructor
*
* @since 1.0.0
*/
public function __construct() {
// Define plugin constants.
$this->define_constants();
// Define autoloader.
$this->auto_load();
// Initiate plugin.
\HubloyMembership\Base\Plugin::instance();
$this->query = new \HubloyMembership\Core\Query();
$this->api = new \HubloyMembership\Core\Api();
if ( defined( 'WP_CLI' ) && WP_CLI ) {
// Load wp_cli
}
do_action( 'memberships-by-hubloy_loaded' );
}
/**
* Define plugin constants
* Global constants used within the plugin if they are not already defined
*
* @since 1.0.0
*/
protected function define_constants() {
$upload_dir = wp_upload_dir();
$this->define( 'HUBMEMB_MENU_LOCATION', '55.5' );
$this->define( 'HUBMEMB_REST_NAMESPACE', 'memberships-by-hubloy/v1/' );
$this->define( 'HUBMEMB_VERSION', $this->version );
$this->define( 'HUBMEMB_UIKIT_VERSION', '3.2.6' );
$this->define( 'HUBMEMB_ROUNDING_PRECISION', 6 );
$this->define( 'HUBMEMB_DEBUG', true );
$this->define( 'HUBMEMB_PLUGIN_FILE', __FILE__ );
$this->define( 'HUBMEMB_PLUGIN', plugin_basename( __FILE__ ) );
$this->define( 'HUBMEMB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
$this->define( 'HUBMEMB_PLUGIN_BASE_DIR', dirname( __FILE__ ) );
$this->define( 'HUBMEMB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
$this->define( 'HUBMEMB_LANG_DIR', HUBMEMB_PLUGIN_DIR . '/languages' );
$this->define( 'HUBMEMB_TEMPLATE_DIR', HUBMEMB_PLUGIN_DIR . '/templates/' );
$this->define( 'HUBMEMB_FUNCTIONS_DIR', HUBMEMB_PLUGIN_DIR . '/app/functions/' );
$this->define( 'HUBMEMB_LIB_DIR', HUBMEMB_PLUGIN_DIR . '/lib/' );
$this->define( 'HUBMEMB_LOCALE_DIR', HUBMEMB_PLUGIN_DIR . '/app/i18n' );
$this->define( 'HUBMEMB_ASSETS_URL', HUBMEMB_PLUGIN_URL . 'assets' );
$this->define( 'HUBMEMB_LOG_DIR', $upload_dir['basedir'] . '/memberships-by-hubloy-logs/' );
$this->define( 'HUBMEMB_LOG_URL', $upload_dir['baseurl'] . '/memberships-by-hubloy-logs/' );
}
/**
* Define constant helper if not already set
*
* @param string $name The name.
* @param string|bool $value The value.
*
* @since 1.0.0
*/
private function define( $name, $value ) {
if ( ! defined( $name ) ) {
define( $name, $value );
}
}
/**
* Load plugin
*
* @since 1.0.0
*/
private function auto_load() {
spl_autoload_register( array( &$this, '_autoload' ) );
}
/**
* Set up the class loader.
*
* @param string $class The class name.
*/
public function _autoload( $class ) {
$base_path = __DIR__ . DIRECTORY_SEPARATOR;
$pools = explode( '\\', $class );
if ( 'HubloyMembership' !== $pools[0] ) {
return;
}
$pools[0] = 'App';
// build the path.
$path = implode( DIRECTORY_SEPARATOR, $pools );
$path = $base_path . strtolower( str_replace( '_', '-', $path ) ) . '.php';
if ( file_exists( $path ) ) {
include_once $path;
}
}
/**
* Get query
*
* @since 1.0.0
*
* @return object
*/
public function get_query() {
return $this->query;
}
/**
* Get api
*
* @since 1.0.0
*
* @return object
*/
public function get_api() {
return $this->api;
}
}
/**
* Global function
*
* @since 1.0.0
*
* @return HubloyMembership
*/
function hubloy_membership() {
return HubloyMembership::instance();
}
hubloy_membership();
endif;