This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmemberpress.php
170 lines (149 loc) · 5.87 KB
/
memberpress.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
<?php
/*
Plugin Name: MemberPress Developer Edition
Plugin URI: http://www.memberpress.com/
Description: The membership plugin that makes it easy to accept payments for access to your content and digital products.
Version: 1.2.4
Author: Caseproof, LLC
Author URI: http://caseproof.com/
Text Domain: memberpress
Copyright: 2004-2015, Caseproof, LLC
*/
if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');}
define('MEPR_PLUGIN_SLUG','memberpress/memberpress.php');
define('MEPR_PLUGIN_NAME','memberpress');
define('MEPR_PATH',WP_PLUGIN_DIR.'/'.MEPR_PLUGIN_NAME);
define('MEPR_IMAGES_PATH',MEPR_PATH.'/images');
define('MEPR_CSS_PATH',MEPR_PATH.'/css');
define('MEPR_JS_PATH',MEPR_PATH.'/js');
define('MEPR_I18N_PATH',MEPR_PATH.'/i18n');
define('MEPR_LIB_PATH',MEPR_PATH.'/app/lib');
define('MEPR_INTERFACES_PATH',MEPR_PATH.'/app/lib/interfaces');
define('MEPR_DATA_PATH',MEPR_PATH.'/app/data');
define('MEPR_VENDOR_LIB_PATH',MEPR_PATH.'/vendor/lib');
define('MEPR_APIS_PATH',MEPR_PATH.'/app/apis');
define('MEPR_MODELS_PATH',MEPR_PATH.'/app/models');
define('MEPR_CTRLS_PATH',MEPR_PATH.'/app/controllers');
define('MEPR_GATEWAYS_PATH',MEPR_PATH.'/app/gateways');
define('MEPR_EMAILS_PATH',MEPR_PATH.'/app/emails');
define('MEPR_JOBS_PATH',MEPR_PATH.'/app/jobs');
define('MEPR_VIEWS_PATH',MEPR_PATH.'/app/views');
define('MEPR_WIDGETS_PATH',MEPR_PATH.'/app/widgets');
define('MEPR_HELPERS_PATH',MEPR_PATH.'/app/helpers');
// Make all of our URLS protocol agnostic
$mepr_url_protocol = (empty($_SERVER['HTTPS'])?'http':'https');
define('MEPR_URL',preg_replace('/^https?:/', "{$mepr_url_protocol}:", plugins_url('/'.MEPR_PLUGIN_NAME)));
define('MEPR_VIEWS_URL',MEPR_URL.'/app/views');
define('MEPR_IMAGES_URL',MEPR_URL.'/images');
define('MEPR_CSS_URL',MEPR_URL.'/css');
define('MEPR_JS_URL',MEPR_URL.'/js');
define('MEPR_GATEWAYS_URL',MEPR_URL.'/app/gateways');
define('MEPR_VENDOR_LIB_URL',MEPR_URL.'/vendor/lib');
define('MEPR_SCRIPT_URL',get_option('home').'/index.php?plugin=mepr');
define('MEPR_OPTIONS_SLUG', 'mepr_options');
define('MEPR_EDITION', 'developer');
/**
* Returns current plugin version.
*
* @return string Plugin version
*/
function mepr_plugin_info($field) {
static $curr_plugins;
if( !isset($curr_plugins) ) {
if( !function_exists( 'get_plugins' ) ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}
$curr_plugins = get_plugins();
}
if(isset($curr_plugins[MEPR_PLUGIN_SLUG][$field])) {
return $curr_plugins[MEPR_PLUGIN_SLUG][$field];
}
return '';
}
// Plugin Information from the plugin header declaration
define('MEPR_VERSION', mepr_plugin_info('Version'));
define('MEPR_DISPLAY_NAME', mepr_plugin_info('Name'));
define('MEPR_AUTHOR', mepr_plugin_info('Author'));
define('MEPR_AUTHOR_URI', mepr_plugin_info('AuthorURI'));
define('MEPR_DESCRIPTION', mepr_plugin_info('Description'));
// Autoload all the requisite classes
function mepr_autoloader($class_name)
{
// Only load MemberPress classes here
if(preg_match('/^Mepr.+$/', $class_name))
{
if(preg_match('/^.+Interface$/', $class_name)) // Load interfaces first
$filepath = MEPR_INTERFACES_PATH."/{$class_name}.php";
else if(preg_match('/^Mepr(Base|Cpt).+$/', $class_name)) // Base classes are in lib
$filepath = MEPR_LIB_PATH."/{$class_name}.php";
else if(preg_match('/^.+Ctrl$/', $class_name))
$filepath = MEPR_CTRLS_PATH."/{$class_name}.php";
else if(preg_match('/^.+Helper$/', $class_name))
$filepath = MEPR_HELPERS_PATH."/{$class_name}.php";
else if(preg_match('/^.+Exception$/', $class_name))
$filepath = MEPR_LIB_PATH."/MeprExceptions.php";
else if(preg_match('/^.+Jobs$/', $class_name))
$filepath = MEPR_LIB_PATH."/MeprJobs.php";
else if(preg_match('/^.+Gateway$/', $class_name)) {
foreach( MeprGatewayFactory::paths() as $path ) {
$filepath = $path."/{$class_name}.php";
if( file_exists($filepath) ) {
require_once($filepath); return;
}
}
return;
}
else if(preg_match('/^.+Email$/', $class_name)) {
foreach( MeprEmailFactory::paths() as $path ) {
$filepath = $path."/{$class_name}.php";
if( file_exists($filepath) ) {
require_once($filepath); return;
}
}
return;
}
else if(preg_match('/^.+Job$/', $class_name)) {
foreach( MeprJobFactory::paths() as $path ) {
$filepath = $path."/{$class_name}.php";
if( file_exists($filepath) ) {
require_once($filepath); return;
}
}
return;
}
else {
$filepath = MEPR_MODELS_PATH."/{$class_name}.php";
// Now let's try the lib dir if its not a model
if(!file_exists($filepath))
$filepath = MEPR_LIB_PATH."/{$class_name}.php";
}
if(file_exists($filepath))
require_once($filepath);
}
}
// if __autoload is active, put it on the spl_autoload stack
if(is_array(spl_autoload_functions()) and in_array('__autoload', spl_autoload_functions()))
spl_autoload_register('__autoload');
// Add the autoloader
spl_autoload_register('mepr_autoloader');
// Gotta load the language before everything else
MeprAppCtrl::load_language();
// Load our controllers
MeprCtrlFactory::all();
// Setup screens
MeprAppCtrl::setup_menus();
// Start Job Processor / Scheduler
new MeprJobs();
// Template Tags
function mepr_account_link() {
try {
$account_ctrl = MeprCtrlFactory::fetch('account');
echo $account_ctrl->get_account_links();
}
catch(Exception $e) {
// Silently fail ... not much we can do if the account controller isn't present
}
}
register_activation_hook( MEPR_PLUGIN_SLUG, create_function( '', 'require_once( MEPR_LIB_PATH . "/activation.php");' ) );
register_deactivation_hook( MEPR_PLUGIN_SLUG, create_function( '', 'require_once( MEPR_LIB_PATH . "/deactivation.php");' ) );
//register_uninstall_hook( MEPR_PLUGIN_SLUG, create_function( '', 'require_once( MEPR_PATH . "/uninstall.php");' ) );