Skip to content

Commit

Permalink
Updates to 1.11.20
Browse files Browse the repository at this point in the history
  • Loading branch information
MemberPress committed Nov 14, 2023
1 parent 317fd08 commit 8171329
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 134 deletions.
9 changes: 9 additions & 0 deletions app/controllers/MeprActiveInactiveHooksCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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) {
Expand Down Expand Up @@ -87,4 +88,12 @@ public function handle_txn_expired($txn, $sub_status = false) {
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);
}
}
} // End Class
1 change: 1 addition & 0 deletions app/controllers/MeprCouponsCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function register_post_type() {
'labels' => array(
'name' => __('Coupons', 'memberpress'),
'singular_name' => __('Coupon', 'memberpress'),
'add_new' => __('Add New', 'memberpress'),
'add_new_item' => __('Add New Coupon', 'memberpress'),
'edit_item' => __('Edit Coupon', 'memberpress'),
'new_item' => __('New Coupon', 'memberpress'),
Expand Down
1 change: 1 addition & 0 deletions app/controllers/MeprGroupsCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function register_post_type() {
'labels' => array(
'name' => __('Groups', 'memberpress'),
'singular_name' => __('Group', 'memberpress'),
'add_new' => __('Add New', 'memberpress'),
'add_new_item' => __('Add New Group', 'memberpress'),
'edit_item' => __('Edit Group', 'memberpress'),
'new_item' => __('New Group', 'memberpress'),
Expand Down
1 change: 1 addition & 0 deletions app/controllers/MeprProductsCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function register_post_type() {
'labels' => array(
'name' => __('Memberships', 'memberpress'),
'singular_name' => __('Membership', 'memberpress'),
'add_new' => __('Add New', 'memberpress'),
'add_new_item' => __('Add New Membership', 'memberpress'),
'edit_item' => __('Edit Membership', 'memberpress'),
'new_item' => __('New Membership', 'memberpress'),
Expand Down
1 change: 1 addition & 0 deletions app/controllers/MeprRemindersCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function register_post_type() {
'labels' => array(
'name' => __('Reminders', 'memberpress'),
'singular_name' => __('Reminder', 'memberpress'),
'add_new' => __('Add New', 'memberpress'),
'add_new_item' => __('Add New Reminder', 'memberpress'),
'edit_item' => __('Edit Reminder', 'memberpress'),
'new_item' => __('New Reminder', 'memberpress'),
Expand Down
1 change: 1 addition & 0 deletions app/controllers/MeprRulesCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function register_post_type() {
'labels' => array(
'name' => __('Rules', 'memberpress'),
'singular_name' => __('Rule', 'memberpress'),
'add_new' => __('Add New', 'memberpress'),
'add_new_item' => __('Add New Rule', 'memberpress'),
'edit_item' => __('Edit Rule', 'memberpress'),
'new_item' => __('New Rule', 'memberpress'),
Expand Down
8 changes: 6 additions & 2 deletions app/lib/MeprBaseGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ public function upgraded_sub($obj, $event_txn) {
MeprHooks::do_action("mepr-upgraded-{$type}-sub", $obj);
MeprHooks::do_action("mepr-upgraded-sub", $type, $obj);
MeprHooks::do_action("mepr-sub-created", $type, $obj, 'upgraded');
MeprUtils::send_upgraded_sub_notices($obj);
if( MeprHooks::apply_filters('mepr_send_upgraded_sub_notices', true, $obj, $event_txn)) {
MeprUtils::send_upgraded_sub_notices($obj);
}
MeprUtils::record_upgraded_sub_events($obj, $event_txn);
}
}
Expand All @@ -621,7 +623,9 @@ public function downgraded_sub($obj, $event_txn) {
MeprHooks::do_action("mepr-downgraded-{$type}-sub", $obj);
MeprHooks::do_action("mepr-downgraded-sub", $type, $obj);
MeprHooks::do_action("mepr-sub-created", $type, $obj, 'downgraded');
MeprUtils::send_downgraded_sub_notices($obj);
if( MeprHooks::apply_filters('mepr_send_downgraded_sub_notices', true, $obj, $event_txn) ) {
MeprUtils::send_downgraded_sub_notices($obj);
}
MeprUtils::record_downgraded_sub_events($obj, $event_txn);
}
}
Expand Down
52 changes: 49 additions & 3 deletions app/lib/MeprUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public function uuid($regenerate=false) {
* @return array
*/
public function snapshot() {
global $wpdb, $mepr_update;

$mepr_options = MeprOptions::fetch();

$txn_stats = MeprReports::transaction_stats();
Expand Down Expand Up @@ -62,7 +60,8 @@ public function snapshot() {
'uuid' => $this->uuid(),
'mp_version' => MEPR_VERSION,
'php_version' => phpversion(),
'mysql_version' => $wpdb->db_version(),
'mysql_version' => $this->get_database_version(),
'db_provider' => $this->get_database_provider(),
'os' => (function_exists('php_uname')) ? php_uname('s') : '',
'webserver' => $_SERVER["SERVER_SOFTWARE"],
'active_license' => MeprUpdateCtrl::is_activated(),
Expand Down Expand Up @@ -466,4 +465,51 @@ private function get_theme_data($theme) {
);
}

/**
* Get the database version.
*
* @return string
*/
private function get_database_version() {
global $wpdb;

$db_version = $wpdb->db_version();

if(method_exists($wpdb, 'db_server_info')) {
$db_server_info = $wpdb->db_server_info();

// Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
if(
'5.5.5' === $db_version &&
is_string($db_server_info) &&
strpos($db_server_info, 'MariaDB') !== false &&
PHP_VERSION_ID < 80016 // PHP 8.0.15 or older.
) {
// Strip the '5.5.5-' prefix and set the version to the correct value.
$db_server_info = preg_replace('/^5\.5\.5-(.*)/', '$1', $db_server_info);
$db_version = preg_replace('/[^0-9.].*/', '', $db_server_info);
}
}

return $db_version;
}

/**
* Get the database provider.
*
* @return string
*/
private function get_database_provider() {
global $wpdb;

if(method_exists($wpdb, 'db_server_info')) {
$db_server_info = $wpdb->db_server_info();

if(is_string($db_server_info) && strpos($db_server_info, 'MariaDB') !== false) {
return 'MariaDB';
}
}

return 'MySQL';
}
} //End class
3 changes: 2 additions & 1 deletion app/lib/MeprUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,7 @@ public static function get_edition($product_slug) {
array('index' => 6, 'slug' => 'memberpress-pro-5', 'name' => 'MemberPress Pro'),
array('index' => 7, 'slug' => 'memberpress-reseller', 'name' => 'MemberPress Reseller'),
array('index' => 8, 'slug' => 'memberpress-oem', 'name' => 'MemberPress OEM'),
array('index' => 9, 'slug' => 'memberpress-elite', 'name' => 'MemberPress Elite'),
);

if(preg_match('/^memberpress-reseller-.+$/', $product_slug)) {
Expand Down Expand Up @@ -2387,7 +2388,7 @@ public static function is_pro_edition($product_slug) {
return false;
}

return in_array($product_slug, ['memberpress-pro', 'memberpress-pro-5'], true) || MeprUtils::is_oem_edition($product_slug);
return in_array($product_slug, ['memberpress-pro', 'memberpress-pro-5', 'memberpress-elite'], true) || MeprUtils::is_oem_edition($product_slug);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/models/MeprOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function set_defaults() {
}

if(!isset( $this->rl_enable_coaching_template ) ){
$this->rl_enable_coaching_template = false;
$this->rl_enable_coaching_template = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/options/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
<label for="<?php echo $mepr_options->tos_title_str; ?>"><?php _e('Terms of Service Checkbox Title:', 'memberpress'); ?></label>
</div>
<div class="mp-col-4">
<input type="text" id="<?php echo $mepr_options->tos_title_str; ?>" name="<?php echo $mepr_options->tos_title_str; ?>" class="regular-text" value="<?php echo stripslashes($mepr_options->tos_title); ?>" />
<input type="text" id="<?php echo $mepr_options->tos_title_str; ?>" name="<?php echo $mepr_options->tos_title_str; ?>" class="regular-text" value="<?php echo esc_attr(stripslashes($mepr_options->tos_title)); ?>" />
</div>
</div>
</div>
Expand Down Expand Up @@ -380,7 +380,7 @@
__('This will appear next to the Privacy Policy checkbox on membership registration forms. The text between % characters will become the link text to your Privacy Policy page.', 'memberpress') ); ?>
</div>
<div class="mp-col-4">
<input type="text" id="<?php echo $mepr_options->privacy_policy_title_str; ?>" name="<?php echo $mepr_options->privacy_policy_title_str; ?>" class="regular-text" value="<?php echo stripslashes($mepr_options->privacy_policy_title); ?>" />
<input type="text" id="<?php echo $mepr_options->privacy_policy_title_str; ?>" name="<?php echo $mepr_options->privacy_policy_title_str; ?>" class="regular-text" value="<?php echo esc_attr(stripslashes($mepr_options->privacy_policy_title)); ?>" />
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/checkout/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<div class="mp-form-row mepr_tos">
<label for="mepr_agree_to_tos<?php echo $unique_suffix; ?>" class="mepr-checkbox-field mepr-form-input" required>
<input type="checkbox" name="mepr_agree_to_tos" id="mepr_agree_to_tos<?php echo $unique_suffix; ?>" <?php checked(isset($mepr_agree_to_tos)); ?> />
<a href="<?php echo stripslashes($mepr_options->tos_url); ?>" target="_blank" rel="noopener noreferrer"><?php echo stripslashes($mepr_options->tos_title); ?></a>*
<a href="<?php echo stripslashes($mepr_options->tos_url); ?>" target="_blank" rel="noopener noreferrer"><?php echo wp_kses_post( stripslashes($mepr_options->tos_title) ); ?></a>*
</label>
</div>
<?php endif; ?>
Expand All @@ -167,7 +167,7 @@
<div class="mp-form-row">
<label for="mepr_agree_to_privacy_policy<?php echo $unique_suffix; ?>" class="mepr-checkbox-field mepr-form-input" required>
<input type="checkbox" name="mepr_agree_to_privacy_policy" id="mepr_agree_to_privacy_policy<?php echo $unique_suffix; ?>" />
<?php echo preg_replace('/%(.*)%/', '<a href="' . $privacy_page_link . '" target="_blank">$1</a>', __($mepr_options->privacy_policy_title, 'memberpress')); ?>
<?php echo preg_replace('/%(.*)%/', '<a href="' . $privacy_page_link . '" target="_blank">$1</a>', wp_kses_post(__($mepr_options->privacy_policy_title, 'memberpress'))); ?>
</label>
</div>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions app/views/checkout/spc_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<div class="mp-form-row mepr_tos">
<label for="mepr_agree_to_tos<?php echo $unique_suffix; ?>" class="mepr-checkbox-field mepr-form-input" required>
<input type="checkbox" name="mepr_agree_to_tos" id="mepr_agree_to_tos<?php echo $unique_suffix; ?>" <?php checked(isset($mepr_agree_to_tos)); ?> />
<a href="<?php echo stripslashes($mepr_options->tos_url); ?>" target="_blank" rel="noopener noreferrer"><?php echo stripslashes($mepr_options->tos_title); ?></a>*
<a href="<?php echo stripslashes($mepr_options->tos_url); ?>" target="_blank" rel="noopener noreferrer"><?php echo wp_kses_post(stripslashes($mepr_options->tos_title)); ?></a>*
</label>
</div>
<?php endif; ?>
Expand All @@ -201,7 +201,7 @@
<div class="mp-form-row">
<label for="mepr_agree_to_privacy_policy<?php echo $unique_suffix; ?>" class="mepr-checkbox-field mepr-form-input" required>
<input type="checkbox" name="mepr_agree_to_privacy_policy" id="mepr_agree_to_privacy_policy<?php echo $unique_suffix; ?>" />
<?php echo preg_replace('/%(.*)%/', '<a href="' . $privacy_page_link . '" target="_blank">$1</a>', __($mepr_options->privacy_policy_title, 'memberpress')); ?>
<?php echo preg_replace('/%(.*)%/', '<a href="' . $privacy_page_link . '" target="_blank">$1</a>', wp_kses_post(__($mepr_options->privacy_policy_title, 'memberpress'))); ?>
</label>
</div>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions app/views/readylaunch/checkout/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class="mepr-form-input mepr-password"
<input type="checkbox" name="mepr_agree_to_tos" id="mepr_agree_to_tos<?php echo $unique_suffix; ?>"
<?php checked( isset( $mepr_agree_to_tos ) ); ?> />
<a href="<?php echo stripslashes( $mepr_options->tos_url ); ?>" target="_blank"
rel="noopener noreferrer"><?php echo stripslashes( $mepr_options->tos_title ); ?></a>*
rel="noopener noreferrer"><?php echo wp_kses_post(stripslashes( $mepr_options->tos_title )); ?></a>*
</label>
</div>
<?php endif; ?>
Expand All @@ -241,7 +241,7 @@ class="mepr-form-input mepr-password"
class="mepr-checkbox-field mepr-form-input" required>
<input type="checkbox" name="mepr_agree_to_privacy_policy"
id="mepr_agree_to_privacy_policy<?php echo $unique_suffix; ?>" />
<?php echo preg_replace( '/%(.*)%/', '<a href="' . $privacy_page_link . '" target="_blank">$1</a>', __( $mepr_options->privacy_policy_title, 'memberpress' ) ); ?>
<?php echo preg_replace( '/%(.*)%/', '<a href="' . $privacy_page_link . '" target="_blank">$1</a>', wp_kses_post(__( $mepr_options->privacy_policy_title, 'memberpress' ) ) ); ?>
</label>
</div>
<?php endif; ?>
Expand Down

0 comments on commit 8171329

Please sign in to comment.