This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
forked from strangerstudios/paid-memberships-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paid-memberships-pro.php
225 lines (185 loc) · 10.6 KB
/
paid-memberships-pro.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
225
<?php
/**
* Plugin Name: Paid Memberships Pro
* Plugin URI: https://www.paidmembershipspro.com
* Description: The most complete member management and membership subscriptions plugin for WordPress.
* Version: 2.8.3
* Author: Paid Memberships Pro
* Author URI: https://www.paidmembershipspro.com
* Text Domain: paid-memberships-pro
* Domain Path: /languages
*/
/**
* Copyright 2011-2022 Stranger Studios
* (email : [email protected])
* GPLv2 Full license details in license.txt
*/
// version constant
define( 'PMPRO_VERSION', '2.8.3' );
define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
/*
Includes
*/
define( 'PMPRO_BASE_FILE', __FILE__ );
define( 'PMPRO_DIR', dirname( __FILE__ ) );
require_once( PMPRO_DIR . '/classes/class-deny-network-activation.php' ); // stop PMPro from being network activated
require_once( PMPRO_DIR . '/includes/sessions.php' ); // start/close PHP session vars
require_once( PMPRO_DIR . '/includes/localization.php' ); // localization functions
require_once( PMPRO_DIR . '/includes/lib/name-parser.php' ); // parses "Jason Coleman" into firstname=>Jason, lastname=>Coleman
require_once( PMPRO_DIR . '/includes/functions.php' ); // misc functions used by the plugin
require_once( PMPRO_DIR . '/includes/updates.php' ); // database and other updates
require_once( PMPRO_DIR . '/includes/upgradecheck.php' ); // database and other updates
require_once( PMPRO_DIR . '/includes/deprecated.php' ); // deprecated hooks and functions
if ( ! defined( 'PMPRO_LICENSE_SERVER' ) ) {
require_once( PMPRO_DIR . '/includes/license.php' ); // defines location of addons data and licenses
}
require_once( PMPRO_DIR . '/includes/crons.php' ); // cron-related functionality
require_once( PMPRO_DIR . '/scheduled/crons.php' ); // crons for expiring members, sending expiration emails, etc
require_once( PMPRO_DIR . '/classes/class.memberorder.php' ); // class to process and save orders
require_once( PMPRO_DIR . '/classes/class.pmproemail.php' ); // setup and filter emails sent by PMPro
require_once( PMPRO_DIR . '/classes/class-pmpro-levels.php' );
require_once( PMPRO_DIR . '/classes/class-pmpro-admin-activity-email.php' ); // setup the admin activity email
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
require_once( PMPRO_DIR . '/includes/admin.php' ); // admin notices and functionality
require_once( PMPRO_DIR . '/includes/adminpages.php' ); // dashboard pages
require_once( PMPRO_DIR . '/classes/class-pmpro-members-list-table.php' ); // Members List
if ( version_compare( PHP_VERSION, '5.3.29', '>=' ) ) {
require_once( PMPRO_DIR . '/blocks/blocks.php' ); // Gutenberg blocks
}
require_once( PMPRO_DIR . '/includes/services.php' ); // services loaded by AJAX and via webhook, etc
require_once( PMPRO_DIR . '/includes/metaboxes.php' ); // metaboxes for dashboard
require_once( PMPRO_DIR . '/includes/profile.php' ); // edit user/profile fields
require_once( PMPRO_DIR . '/includes/https.php' ); // code related to HTTPS/SSL
require_once( PMPRO_DIR . '/includes/menus.php' ); // custom menu functions for PMPro
require_once( PMPRO_DIR . '/includes/notifications.php' ); // check for notifications at PMPro, shown in PMPro settings
require_once( PMPRO_DIR . '/includes/init.php' ); // code run during init, set_current_user, and wp hooks
require_once( PMPRO_DIR . '/includes/scripts.php' ); // enqueue frontend and admin JS and CSS
require_once( PMPRO_DIR . '/includes/content.php' ); // code to check for memebrship and protect content
require_once( PMPRO_DIR . '/includes/compatibility.php' ); // code to support compatibility for popular page builders
require_once( PMPRO_DIR . '/includes/email.php' ); // code related to email
require_once( PMPRO_DIR . '/includes/recaptcha.php' ); // load recaptcha files if needed
require_once( PMPRO_DIR . '/includes/cleanup.php' ); // clean things up when deletes happen, etc.
require_once( PMPRO_DIR . '/includes/login.php' ); // code to redirect away from login/register page
require_once( PMPRO_DIR . '/includes/capabilities.php' ); // manage PMPro capabilities for roles
require_once( PMPRO_DIR . '/includes/privacy.php' ); // code to aid with user data privacy, e.g. GDPR compliance
require_once( PMPRO_DIR . '/includes/pointers.php' ); // popover help pointers
require_once( PMPRO_DIR . '/includes/spam.php' ); // code to combat spam of various kinds
require_once( PMPRO_DIR . '/includes/xmlrpc.php' ); // xmlrpc methods
require_once( PMPRO_DIR . '/includes/rest-api.php' ); // rest API endpoints
require_once( PMPRO_DIR . '/includes/widgets.php' ); // widgets for PMPro
require_once( PMPRO_DIR . '/classes/class-pmpro-site-health.php' ); // Site Health information.
require_once( PMPRO_DIR . '/shortcodes/checkout_button.php' ); // [pmpro_checkout_button] shortcode to show link to checkout for a level
require_once( PMPRO_DIR . '/shortcodes/membership.php' ); // [membership] shortcode to hide/show member content
require_once( PMPRO_DIR . '/shortcodes/pmpro_account.php' ); // [pmpro_account] shortcode to show account information
require_once( PMPRO_DIR . '/shortcodes/pmpro_login.php' ); // [pmpro_login] shortcode to show a login form or logged in member info and menu.
require_once( PMPRO_DIR . '/shortcodes/pmpro_member.php' ); // [pmpro_member] shortcode to show user fields
require_once( PMPRO_DIR . '/shortcodes/pmpro_member_profile_edit.php' ); // [pmpro_member_profile_edit] shortcode to allow members to edit their profile
// load gateway
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway.php' ); // loaded by memberorder class when needed
// load payment gateway class
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_authorizenet.php' );
if ( version_compare( PHP_VERSION, '5.4.45', '>=' ) ) {
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_braintree.php' );
}
require_once( PMPRO_DIR . '/classes/class-pmpro-discount-codes.php' ); // loaded by memberorder class when needed
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_check.php' );
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_cybersource.php' );
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_payflowpro.php' );
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_paypal.php' );
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_paypalexpress.php' );
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_paypalstandard.php' );
pmpro_check_for_deprecated_gateways();
if ( version_compare( PHP_VERSION, '5.3.29', '>=' ) ) {
require_once( PMPRO_DIR . '/classes/gateways/class.pmprogateway_stripe.php' );
require_once( PMPRO_DIR . '/includes/lib/stripe-apple-pay/stripe-apple-pay.php' ); // rewrite rules to set up Apple Pay.
}
// Set up Wisdom tracking.
require_once PMPRO_DIR . '/classes/class-pmpro-wisdom-integration.php';
$wisdom_integration = PMPro_Wisdom_Integration::instance();
$wisdom_integration->setup_wisdom();
/*
Setup the DB and check for upgrades
*/
global $wpdb;
// check if the DB needs to be upgraded
if ( is_admin() || defined('WP_CLI') ) {
pmpro_checkForUpgrades();
}
// load plugin updater
if ( is_admin() ) {
require_once( PMPRO_DIR . '/includes/addons.php' );
}
/*
Definitions
*/
define( 'SITENAME', str_replace( ''', "'", get_bloginfo( 'name' ) ) );
if ( ! defined( 'SITEURL' ) ) {
$urlparts = explode( '//', home_url() );
define( 'SITEURL', $urlparts[1] );
}
if ( ! defined( 'SECUREURL' ) ) {
define( 'SECUREURL', str_replace( 'http://', 'https://', get_bloginfo( 'wpurl' ) ) );
}
define( 'PMPRO_URL', plugins_url( '', PMPRO_BASE_FILE ) );
define( 'PMPRO_DOMAIN', pmpro_getDomainFromURL( site_url() ) );
define( 'PAYPAL_BN_CODE', 'PaidMembershipsPro_SP' );
/*
Globals
*/
global $gateway_environment;
$gateway_environment = pmpro_getOption( 'gateway_environment' );
// Returns a list of all available gateway
function pmpro_gateways() {
$pmpro_gateways = array(
'' => __( 'Testing Only', 'paid-memberships-pro' ),
'check' => __( 'Pay by Check', 'paid-memberships-pro' ),
'stripe' => __( 'Stripe', 'paid-memberships-pro' ),
'paypalexpress' => __( 'PayPal Express', 'paid-memberships-pro' ),
'paypal' => __( 'PayPal Website Payments Pro', 'paid-memberships-pro' ),
'payflowpro' => __( 'PayPal Payflow Pro/PayPal Pro', 'paid-memberships-pro' ),
'paypalstandard' => __( 'PayPal Standard', 'paid-memberships-pro' ),
'authorizenet' => __( 'Authorize.net', 'paid-memberships-pro' ),
'braintree' => __( 'Braintree Payments', 'paid-memberships-pro' ),
'cybersource' => __( 'Cybersource', 'paid-memberships-pro' ),
);
if ( pmpro_onlyFreeLevels() ) {
$pmpro_gateways[''] = __( 'Default', 'paid-memberships-pro' );
}
return apply_filters( 'pmpro_gateways', $pmpro_gateways );
}
// when checking levels for users, we save the info here for caching. each key is a user id for level object for that user.
global $all_membership_levels;
// we sometimes refer to this array of levels
// DEPRECATED: Remove this in v3.0.
global $membership_levels;
$membership_levels = pmpro_sort_levels_by_order( pmpro_getAllLevels( true, true ) );
/*
Activation/Deactivation
*/
// we need monthly crons
function pmpro_cron_schedules_monthly( $schedules ) {
$schedules['monthly'] = array(
'interval' => 2635200,
'display' => __( 'Once a month', 'paid-memberships-pro' ),
);
return $schedules;
}
add_filter( 'cron_schedules', 'pmpro_cron_schedules_monthly' );
// activation
function pmpro_activation() {
pmpro_maybe_schedule_crons();
pmpro_set_capabilities_for_role( 'administrator', 'enable' );
do_action( 'pmpro_activation' );
}
// deactivation
function pmpro_deactivation() {
// remove crons
pmpro_clear_crons();
// remove caps from admin role
pmpro_set_capabilities_for_role( 'administrator', 'disable' );
do_action( 'pmpro_deactivation' );
}
register_activation_hook( __FILE__, 'pmpro_activation' );
register_deactivation_hook( __FILE__, 'pmpro_deactivation' );