Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/simple-membership/classes/class.simple-wp-membership.php
+++ b/simple-membership/classes/class.simple-wp-membership.php
@@ -923,7 +923,6 @@
wp_register_script('jquery.validationEngine', SIMPLE_WP_MEMBERSHIP_URL . '/js/jquery.validationEngine.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
wp_register_script('jquery.validationEngine-en', SIMPLE_WP_MEMBERSHIP_URL . '/js/jquery.validationEngine-en.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
wp_register_script('swpm.validationEngine-localization', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.validationEngine-localization.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
- wp_register_script('swpm.password-toggle', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.password-toggle.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
wp_register_script('swpm-reg-form-validator', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm-reg-form-validator.js', null, SIMPLE_WP_MEMBERSHIP_VER, true);
wp_register_script('swpm-profile-form-validator', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm-profile-form-validator.js', null, SIMPLE_WP_MEMBERSHIP_VER, true);
@@ -1093,6 +1092,39 @@
wp_localize_script('jquery.validationEngine-en', 'swpmRegForm', array('nonce' => $nonce));
}
+ public static function enqueue_password_toggle_scripts( $handle, $params = array() ) {
+ if ( ! wp_script_is( $handle, 'registered' ) ) {
+ wp_register_script( $handle, SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.password-toggle.js', null , SIMPLE_WP_MEMBERSHIP_VER);
+ }
+
+ wp_localize_script( $handle, 'swpmPasswordToggleStrings', array(
+ 'showPassword' => __('Show Password', 'simple-membership'),
+ ));
+
+ wp_enqueue_script( $handle );
+
+ $params = wp_parse_args($params, array(
+ 'type' => '',
+ 'formId' => '',
+ 'passwordInputSelectors' => "input[type='password']",
+ 'passwordInputSelectorsToAttach' => "input[type='password']",
+ 'checkboxTogglerSelector' => '',
+ 'checkboxTogglerStyles' => [],
+ ));
+
+ wp_print_inline_script_tag( '
+ document.addEventListener("DOMContentLoaded", function () {
+ new SWPM_Password_Visibility_Toggler({
+ type: "'.esc_js($params['type']).'",
+ formId: "'.esc_js($params['formId']).'",
+ passwordInputSelectors: "'.esc_js($params['passwordInputSelectors']).'",
+ passwordInputSelectorsToAttach: "'.esc_js($params['passwordInputSelectorsToAttach']).'",
+ checkboxTogglerSelector: "'.esc_js($params['checkboxTogglerSelector']).'",
+ checkboxTogglerStyles: '.json_encode($params['checkboxTogglerStyles']).',
+ });
+ });
+ ');
+ }
public function menu() {
$menu_parent_slug = 'simple_wp_membership';
--- a/simple-membership/classes/class.swpm-installation.php
+++ b/simple-membership/classes/class.swpm-installation.php
@@ -353,7 +353,16 @@
}
if (version_compare($installed_version, SIMPLE_WP_MEMBERSHIP_VER) == -1) {
- //Do upgrade tasks
+ //Upgrade path. Tasks for existing users of the plugin.
+
+ /**
+ * Backwards compatibility: Set login form password visibility toggler style to 'checkbox' type if before updating the plugin the login form password toggler was already enabled.
+ * Also check if the toggler style wasn't set before, so that it doesn't update the value on every plugin upgrade scenario.
+ */
+ if (!empty($settings->get_value('password-visibility-login-form')) && $settings->get_value('password-visibility-toggler-style-login-form', '') == ''){
+ $settings->set_value("password-visibility-toggler-style-login-form", "checkbox");
+ }
+
}
//save everything.
--- a/simple-membership/classes/class.swpm-settings.php
+++ b/simple-membership/classes/class.swpm-settings.php
@@ -147,16 +147,58 @@
add_settings_field(
'password-visibility-login-form',
- SwpmUtils::_( 'Enable Toggle Password Visibility in Login Form' ),
- array( &$this, 'checkbox_callback' ),
+ __( 'Enable Password Visibility Toggle in Login Form', 'simple-membership' ),
+ array( &$this, 'password_toggler_checkbox_callback' ),
'simple_wp_membership_settings',
'general-settings',
array(
'item' => 'password-visibility-login-form',
- 'message' => SwpmUtils::_( 'You can use it to show a toggle password visibility option in the login form. It will add a Show Password checkbox.' ),
+ 'message' => SwpmUtils::_( 'You can use it to show a toggle password visibility option in the login form.' ),
+ 'toggler_select' => array(
+ 'item' => 'password-visibility-toggler-style-login-form',
+ 'options' => SwpmUtils::get_pass_visibility_toggler_options(),
+ 'default' => 'icon',
+ 'message' => __( 'Select toggle style.' , 'simple-membership'),
+ ),
)
);
+ add_settings_field(
+ 'password-visibility-registration-form',
+ __( 'Enable Password Visibility Toggle in Registration Form' , 'simple-membership'),
+ array( $this, 'password_toggler_checkbox_callback' ),
+ 'simple_wp_membership_settings',
+ 'general-settings',
+ array(
+ 'item' => 'password-visibility-registration-form',
+ 'message' => __( 'You can use it to show a toggle password visibility option in the registration form.' , 'simple-membership'),
+ 'toggler_select' => array(
+ 'item' => 'password-visibility-toggler-style-reg-form',
+ 'options' => SwpmUtils::get_pass_visibility_toggler_options(),
+ 'default' => 'icon',
+ 'message' => __( 'Select toggle style.' , 'simple-membership'),
+ ),
+ )
+ );
+
+ add_settings_field(
+ 'password-visibility-profile-form',
+ __( 'Enable Password Visibility Toggle in Profile Form' , 'simple-membership'),
+ array( $this, 'password_toggler_checkbox_callback' ),
+ 'simple_wp_membership_settings',
+ 'general-settings',
+ array(
+ 'item' => 'password-visibility-profile-form',
+ 'message' => __( 'You can use it to show a toggle password visibility option in the profile form.' , 'simple-membership'),
+ 'toggler_select' => array(
+ 'item' => 'password-visibility-toggler-style-profile-form',
+ 'options' => SwpmUtils::get_pass_visibility_toggler_options(),
+ 'default' => 'icon',
+ 'message' => __( 'Select toggle style.' , 'simple-membership'),
+ ),
+ )
+ );
+
add_settings_field(
'password-reset-using-link',
SwpmUtils::_( 'Enable Password Reset Using Link' ),
@@ -1285,6 +1327,33 @@
echo '<p class="description">' . $msg . '</p>';
}
+ public function password_toggler_checkbox_callback($args) {
+ $item = $args['item'];
+ $msg = isset( $args['message'] ) ? $args['message'] : '';
+ $is = esc_attr( $this->get_value( $item ) );
+ echo "<input type='checkbox' $is name='swpm-settings[" . $item . "]' value="checked='checked'" />";
+ echo '<p class="description">' . $msg . '</p>';
+
+ if (isset($args['toggler_select'])) {
+ $toggler_args = $args['toggler_select'];
+
+ $item = $toggler_args['item'];
+ $options = $toggler_args['options'];
+ $default = $toggler_args['default'];
+ $msg = isset( $toggler_args['message'] ) ? $toggler_args['message'] : '';
+ $selected = esc_attr( $this->get_value( $item, $default ) );
+
+ $select_input = "<select name='swpm-settings[" . $item . "]' >";
+ foreach ( $options as $key => $value ) {
+ $is_selected = ( $key == $selected ) ? 'selected="selected"' : '';
+ $select_input .= '<option ' . $is_selected . ' value="' . esc_attr( $key ) . '">' . esc_attr( $value ) . '</option>';
+ }
+ $select_input .= '</select>';
+
+ echo '<p class="description">'. $select_input . '<br>' . sprintf($msg, $select_input) . '</p>';
+ }
+ }
+
public function textarea_callback( $args ) {
$item = $args['item'];
$msg = isset( $args['message'] ) ? $args['message'] : '';
@@ -1575,6 +1644,11 @@
$output['default-account-status-after-payment'] = esc_attr( $input['default-account-status-after-payment'] );
$output['members-login-to-comment'] = isset( $input['members-login-to-comment'] ) ? esc_attr( $input['members-login-to-comment'] ) : '';
$output['password-visibility-login-form'] = isset( $input['password-visibility-login-form'] ) ? esc_attr( $input['password-visibility-login-form'] ) : '';
+ $output['password-visibility-toggler-style-login-form'] = isset( $input['password-visibility-toggler-style-login-form'] ) ? esc_attr( $input['password-visibility-toggler-style-login-form'] ) : '';
+ $output['password-visibility-registration-form'] = isset( $input['password-visibility-registration-form'] ) ? esc_attr( $input['password-visibility-registration-form'] ) : '';
+ $output['password-visibility-toggler-style-reg-form'] = isset( $input['password-visibility-toggler-style-reg-form'] ) ? esc_attr( $input['password-visibility-toggler-style-reg-form'] ) : '';
+ $output['password-visibility-profile-form'] = isset( $input['password-visibility-profile-form'] ) ? esc_attr( $input['password-visibility-profile-form'] ) : '';
+ $output['password-visibility-toggler-style-profile-form'] = isset( $input['password-visibility-toggler-style-profile-form'] ) ? esc_attr( $input['password-visibility-toggler-style-profile-form'] ) : '';
return $output;
}
--- a/simple-membership/classes/class.swpm-utils.php
+++ b/simple-membership/classes/class.swpm-utils.php
@@ -194,6 +194,13 @@
);
}
+ public static function get_pass_visibility_toggler_options() {
+ return array(
+ 'icon' => __( 'Icon', 'simple-membership' ),
+ 'checkbox' => __( 'Checkbox', 'simple-membership' ),
+ );
+ }
+
public static function account_state_dropdown( $selected = 'active' , $option_all = false) {
$options = self::get_account_state_options();
$html = '';
--- a/simple-membership/lib/paypal/class-swpm-paypal-button-sub-ajax-handler.php
+++ b/simple-membership/lib/paypal/class-swpm-paypal-button-sub-ajax-handler.php
@@ -372,6 +372,16 @@
$api_injector = new SWPM_PayPal_Request_API_Injector();
$sub_details = $api_injector->get_paypal_subscription_details( $subscription_id );
if( $sub_details !== false ){
+
+ // Check if plan id mismatch.
+ $received_plan_id = isset($sub_details->plan_id) ? $sub_details->plan_id : '';
+ $configured_plan_id = get_post_meta( $button_id, 'pp_subscription_plan_id', true );
+ if ( !empty($received_plan_id) && $received_plan_id !== $configured_plan_id ) {
+ $validation_error_msg = 'Validation Error! PayPal subscription plan ID mismatch.';
+ SwpmLog::log_simple_debug( $validation_error_msg .' Received: '. $received_plan_id .' Actual: ' . $configured_plan_id, false );
+ return $validation_error_msg;
+ }
+
/*** Guard: Verify the subscriber email from PayPal API matches the email submitted in the request (prevent email spoofing in replayed requests). ***/
$api_subscriber = isset($sub_details->subscriber) ? $sub_details->subscriber : null;
if ( is_object($api_subscriber) ) {
@@ -411,6 +421,20 @@
SwpmLog::log_simple_debug( $validation_error_msg, false );
return $validation_error_msg;
}
+
+ // Check trial payment amount.
+ $configured_trial_billing_amount = (float) get_post_meta( $button_id, 'trial_billing_amount', true );
+ if (!empty($configured_trial_billing_amount)){
+ // Its a pain trial amount.
+ $received_trial_billing_amount = isset($billing_info['last_payment']['amount']['value']) ? (float) $billing_info['last_payment']['amount']['value'] : 0;
+
+ if( abs($configured_trial_billing_amount - $received_trial_billing_amount) > 0.01 ){
+ $validation_error_msg = 'Validation Error! Trial payment amount mismatch!';
+ SwpmLog::log_simple_debug( $validation_error_msg . ' Configured: ' . $configured_trial_billing_amount . ', Received: ' . $received_trial_billing_amount, false );
+ return $validation_error_msg;
+ }
+ }
+
} else {
//This is a regular subscription checkout (without trial). Check that the price matches.
$amount = isset($billing_info['last_payment']['amount']['value']) ? $billing_info['last_payment']['amount']['value'] : 0;
--- a/simple-membership/simple-wp-membership.php
+++ b/simple-membership/simple-wp-membership.php
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Simple Membership
-Version: 4.7.8
+Version: 4.7.9
Plugin URI: https://simple-membership-plugin.com/
Author: smp7, wp.insider
Author URI: https://simple-membership-plugin.com/
@@ -17,8 +17,8 @@
}
//Define plugin constants
-define( 'SIMPLE_WP_MEMBERSHIP_VER', '4.7.8' );
-define( 'SIMPLE_WP_MEMBERSHIP_DB_VER', '1.5' );
+define( 'SIMPLE_WP_MEMBERSHIP_VER', '4.7.9' );
+define( 'SIMPLE_WP_MEMBERSHIP_DB_VER', '1.6' );
define( 'SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url() );
define( 'SIMPLE_WP_MEMBERSHIP_PATH', dirname( __FILE__ ) . '/' );
define( 'SIMPLE_WP_MEMBERSHIP_URL', plugins_url( '', __FILE__ ) );
--- a/simple-membership/views/add-v2.php
+++ b/simple-membership/views/add-v2.php
@@ -49,6 +49,19 @@
)
);
+$display_reg_form_password_toggle = $settings->get_value('password-visibility-registration-form');
+$password_toggler_type = $settings->get_value('password-visibility-toggler-style-reg-form', 'icon');
+if (!empty($display_reg_form_password_toggle)) {
+ $all_password_input_selectors = '.swpm-form-password, .swpm-form-repass';
+ $password_inputs_to_attach = $all_password_input_selectors;
+ SimpleWpMembership::enqueue_password_toggle_scripts('swpm.password-toggle', array(
+ 'type' => $password_toggler_type,
+ 'formId' => $form_id,
+ 'passwordInputSelectors' => $all_password_input_selectors,
+ 'passwordInputSelectorsToAttach' => $password_inputs_to_attach,
+ ));
+}
+
?>
<div class="swpm-registration-widget-form">
<form id="<?php echo $form_id ?>" class="swpm-form" name="swpm-registration-form" method="post" action="">
@@ -92,7 +105,7 @@
</div>
<div class="swpm-form-row swpm-firstname-row" <?php apply_filters('swpm_registration_form_firstname_tr_attributes', ''); ?>>
<div class="swpm-form-label-wrap swpm-form-firstname-label-wrap">
- <label for="first_name"><?php echo _e('First Name', "simple-membership") ?></label>
+ <label for="first_name"><?php _e('First Name', "simple-membership") ?></label>
</div>
<div class="swpm-form-input-wrap swpm-form-firstname-input-wrap">
<input type="text" id="first_name" class="swpm-form-field swpm-form-firstname" value="<?php echo esc_attr($first_name); ?>" name="first_name" />
@@ -101,7 +114,7 @@
</div>
<div class="swpm-form-row swpm-lastname-row" <?php apply_filters('swpm_registration_form_lastname_tr_attributes', ''); ?>>
<div class="swpm-form-label-wrap swpm-form-lastname-label-wrap">
- <label for="last_name"><?php echo _e('Last Name', "simple-membership") ?></label>
+ <label for="last_name"><?php _e('Last Name', "simple-membership") ?></label>
</div>
<div class="swpm-form-input-wrap swpm-form-lastname-input-wrap">
<input type="text" id="last_name" class="swpm-form-field swpm-form-lastname" value="<?php echo esc_attr($last_name); ?>" name="last_name" />
--- a/simple-membership/views/admin_add_v2.php
+++ b/simple-membership/views/admin_add_v2.php
@@ -13,6 +13,23 @@
'form_id' => $form_id,
)
);
+$settings = SwpmSettings::get_instance();
+$display_reg_form_password_toggle = $settings->get_value('password-visibility-registration-form', false);
+$password_toggler_type = $settings->get_value('password-visibility-toggler-style-reg-form', 'icon');
+if (!empty($display_reg_form_password_toggle)) {
+ $all_password_input_selectors = '.swpm-form-password, .swpm-form-repass';
+ $password_inputs_to_attach = $all_password_input_selectors;
+ SimpleWpMembership::enqueue_password_toggle_scripts('swpm.password-toggle', array(
+ 'type' => $password_toggler_type,
+ 'formId' => $form_id,
+ 'passwordInputSelectors' => $all_password_input_selectors,
+ 'passwordInputSelectorsToAttach' => $password_inputs_to_attach,
+ 'checkboxTogglerInsertAfterSelector' => $password_inputs_to_attach,
+ 'checkboxTogglerStyles' => [
+ 'margin' => '10px 0 0',
+ ],
+ ));
+}
?>
<div class="wrap" id="swpm-profile-page" type="add">
--- a/simple-membership/views/admin_edit_v2.php
+++ b/simple-membership/views/admin_edit_v2.php
@@ -18,6 +18,24 @@
//Get the current expiry date based on the membership level of this member.
$member_current_expiry_date = SwpmMemberUtils::get_formatted_expiry_date_by_user_id($member_id);
+
+$display_profile_form_password_toggle = SwpmSettings::get_instance()->get_value('password-visibility-profile-form');
+$password_toggler_type = SwpmSettings::get_instance()->get_value('password-visibility-toggler-style-profile-form', 'icon');
+if (!empty($display_profile_form_password_toggle)) {
+ $all_password_input_selectors = '.swpm-form-password, .swpm-form-repass';
+ $password_inputs_to_attach = $all_password_input_selectors;
+ SimpleWpMembership::enqueue_password_toggle_scripts('swpm.password-toggle', array(
+ 'type' => $password_toggler_type,
+ 'formId' => $form_id,
+ 'passwordInputSelectors' => $all_password_input_selectors,
+ 'passwordInputSelectorsToAttach' => $password_inputs_to_attach,
+ 'checkboxTogglerInsertAfterSelector' => $password_inputs_to_attach,
+ 'checkboxTogglerStyles' => [
+ 'margin' => '10px 0 6px',
+ ],
+ ));
+}
+
?>
<div class="wrap" id="swpm-profile-page" type="edit">
<form action="" method="post" name="swpm-edit-user" id="<?php echo $form_id ?>" enctype="multipart/form-data" class="swpm-form" <?php do_action('user_new_form_tag'); ?>>
--- a/simple-membership/views/edit-v2.php
+++ b/simple-membership/views/edit-v2.php
@@ -38,6 +38,20 @@
'custom_pass_min_length_validator_msg' => $custom_pass_min_length_validator_msg,
)
);
+
+$display_profile_form_password_toggle = $settings->get_value('password-visibility-profile-form');
+$password_toggler_type = $settings->get_value('password-visibility-toggler-style-profile-form', 'icon');
+if (!empty($display_profile_form_password_toggle)) {
+ $all_password_input_selectors = '.swpm-form-password, .swpm-form-repass';
+ $password_inputs_to_attach = $all_password_input_selectors;
+ SimpleWpMembership::enqueue_password_toggle_scripts('swpm.password-toggle', array(
+ 'type' => $password_toggler_type,
+ 'formId' => $form_id,
+ 'passwordInputSelectors' => $all_password_input_selectors,
+ 'passwordInputSelectorsToAttach' => $password_inputs_to_attach,
+ ));
+}
+
?>
<div class="swpm-edit-profile-form">
<form id="<?php echo $form_id ?>" class="swpm-form" name="swpm-editprofile-form" method="post" action="">
@@ -167,6 +181,15 @@
</div>
</div>
<?php echo apply_filters('swpm_edit_profile_form_after_membership_level', ''); ?>
+
+ <?php if( $display_profile_form_password_toggle && $password_toggler_type == 'checkbox' ) { ?>
+ <div class="swpm-form-row swpm-password-input-visibility">
+ <label class="swpm-password-toggle-checkbox-label">
+ <input type="checkbox" class="swpm-password-toggle-checkbox">
+ <span class="swpm-password-toggle-label"> <?php _e('Show password', 'simple-membership') ?></span>
+ </label>
+ </div>
+ <?php } ?>
</div>
<?php
// Trigger action hook. Can be used to add content to the registration form.
--- a/simple-membership/views/login.php
+++ b/simple-membership/views/login.php
@@ -26,10 +26,22 @@
$login_submit_class .= ' swpm-submit-btn-default-style';
}
+$form_id = 'swpm-login-form';
+
$hide_join_us_link_enabled = SwpmSettings::get_instance()->get_value('hide-join-us-link');
+
+$password_toggler_type = SwpmSettings::get_instance()->get_value('password-visibility-toggler-style-login-form', 'icon');
+if (!empty($display_password_toggle)) {
+ SimpleWpMembership::enqueue_password_toggle_scripts('swpm.password-toggle', array(
+ 'type' => $password_toggler_type,
+ 'formId' => $form_id,
+ 'checkboxTogglerSelector' => "#swpm-password-toggle-checkbox",
+ ));
+}
+
?>
<div class="swpm-login-widget-form">
- <form id="swpm-login-form" name="swpm-login-form" method="post" action="">
+ <form id="<?php echo esc_attr($form_id) ?>" name="swpm-login-form" method="post" action="">
<input type="hidden" name="swpm_login_origination_flag" value="1" />
<div class="swpm-login-form-inner">
<div class="swpm-username-label">
@@ -44,7 +56,7 @@
<div class="swpm-password-input">
<input type="password" class="swpm-text-field swpm-password-field" id="swpm_password" value="" size="25" name="swpm_password" />
</div>
- <?php if( $display_password_toggle ){ ?>
+ <?php if( !empty($display_password_toggle) && $password_toggler_type == 'checkbox' ){ ?>
<div class="swpm-password-input-visibility">
<span class="swpm-password-toggle-checkbox"><input type="checkbox" name="swpm-password-toggle-checkbox" id="swpm-password-toggle-checkbox" data-state="password-hidden" > </span>
<label for="swpm-password-toggle-checkbox" class="swpm-password-toggle-checkbox-label">