Skip to content

Commit

Permalink
Updates to 1.11.29
Browse files Browse the repository at this point in the history
  • Loading branch information
MemberPress committed May 9, 2024
1 parent 6d6d8df commit 121db5c
Show file tree
Hide file tree
Showing 26 changed files with 405 additions and 194 deletions.
43 changes: 43 additions & 0 deletions app/controllers/MeprAppCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function load_hooks() {
add_filter('custom_menu_order', '__return_true');
add_filter('menu_order', 'MeprAppCtrl::admin_menu_order');
add_filter('menu_order', 'MeprAppCtrl::admin_submenu_order');
add_action('widgets_init', 'MeprAppCtrl::register_global_widget_area');
add_action('widgets_init', 'MeprAccountLinksWidget::register_widget');
add_action('widgets_init', 'MeprLoginWidget::register_widget');
add_action('widgets_init', 'MeprSubscriptionsWidget::register_widget');
Expand Down Expand Up @@ -536,6 +537,48 @@ public static function admin_submenu_order($menu_order)
return $menu_order;
}

public static function register_global_widget_area() {
register_sidebar( array(
'name' => _x('ReadyLaunch™️ General Footer', 'ui', 'memberpress'),
'description' => __( 'Widgets in this area will be shown at the bottom of all ReadyLaunch pages.', 'memberpress' ),
'id' => 'mepr_rl_global_footer',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );

register_sidebar( array(
'name' => _x('ReadyLaunch™️ Account Footer', 'ui', 'memberpress'),
'description' => __( 'Widgets in this area will be shown at the bottom of ReadyLaunch Account page.', 'memberpress' ),
'id' => 'mepr_rl_account_footer',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );

register_sidebar( array(
'name' => _x('ReadyLaunch™️ Login Footer', 'ui', 'memberpress'),
'description' => __( 'Widgets in this area will be shown at the bottom of ReadyLaunch Login page.', 'memberpress' ),
'id' => 'mepr_rl_login_footer',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );

register_sidebar( array(
'name' => _x('ReadyLaunch™️ Registration Footer', 'ui', 'memberpress'),
'description' => __( 'Widgets in this area will be shown at the bottom of ReadyLaunch Registration pages.', 'memberpress' ),
'id' => 'mepr_rl_registration_footer',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );
}

// Routes for wordpress pages -- we're just replacing content here folks.
public static function page_route($content) {
$current_post = MeprUtils::get_current_post();
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/MeprCheckoutCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,15 @@ public function display_#_form($product) {

if($mepr_options->enable_spc) {
if(MeprReadyLaunchCtrl::template_enabled( 'checkout' ) || MeprAppHelper::has_block( 'memberpress/checkout' )){
$is_rl_widget = ( is_active_sidebar( 'mepr_rl_registration_footer' ) || is_active_sidebar( 'mepr_rl_global_footer' ) );
MeprView::render('/readylaunch/checkout/form', get_defined_vars());
} else {
MeprView::render('/checkout/spc_form', get_defined_vars());
}
}
else {
if(MeprReadyLaunchCtrl::template_enabled( 'checkout' )){
$is_rl_widget = ( is_active_sidebar( 'mepr_rl_registration_footer' ) || is_active_sidebar( 'mepr_rl_global_footer' ) );
MeprView::render('/readylaunch/checkout/form', get_defined_vars());
} else {
MeprView::render('/checkout/form', get_defined_vars());
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/MeprCouponsCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static function save_postdata($post_id) {
$coupon->valid_products = isset($_POST[MeprCoupon::$valid_products_str])?$_POST[MeprCoupon::$valid_products_str]:array();
$coupon->discount_mode = sanitize_text_field($_POST[MeprCoupon::$discount_mode_str]);
$coupon->trial_days = isset($_POST[MeprCoupon::$trial_days_str])?(int)sanitize_text_field($_POST[MeprCoupon::$trial_days_str]):0;
$coupon->trial_amount = isset($_POST[MeprCoupon::$trial_amount_str]) ? MeprUtils::format_float( $_POST[MeprCoupon::$trial_amount_str] ) : 0.00;
$coupon->trial_amount = isset($_POST[MeprCoupon::$trial_amount_str]) ? (float) sanitize_text_field( $_POST[MeprCoupon::$trial_amount_str] ) : 0.00;
$coupon->store_meta();

MeprHooks::do_action('mepr-coupon-save-meta', $coupon);
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/MeprLoginCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,15 @@ public function display_reset_password_form($mepr_key, $mepr_screenname) {
$user = new MeprUser();
$user->load_user_data_by_login($mepr_screenname);

if($user->ID && $user->reset_form_key_is_valid($mepr_key)) {
$is_key_valid = $user->reset_form_key_is_valid($mepr_key);
if($user->ID && $is_key_valid) {
if(MeprReadyLaunchCtrl::template_enabled( 'login' )){
MeprView::render('/readylaunch/#/reset_password', get_defined_vars());
} else {
MeprView::render('/#/reset_password', get_defined_vars());
}
}
elseif($user->ID && $user->reset_form_key_has_expired($mepr_key)) {
elseif($user->ID && ($user->reset_form_key_has_expired($mepr_key) || ! $is_key_valid)) {
if(MeprReadyLaunchCtrl::template_enabled( 'login' )){
MeprView::render('/readylaunch/shared/expired_password_reset', get_defined_vars());
} else {
Expand Down
6 changes: 6 additions & 0 deletions app/data/stripe_payment_methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
'currencies' => ['MYR', 'SGD'],
'capabilities' => ['payment_intents'],
],
[
'key' => 'mobilepay',
'name' => 'MobilePay',
'currencies' => ['DKK', 'EUR', 'NOK', 'SEK'],
'capabilities' => ['payment_intents'],
],
[
'key' => 'wechat_pay',
'name' => 'WeChat Pay',
Expand Down
14 changes: 7 additions & 7 deletions app/data/taxes/vat_countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
'SE' => array( 'name' => __('Sweden', 'memberpress'), 'rate' => 25, 'reduced_rate' => 6, 'fmt' => '(SE)?[0-9]{12}' ),
'SI' => array( 'name' => __('Slovenia', 'memberpress'), 'rate' => 22, 'reduced_rate' => 5, 'fmt' => '(SI)?[0-9]{8}' ),
'SK' => array( 'name' => __('Slovakia', 'memberpress'), 'rate' => 20, 'fmt' => '(SK)?[0-9]{10}' ),
'GF' => array( 'name' => __('French Guiana', 'memberpress'), 'rate' => 20, 'reduced_rate' => 5.5, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'MF' => array( 'name' => __('Saint Martin (French part)', 'memberpress'), 'rate' => 20, 'reduced_rate' => 5.5, 'fmt' => '?[0-9A-Z]{2}[0-9]{9}' ),
'MQ' => array( 'name' => __('Martinique', 'memberpress'), 'rate' => 8.5, 'reduced_rate' => 2.1, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'RE' => array( 'name' => __('Reunion', 'memberpress'), 'rate' => 8.5, 'reduced_rate' => 2.1, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'YT' => array( 'name' => __('Mayotte', 'memberpress'), 'rate' => 20, 'reduced_rate' => 5.5, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'PM' => array( 'name' => __('Saint Pierre and Miquelon', 'memberpress'), 'rate' => 20, 'reduced_rate' => 5.5, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'GP' => array( 'name' => __('Guadeloupe', 'memberpress'), 'rate' => 8.5, 'reduced_rate' => 2.1, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'GF' => array( 'name' => __('French Guiana', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'MF' => array( 'name' => __('Saint Martin (French part)', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '?[0-9A-Z]{2}[0-9]{9}' ),
'MQ' => array( 'name' => __('Martinique', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'RE' => array( 'name' => __('Reunion', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'YT' => array( 'name' => __('Mayotte', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'PM' => array( 'name' => __('Saint Pierre and Miquelon', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'GP' => array( 'name' => __('Guadeloupe', 'memberpress'), 'rate' => 0, 'reduced_rate' => 0, 'fmt' => '[0-9A-Z]{2}[0-9]{9}' ),
'MC' => array( 'name' => __('Monaco', 'memberpress'), 'rate' => 20, 'reduced_rate' => 5.5, 'fmt' => '(FR)?[0-9A-Z]{2}[0-9]{9}' ),
) );
24 changes: 18 additions & 6 deletions app/gateways/MeprStripeGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public function get_setup_intent_payment_method_types() {

$types = MeprHooks::apply_filters('mepr_stripe_setup_intent_payment_method_types', $types);

return $this->filter_incompatible_payment_method_types($types);
return $this->filter_incompatible_payment_method_types(array_unique($types));
}

/**
Expand Down Expand Up @@ -778,7 +778,7 @@ public function get_payment_intent_payment_method_types($setup_future_usage = nu

$types = MeprHooks::apply_filters('mepr_stripe_payment_intent_payment_method_types', $types);

return $this->filter_incompatible_payment_method_types($types, $amount);
return $this->filter_incompatible_payment_method_types(array_unique($types), $amount);
}

/**
Expand All @@ -800,7 +800,7 @@ public function get_subscription_payment_method_types() {

$types = MeprHooks::apply_filters('mepr_stripe_subscription_payment_method_types', $types);

return $this->filter_incompatible_payment_method_types($types);
return $this->filter_incompatible_payment_method_types(array_unique($types));
}

/**
Expand All @@ -822,7 +822,7 @@ public function get_update_setup_intent_payment_method_types() {

$types = MeprHooks::apply_filters('mepr_stripe_update_setup_intent_payment_method_types', $types);

return $this->filter_incompatible_payment_method_types($types);
return $this->filter_incompatible_payment_method_types(array_unique($types));
}

/**
Expand Down Expand Up @@ -1041,7 +1041,7 @@ public function record_subscription_payment() {
* Silent Post from Authorize.net.
*/
public function record_sub_payment(MeprSubscription $sub, $amount, $trans_num, $payment_method = null, $txn_expires_at_override = null, $order_id = 0) {
if(strpos($trans_num, 'ch_') === 0 && MeprTransaction::txn_exists($trans_num)) {
if(self::is_charge_object_id($trans_num) && MeprTransaction::txn_exists($trans_num)) {
return;
}

Expand Down Expand Up @@ -1090,7 +1090,7 @@ public function record_sub_payment(MeprSubscription $sub, $amount, $trans_num, $
// just cancel the subscr when limit_cycles_num is hit
$sub->limit_payment_cycles();

if(strpos($trans_num, 'ch_') === 0) {
if(self::is_charge_object_id($trans_num)) {
// Update Stripe Metadata Asynchronously
$job = new MeprUpdateStripeMetadataJob();
$job->gateway_settings = $this->settings;
Expand Down Expand Up @@ -4876,4 +4876,16 @@ private function record_cc_vars($sub, $payment_method) {
$sub->cc_exp_year = $payment_method->card['exp_year'];
}
}

/**
* Is the given ID a Charge object ID?
*
* A Charge object ID starts with either ch_ or py_.
*
* @param string $id The ID to check.
* @return bool
*/
private static function is_charge_object_id($id) {
return strpos($id, 'ch_') === 0 || strpos($id, 'py_') === 0;
}
}
17 changes: 3 additions & 14 deletions app/gateways/stripe/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,20 +522,9 @@
var stripe = Stripe(result.public_key);
return stripe.redirectToCheckout({ sessionId: result.id });
})
.fail(function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 0) {
// Don't send a debug email for errors with status 0
self.handlePaymentError(MeprStripeGateway.error_please_try_again);
} else {
self.handlePaymentError(MeprStripeGateway.ajax_error);
self.debugCheckoutError({
status: jqXHR.status,
status_text: jqXHR.statusText,
response_text: jqXHR.responseText,
text_status: textStatus,
error_thrown: '' + errorThrown
});
}
.fail(function () {
self.allowResubmission();
self.$form.find('.mepr-stripe-checkout-errors').html(MeprStripeGateway.error_please_try_again);
});
};

Expand Down
7 changes: 7 additions & 0 deletions app/helpers/MeprAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,13 @@ public static function wp_kses( $content, $allowed_tags = array() ) {
'src' => array(),
'width' => array(),
),
'form' => array(
'id' => array(),
'class' => array(),
'name' => array(),
'action' => array(),
'method' => array(),
),
'li' => array(
'class' => array(),
),
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/MeprOptionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function payment_currencies_dropdown($field_name, $payment_currenc
}

public static function payment_currency_code_dropdown($field_name, $code) {
$codes = MeprHooks::apply_filters('mepr-currency-codes', array('USD', 'AED', 'AUD', 'AWG', 'BGN', 'BRL', 'BWP', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CVE', 'CZK', 'DKK', 'EUR', 'GBP', 'GHS', 'HKD', 'HRK', 'HUF', 'HUN', 'IDR', 'ILS', 'INR', 'ISK', 'JOD', 'JPY', 'KES', 'KRW', 'LYD', 'MAD', 'MMK', 'MXN', 'MYR', 'NGN', 'NOK', 'NZD', 'PEN', 'PHP', 'PKR', 'PLN', 'RON', 'RSD', 'RUB', 'SAR', 'SEK', 'SGD', 'THB', 'TRY', 'TWN', 'UGX', 'VND', 'XOF', 'ZAR', 'ZMW'));
$codes = MeprHooks::apply_filters('mepr-currency-codes', array('USD', 'AED', 'AUD', 'AWG', 'BGN', 'BRL', 'BWP', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CVE', 'CZK', 'DKK', 'EUR', 'GBP', 'GHS', 'HKD', 'HRK', 'HUF', 'HUN', 'IDR', 'ILS', 'INR', 'ISK', 'JOD', 'JPY', 'KES', 'KRW', 'LYD', 'MAD', 'MMK', 'MXN', 'MYR', 'NGN', 'NOK', 'NZD', 'PEN', 'PHP', 'PKR', 'PLN', 'RON', 'RSD', 'RUB', 'SAR', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'UGX', 'VND', 'XOF', 'ZAR', 'ZMW'));
$field_value = isset($_POST[$field_name])?$_POST[$field_name]:null;

?>
Expand Down
4 changes: 2 additions & 2 deletions app/lib/MeprDrmAppFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function get_stripe_connected_payment_methods() {
$methods = array();

foreach( $pmt_methods as $key => $method ) {
if( $method instanceof MeprStripeGateway && MeprStripeGateway::is_stripe_connect( $method ) ) {
if( $method instanceof MeprStripeGateway && MeprStripeGateway::is_stripe_connect( $key ) ) {
$methods[] = $key;
}
}
Expand Down Expand Up @@ -178,4 +178,4 @@ public function process_subscriptions_fee( $subscriptions, $api_version, $curren

return $updated;
}
} //End class
} //End class
2 changes: 1 addition & 1 deletion app/models/MeprCoupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function is_valid($product_id) {
}
}

return apply_filters('mepr_coupon_is_valid', true); // If we made it here, the coupon is good
return apply_filters('mepr_coupon_is_valid', true, $this, $product_id); // If we made it here, the coupon is good
}

//Hmmm...maybe this method should be moved to the Coupon Ctrl instead
Expand Down
75 changes: 38 additions & 37 deletions app/views/admin/emails/options.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');} ?>

<p id="config-<?php echo $email->dashed_name(); ?>" class="mepr-config-email-row">
<div id="config-<?php echo $email->dashed_name(); ?>" class="mepr-config-email-row">
<label for="<?php echo $email->field_name('enabled', true); ?>">
<input type="checkbox"
name="<?php echo $email->field_name('enabled'); ?>"
Expand Down Expand Up @@ -30,42 +30,43 @@ class="mepr-reset-email button"
data-use-template-id="<?php echo $email->field_name('use_template', true); ?>"
data-body-id="<?php echo $email->field_name('body', true); ?>"><?php _e('Reset to Default', 'memberpress'); ?></a>
<img src="<?php echo MEPR_IMAGES_URL . '/square-loader.gif'; ?>" alt="<?php _e('Loading...', 'memberpress'); ?>" id="mepr-loader-<?php echo $email->dashed_name(); ?>" class="mepr_loader" />
</p>
<div id="edit-<?php echo $email->dashed_name(); ?>" class="mepr-hidden mepr-options-pane mepr-edit-email">
<ul>
<li>
<span class="mepr-field-label"><?php _e('Subject', 'memberpress'); ?></span><br/>
<input class="form-field" type="text" id="<?php echo $email->field_name('subject', true); ?>" name="<?php echo $email->field_name('subject'); ?>" value="<?php echo $email->subject(); ?>" />
</li>
<li>
<span class="mepr-field-label"><?php _e('Body', 'memberpress'); ?></span><br/>
<?php wp_editor( $email->body(),
$email->field_name('body', true),
array( 'textarea_name' => $email->field_name('body') )
); ?>
</li>
<li>
<select id="var-<?php echo $email->dashed_name(); ?>">
<?php foreach( $email->variables as $var ): ?>
<option value="{$<?php echo $var; ?>}">{$<?php echo $var; ?>}</option>
<?php endforeach; ?>
</select>

<a href="#" class="button mepr-insert-email-var" data-variable-id="var-<?php echo $email->dashed_name(); ?>"
data-textarea-id="<?php echo $email->field_name('body', true); ?>"><?php _e('Insert &uarr;', 'memberpress'); ?></a>
</li>
<li>
<br/>
<input type="checkbox"
name="<?php echo $email->field_name('use_template'); ?>"
id="<?php echo $email->field_name('use_template', true); ?>"<?php checked($email->use_template()); ?>/>
<span class="mepr-field-label">
<?php _e('Use default template', 'memberpress'); ?>
<?php MeprAppHelper::info_tooltip( $email->dashed_name() . '-template',
__('Default Email Template', 'memberpress'),
__('When this is checked the body of this email will be wrapped in the default email template.', 'memberpress') ); ?>
</span>
</li>
</ul>
<div id="edit-<?php echo $email->dashed_name(); ?>" class="mepr-hidden mepr-options-pane mepr-edit-email">
<ul>
<li>
<span class="mepr-field-label"><?php _e('Subject', 'memberpress'); ?></span><br/>
<input class="form-field" type="text" id="<?php echo $email->field_name('subject', true); ?>" name="<?php echo $email->field_name('subject'); ?>" value="<?php echo $email->subject(); ?>" />
</li>
<li>
<span class="mepr-field-label"><?php _e('Body', 'memberpress'); ?></span><br/>
<?php wp_editor( $email->body(),
$email->field_name('body', true),
array( 'textarea_name' => $email->field_name('body') )
); ?>
</li>
<li>
<select id="var-<?php echo $email->dashed_name(); ?>">
<?php foreach( $email->variables as $var ): ?>
<option value="{$<?php echo $var; ?>}">{$<?php echo $var; ?>}</option>
<?php endforeach; ?>
</select>

<a href="#" class="button mepr-insert-email-var" data-variable-id="var-<?php echo $email->dashed_name(); ?>"
data-textarea-id="<?php echo $email->field_name('body', true); ?>"><?php _e('Insert &uarr;', 'memberpress'); ?></a>
</li>
<li>
<br/>
<input type="checkbox"
name="<?php echo $email->field_name('use_template'); ?>"
id="<?php echo $email->field_name('use_template', true); ?>"<?php checked($email->use_template()); ?>/>
<span class="mepr-field-label">
<?php _e('Use default template', 'memberpress'); ?>
<?php MeprAppHelper::info_tooltip( $email->dashed_name() . '-template',
__('Default Email Template', 'memberpress'),
__('When this is checked the body of this email will be wrapped in the default email template.', 'memberpress') ); ?>
</span>
</li>
</ul>
</div>
</div>

4 changes: 4 additions & 0 deletions app/views/#/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<?php else: ?>
<?php echo $message; ?>
<?php MeprHooks::do_action('mepr-before-login-form'); ?>
<!-- mp-login-form-start --> <?php //DON'T GET RID OF THIS HTML COMMENT PLEASE IT'S USEFUL FOR SOME REGEX WE'RE DOING ?>
<form name="mepr_loginform" id="mepr_loginform" class="mepr-form" action="<?php echo esc_url($login_url); ?>" method="post">
<?php /* nonce not necessary on this form seeing as the user isn't logged in yet */ ?>
Expand Down Expand Up @@ -59,6 +60,9 @@
<div class="mepr-login-actions">
<a href="<?php echo esc_url($forgot_password_url); ?>"><?php _ex('Forgot Password', 'ui', 'memberpress'); ?></a>
</div>

<?php MeprHooks::do_action('mepr-login-form-after-submit'); ?>

<!-- mp-login-form-end --> <?php //DON'T GET RID OF THIS HTML COMMENT PLEASE IT'S USEFUL FOR SOME REGEX WE'RE DOING ?>

<?php endif; ?>
Expand Down
Loading

0 comments on commit 121db5c

Please # to comment.