-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MemberPress
committed
Sep 26, 2024
1 parent
fa2c5af
commit d8ac83d
Showing
510 changed files
with
74,504 additions
and
67,829 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
<?php | ||
if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');} | ||
|
||
class MeprAccountLoginCtrl extends MeprBaseCtrl { | ||
public function load_hooks() { | ||
add_filter('submenu_file', array($this, 'highlight_menu_item')); | ||
} | ||
if (!defined('ABSPATH')) { | ||
die('You are not allowed to call this page directly.'); | ||
} | ||
|
||
public function highlight_menu_item($submenu_file) { | ||
global $current_screen; | ||
class MeprAccountLoginCtrl extends MeprBaseCtrl | ||
{ | ||
public function load_hooks() | ||
{ | ||
add_filter('submenu_file', [$this, 'highlight_menu_item']); | ||
} | ||
|
||
// Remove the "Account Login" menu item on all pages | ||
remove_submenu_page('memberpress', 'memberpress-account-login'); | ||
public function highlight_menu_item($submenu_file) | ||
{ | ||
global $current_screen; | ||
|
||
// Set the highlighted menu item to "Settings" | ||
if ($current_screen instanceof WP_Screen && $current_screen->id == 'memberpress_page_memberpress-account-login') { | ||
$submenu_file = 'memberpress-options'; | ||
} | ||
// Remove the "Account Login" menu item on all pages | ||
remove_submenu_page('memberpress', 'memberpress-account-login'); | ||
|
||
return $submenu_file; | ||
} | ||
// Set the highlighted menu item to "Settings" | ||
if ($current_screen instanceof WP_Screen && $current_screen->id == 'memberpress_page_memberpress-account-login') { | ||
$submenu_file = 'memberpress-options'; | ||
} | ||
|
||
public static function route() { | ||
$account_email = get_option('mepr_authenticator_account_email'); | ||
$secret = get_option('mepr_authenticator_secret_token'); | ||
$site_uuid = get_option('mepr_authenticator_site_uuid'); | ||
return $submenu_file; | ||
} | ||
|
||
MeprView::render('/admin/account-login/ui', get_defined_vars()); | ||
} | ||
public static function route() | ||
{ | ||
$account_email = get_option('mepr_authenticator_account_email'); | ||
$secret = get_option('mepr_authenticator_secret_token'); | ||
$site_uuid = get_option('mepr_authenticator_site_uuid'); | ||
|
||
MeprView::render('/admin/account-login/ui', get_defined_vars()); | ||
} | ||
} //End class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,112 @@ | ||
<?php | ||
if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');} | ||
/* | ||
** Added in MP 1.7.3 | ||
** USED FOR OUR AUTORESPONDER ADD-ONS - So we can have the active/inactive logic all in one place | ||
*/ | ||
class MeprActiveInactiveHooksCtrl extends MeprBaseCtrl { | ||
public function load_hooks() { | ||
add_action('mepr-txn-store', array($this, 'handle_txn_store'), 99, 2); | ||
add_action('mepr-txn-expired', array($this, 'handle_txn_expired'), 11, 2); | ||
add_action( 'delete_user', array( $this, 'handle_delete_user' ) ); | ||
} | ||
|
||
public function handle_txn_store($txn, $old_txn) { | ||
// Already been here? | ||
if($old_txn->status == $txn->status) { return; } | ||
|
||
// Allow third party plugins to stop the running of the method | ||
if(MeprHooks::apply_filters('mepr-active-inactive-hooks-skip', false, $txn)){ | ||
return; | ||
} | ||
|
||
// Bail if no id's | ||
if(!isset($txn->id) || $txn->id <= 0 || !isset($txn->user_id) || $txn->user_id <= 0) { return; } | ||
|
||
// Ignore "pending" txns | ||
if(!isset($txn->status) || empty($txn->status) || $txn->status == MeprTransaction::$pending_str) { return; } | ||
|
||
$active_status = array(MeprTransaction::$complete_str, MeprTransaction::$confirmed_str); | ||
$now = time(); | ||
$expires = 0; // Lifetime | ||
|
||
if ( ! empty( $txn->expires_at ) && $txn->expires_at != MeprUtils::db_lifetime() ) { | ||
$expires = strtotime($txn->expires_at); | ||
} | ||
|
||
if(in_array($txn->status, $active_status)) { | ||
if($expires === 0 || $expires >= $now) { | ||
MeprHooks::do_action('mepr-account-is-active', $txn); | ||
} | ||
else { | ||
MeprHooks::do_action('mepr-account-is-inactive', $txn); | ||
} | ||
} | ||
else { | ||
MeprHooks::do_action('mepr-account-is-inactive', $txn); | ||
} | ||
} | ||
|
||
public function handle_txn_expired($txn, $sub_status = false) { | ||
global $wpdb; | ||
|
||
// Part of an Enabled subscription, so let's bail | ||
if($sub_status == MeprSubscription::$active_str) { | ||
return; | ||
if (!defined('ABSPATH')) { | ||
die('You are not allowed to call this page directly.'); | ||
} | ||
/* | ||
** Added in MP 1.7.3 | ||
** USED FOR OUR AUTORESPONDER ADD-ONS - So we can have the active/inactive logic all in one place | ||
*/ | ||
class MeprActiveInactiveHooksCtrl extends MeprBaseCtrl | ||
{ | ||
public function load_hooks() | ||
{ | ||
add_action('mepr-txn-store', [$this, 'handle_txn_store'], 99, 2); | ||
add_action('mepr-txn-expired', [$this, 'handle_txn_expired'], 11, 2); | ||
add_action('delete_user', [$this, 'handle_delete_user']); | ||
} | ||
|
||
// Allow third party plugins to stop the running of the method | ||
if(MeprHooks::apply_filters('mepr-active-inactive-hooks-skip', false, $txn)){ | ||
return; | ||
public function handle_txn_store($txn, $old_txn) | ||
{ | ||
// Already been here? | ||
if ($old_txn->status == $txn->status) { | ||
return; | ||
} | ||
|
||
// Allow third party plugins to stop the running of the method | ||
if (MeprHooks::apply_filters('mepr-active-inactive-hooks-skip', false, $txn)) { | ||
return; | ||
} | ||
|
||
// Bail if no id's | ||
if (!isset($txn->id) || $txn->id <= 0 || !isset($txn->user_id) || $txn->user_id <= 0) { | ||
return; | ||
} | ||
|
||
// Ignore "pending" txns | ||
if (!isset($txn->status) || empty($txn->status) || $txn->status == MeprTransaction::$pending_str) { | ||
return; | ||
} | ||
|
||
$active_status = [MeprTransaction::$complete_str, MeprTransaction::$confirmed_str]; | ||
$now = time(); | ||
$expires = 0; // Lifetime | ||
|
||
if (! empty($txn->expires_at) && $txn->expires_at != MeprUtils::db_lifetime()) { | ||
$expires = strtotime($txn->expires_at); | ||
} | ||
|
||
if (in_array($txn->status, $active_status)) { | ||
if ($expires === 0 || $expires >= $now) { | ||
MeprHooks::do_action('mepr-account-is-active', $txn); | ||
} else { | ||
MeprHooks::do_action('mepr-account-is-inactive', $txn); | ||
} | ||
} else { | ||
MeprHooks::do_action('mepr-account-is-inactive', $txn); | ||
} | ||
} | ||
|
||
// Bail if no id's | ||
if(!isset($txn->id) || $txn->id <= 0 || !isset($txn->user_id) || $txn->user_id <= 0) { return; } | ||
|
||
// Go directly to the database and maybe flush caches beforehand | ||
if(MeprHooks::apply_filters('mepr-autoresponder-flush-caches', true)) { | ||
wp_cache_flush(); | ||
$wpdb->flush(); | ||
} | ||
|
||
$query = $wpdb->prepare( | ||
"SELECT count(*) FROM {$wpdb->prefix}mepr_transactions WHERE user_id = %d AND product_id = %d AND status IN (%s, %s) AND (expires_at >= %s OR expires_at = %s)", | ||
$txn->user_id, | ||
$txn->product_id, | ||
MeprTransaction::$complete_str, | ||
MeprTransaction::$confirmed_str, | ||
MeprUtils::db_now(), | ||
MeprUtils::db_lifetime() | ||
); | ||
|
||
$active_on_membership = $wpdb->get_var($query); | ||
|
||
if($active_on_membership) { | ||
MeprHooks::do_action('mepr-account-is-active', $txn); | ||
} | ||
else { | ||
MeprHooks::do_action('mepr-account-is-inactive', $txn); | ||
public function handle_txn_expired($txn, $sub_status = false) | ||
{ | ||
global $wpdb; | ||
|
||
// Part of an Enabled subscription, so let's bail | ||
if ($sub_status == MeprSubscription::$active_str) { | ||
return; | ||
} | ||
|
||
// Allow third party plugins to stop the running of the method | ||
if (MeprHooks::apply_filters('mepr-active-inactive-hooks-skip', false, $txn)) { | ||
return; | ||
} | ||
|
||
// Bail if no id's | ||
if (!isset($txn->id) || $txn->id <= 0 || !isset($txn->user_id) || $txn->user_id <= 0) { | ||
return; | ||
} | ||
|
||
// Go directly to the database and maybe flush caches beforehand | ||
if (MeprHooks::apply_filters('mepr-autoresponder-flush-caches', true)) { | ||
wp_cache_flush(); | ||
$wpdb->flush(); | ||
} | ||
|
||
$query = $wpdb->prepare( | ||
"SELECT count(*) FROM {$wpdb->prefix}mepr_transactions WHERE user_id = %d AND product_id = %d AND status IN (%s, %s) AND (expires_at >= %s OR expires_at = %s)", | ||
$txn->user_id, | ||
$txn->product_id, | ||
MeprTransaction::$complete_str, | ||
MeprTransaction::$confirmed_str, | ||
MeprUtils::db_now(), | ||
MeprUtils::db_lifetime() | ||
); | ||
|
||
$active_on_membership = $wpdb->get_var($query); | ||
|
||
if ($active_on_membership) { | ||
MeprHooks::do_action('mepr-account-is-active', $txn); | ||
} else { | ||
MeprHooks::do_action('mepr-account-is-inactive', $txn); | ||
} | ||
} | ||
} | ||
|
||
public function handle_delete_user($user_id) { | ||
$user = new MeprUser( $user_id ); | ||
$transactions = (array) $user->active_product_subscriptions( 'transactions', true, true ); | ||
foreach ($transactions as $transaction) { | ||
do_action('mepr-account-is-inactive', $transaction); | ||
public function handle_delete_user($user_id) | ||
{ | ||
$user = new MeprUser($user_id); | ||
$transactions = (array) $user->active_product_subscriptions('transactions', true, true); | ||
foreach ($transactions as $transaction) { | ||
do_action('mepr-account-is-inactive', $transaction); | ||
} | ||
} | ||
} | ||
} // End Class |
Oops, something went wrong.