Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/easy-login-woocommerce/admin/class-xoo-el-admin-settings.php
+++ b/easy-login-woocommerce/admin/class-xoo-el-admin-settings.php
@@ -125,7 +125,10 @@
<div>
<span class="xoo-el-adpopup-head">Popup Style</span>
- <?php echo xoo_el_helper()->admin->get_setting_html_pop( 'style', 'sy_popup', 'sy-popup-style' ); ?>
+ <?php
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo xoo_el_helper()->admin->get_setting_html_pop( 'style', 'sy_popup', 'sy-popup-style' );
+ ?>
</div>
@@ -137,7 +140,10 @@
</div>
<div class="xoo-el-adpop-autoopen">
<span class="xoo-el-adpopup-head">Auto open popup</span>
- <?php echo xoo_el_helper()->admin->get_setting_html_pop( 'general', 'gl_ao', 'ao-enable' ); ?>
+ <?php
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo xoo_el_helper()->admin->get_setting_html_pop( 'general', 'gl_ao', 'ao-enable' );
+ ?>
<span>You can toggle it later from the settings</span>
</div>
</div>
@@ -234,7 +240,7 @@
<span class="xoo-el-adpopup-head">Add Popup Link to Menu</span>
<select name="xoo-el-add-to-menu">
<?php foreach ( $menuOptions as $slug => $name ): ?>
- <option value="<?php echo $slug ?>"><?php echo $name ?></option>
+ <option value="<?php echo esc_attr( $slug ) ?>"><?php echo esc_html( $name ) ?></option>
<?php endforeach; ?>
</select>
<span>You can add or remove this later from your menu page</span>
@@ -260,7 +266,7 @@
<h3>How to translate or change text?</h3>
<ol>
- <li>Form fields texts can be changed from <a href="<?php echo admin_url('admin.php?page=xoo-el-fields') ?>" target="__blank">Fields page</a></li>
+ <li>Form fields texts can be changed from <a href="<?php echo esc_url( admin_url('admin.php?page=xoo-el-fields') ) ?>" target="__blank">Fields page</a></li>
<li>Some texts can be changed from the settings.</li>
</ol>
<h4>Translation</h4>
@@ -306,6 +312,7 @@
}
if( $tab_id === 'info' ){
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo xoo_el_helper()->get_outdated_section().'<br>';
}
}
@@ -395,6 +402,7 @@
//Inline CSS
public function inline_css(){
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if( isset( $_GET['xoo_el_nav'] ) ){
?>
<style type="text/css">
--- a/easy-login-woocommerce/admin/class-xoo-el-aff-fields.php
+++ b/easy-login-woocommerce/admin/class-xoo-el-aff-fields.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
--- a/easy-login-woocommerce/admin/class-xoo-el-user-profile.php
+++ b/easy-login-woocommerce/admin/class-xoo-el-user-profile.php
@@ -126,7 +126,7 @@
$field_html .= '<a target="__blank" href="'.$url.'">'.$url.'</a><br>';
}
$field_html .= '</div>';
- echo $field_html;
+ echo wp_kses_post( $field_html );
echo '<p class="description">Add attachment IDs here (comma separated)</p>';
}
else{
@@ -153,6 +153,7 @@
*
* @param int $user_id User ID of the user being saved
*/
+ // phpcs:disable WordPress.Security.NonceVerification.Missing
public function save_customer_meta_fields( $user_id ) {
$save_fields = xoo_el_fields()->get_fields( 'register' );
@@ -163,13 +164,19 @@
if( isset( $_POST[ $field_id ] ) ){
if( is_array( $_POST[ $field_id ] ) ){
- $value = array_map( 'sanitize_text_field', $_POST[ $field_id ] );
+
+ $value = array_map(
+ 'sanitize_text_field',
+ wp_unslash( $_POST[ $field_id ] )
+ );
}
else{
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
$value = sanitize_text_field( $_POST[ $field_id ] );
}
- if( $field_data['input_type'] === 'file' && $_POST[ $field_id ] ){
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if( $field_data['input_type'] === 'file' && wp_unslash( $_POST[ $field_id ] ) ){
$value = explode(',', $value );
}
--- a/easy-login-woocommerce/admin/templates/shortcode-generator.php
+++ b/easy-login-woocommerce/admin/templates/shortcode-generator.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<div class="xoo-el-scgen-cont xoo-ass-section">
<div class="xoo-asc-head"><span class="xoo-asch-title ">Shortcode Generator</span></div>
@@ -85,7 +87,7 @@
<option value="custom">Custom URL</option>
</select>
- <input type="text" data-fname="xoo-elscg-loginred" value="<?php echo get_site_url() ?>" data-showval="custom">
+ <input type="text" data-fname="xoo-elscg-loginred" value="<?php echo esc_url( get_site_url() ) ?>" data-showval="custom">
<span class="xoo-el-scgdesc">Redirect link after login.<br>
Global Setting refers to the option set under general -> redirect settings.
@@ -107,7 +109,7 @@
<option value="custom">Custom URL</option>
</select>
- <input type="text" data-fname="xoo-elscg-regred" value="<?php echo get_site_url() ?>" data-showval="custom">
+ <input type="text" data-fname="xoo-elscg-regred" value="<?php echo esc_url( get_site_url() ) ?>" data-showval="custom">
<span class="xoo-el-scgdesc">Redirect link after register.<br>
Global Setting refers to the option set under general -> redirect settings.
@@ -163,7 +165,7 @@
<option value="same">Same Page</option>
<option value="custom">Custom URL</option>
</select>
- <input type="text" data-fname="xoo-elscg-popred" value="<?php echo get_site_url() ?>" data-showval="custom">
+ <input type="text" data-fname="xoo-elscg-popred" value="<?php echo esc_url( get_site_url() ) ?>" data-showval="custom">
<span class="xoo-el-scgdesc">Redirect link after login/register.<br>
Global Setting refers to the option set under general -> redirect settings.
</span>
--- a/easy-login-woocommerce/admin/templates/xoo-el-sidebar.php
+++ b/easy-login-woocommerce/admin/templates/xoo-el-sidebar.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
$plugins_list = array(
--- a/easy-login-woocommerce/admin/views/oldtonew.php
+++ b/easy-login-woocommerce/admin/views/oldtonew.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
$oldValues = array(
--- a/easy-login-woocommerce/admin/views/sections.php
+++ b/easy-login-woocommerce/admin/views/sections.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
$sections = array(
--- a/easy-login-woocommerce/admin/views/settings/add-ons.php
+++ b/easy-login-woocommerce/admin/views/settings/add-ons.php
@@ -1,3 +1,4 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php
$link = 'https://xootix.com/plugins/easy-login-for-woocommerce#sp-addons';
@@ -69,8 +70,8 @@
<?php foreach ( $addons as $id => $data ): ?>
<div class="xoo-addon">
<span class="dashicons <?php echo esc_attr( $data['icon'] ); ?>"></span>
- <span class="xoo-ao-title"><?php echo $data['title'] ?></span>
- <div class="xoo-ao-desc"><?php echo $data['desc']; ?></div>
+ <span class="xoo-ao-title"><?php echo wp_kses_post( $data['title'] ) ?></span>
+ <div class="xoo-ao-desc"><?php echo wp_kses_post( $data['desc'] ); ?></div>
<div class="xoo-ao-btns">
<a class="xoo-btn xoo-btn-primary" target="_blank" href="<?php echo esc_url( $data['link'] ) ?>">BUY</a>
<?php if( isset( $data['demo'] ) ): ?>
--- a/easy-login-woocommerce/admin/views/settings/advanced.php
+++ b/easy-login-woocommerce/admin/views/settings/advanced.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
$settings = array(
--- a/easy-login-woocommerce/admin/views/settings/general.php
+++ b/easy-login-woocommerce/admin/views/settings/general.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
if ( ! function_exists( 'get_editable_roles' ) ) {
require_once ABSPATH . 'wp-admin/includes/user.php';
--- a/easy-login-woocommerce/admin/views/settings/shortcode-info.php
+++ b/easy-login-woocommerce/admin/views/settings/shortcode-info.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<div class="xoo-el-popup-info">
<h3>How to open popup?</h3>
--- a/easy-login-woocommerce/admin/views/settings/style.php
+++ b/easy-login-woocommerce/admin/views/settings/style.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
$buttonThemesSettings = array(
@@ -53,7 +55,7 @@
'title' => 'Toggle Buttons',
'id' => 'sy-btntheme-toggle',
'section_id' => 'sy_button_theme_creator',
- 'default' => 'theme_default2'
+ 'default' => 'theme_default1'
);
}
@@ -162,6 +164,42 @@
),
+
+
+ array(
+ 'callback' => 'upload',
+ 'title' => 'Sidebar Image',
+ 'id' => 'sy-sidebar-img',
+ 'section_id' => 'sy_popup',
+ 'default' => XOO_EL_URL.'/assets/images/login.jpg',
+ ),
+
+
+ array(
+ 'callback' => 'select',
+ 'title' => 'Sidebar Position',
+ 'id' => 'sy-sidebar-pos',
+ 'section_id' => 'sy_popup',
+ 'args' => array(
+ 'options' => array(
+ 'left' => 'Left',
+ 'right' => 'Right'
+ )
+ ),
+ 'default' => 'left'
+ ),
+
+
+ array(
+ 'callback' => 'number',
+ 'title' => 'Sidebar width',
+ 'id' => 'sy-sidebar-width',
+ 'section_id' => 'sy_popup',
+ 'default' => 43,
+ 'desc' => 'Width in percentage'
+ ),
+
+
array(
'callback' => 'select',
'title' => 'Popup Position',
@@ -237,39 +275,7 @@
'default' => '#000000',
),
- array(
- 'callback' => 'upload',
- 'title' => 'Sidebar Image',
- 'id' => 'sy-sidebar-img',
- 'section_id' => 'sy_popup',
- 'default' => XOO_EL_URL.'/assets/images/login.jpg',
- ),
-
-
- array(
- 'callback' => 'select',
- 'title' => 'Sidebar Position',
- 'id' => 'sy-sidebar-pos',
- 'section_id' => 'sy_popup',
- 'args' => array(
- 'options' => array(
- 'left' => 'Left',
- 'right' => 'Right'
- )
- ),
- 'default' => 'left'
- ),
-
-
- array(
- 'callback' => 'number',
- 'title' => 'Sidebar width',
- 'id' => 'sy-sidebar-width',
- 'section_id' => 'sy_popup',
- 'default' => 43,
- 'desc' => 'Width in percentage'
- ),
-
+
array(
'callback' => 'color',
--- a/easy-login-woocommerce/admin/views/tabs.php
+++ b/easy-login-woocommerce/admin/views/tabs.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
$tabs = array(
--- a/easy-login-woocommerce/includes/class-xoo-el-core.php
+++ b/easy-login-woocommerce/includes/class-xoo-el-core.php
@@ -174,8 +174,8 @@
ob_start();
?>
<p style="margin: 0 0 16px 0;">
- <span class="xoo-el-sing-head" style="font-size: 32px;"><?php echo $glOptions['txt-sing-head'] ?></span><br />
- <span class="xoo-el-sing-subtxt" style="font-size: 16px;"><?php echo $glOptions['txt-sing-subtxt'] ?></span>
+ <span class="xoo-el-sing-head" style="font-size: 32px;"><?php echo wp_kses_post( $glOptions['txt-sing-head'] ) ?></span><br />
+ <span class="xoo-el-sing-subtxt" style="font-size: 16px;"><?php echo wp_kses_post( $glOptions['txt-sing-subtxt'] ) ?></span>
</p>
<?php
@@ -276,7 +276,7 @@
if( empty( $themeTemplatesData ) || $themeTemplatesData['has_outdated'] !== 'yes' ) return;
?>
<div class="notice notice-success is-dismissible xoo-el-admin-notice">
- <p><?php printf( 'You have <a href="%1$s">outdated templates</a> in your theme which are no longer supported. Please see "info" tab for more info.', admin_url( 'admin.php?page=easy-login-woocommerce-settings' ) ); ?></p>
+ <p><?php printf( 'You have <a href="%1$s">outdated templates</a> in your theme which are no longer supported. Please see "info" tab for more info.', esc_url( admin_url( 'admin.php?page=easy-login-woocommerce-settings' ) ) ); ?></p>
</div>
<?php
}
--- a/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
+++ b/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
@@ -35,9 +35,11 @@
//Process form
public static function form_action(){
+ check_ajax_referer( 'xoo-el-nonce' );
+
if( !isset( $_POST['_xoo_el_form'] ) ) return;
- $form_action = sanitize_text_field( $_POST['_xoo_el_form'] );
+ $form_action = sanitize_text_field( wp_unslash( $_POST['_xoo_el_form'] ) );
switch ($form_action) {
case 'login':
@@ -76,11 +78,13 @@
public static function process_single_form(){
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( !isset($_POST['_xoo_el_form']) || $_POST['_xoo_el_form'] !== 'single' ) return;
try {
- $userInput = sanitize_user( trim( $_POST['xoo-el-sing-user'] ) );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $user_input = isset( $_POST['xoo-el-sing-user'] ) ? trim( sanitize_user( wp_unslash( $_POST['xoo-el-sing-user'] ) ) ) : '';
$allowUsernameSearch = xoo_el()->aff->fields->get_field_data('xoo-el-sing-user')['settings']['xoo_el_username'] === 'yes';
$validation_error = apply_filters( 'xoo_el_process_single_errors', new WP_Error(), $userInput );
@@ -117,12 +121,14 @@
$field = 'input[name="xoo-el-username"]';
}
else{
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( !isset( $_POST['_xoo_el_login_has_register'] ) || !is_email( $userInput ) ){
$notice = xoo_el_add_notice( 'error', __( "We couldn't find your account.", 'easy-login-woocommerce' ) );
$error = 1;
}
else{
$field = 'input[name="xoo_el_reg_email"]';
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
$notice = xoo_el_add_notice( 'warning', isset( $_POST['_xoo_el_referral'] ) && $_POST['_xoo_el_referral'] === 'register' ? __( 'Please enter your details to register.', 'easy-login-woocommerce' ) : __( "We couldn't find your account. Please register.", 'easy-login-woocommerce' ) );
}
}
@@ -159,14 +165,18 @@
//Process Login
public static function process_login(){
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( !isset($_POST['_xoo_el_form']) || $_POST['_xoo_el_form'] !== 'login' ) return;
try {
$creds = array(
- 'user_login' => sanitize_user( trim( $_POST['xoo-el-username'] ) ),
- 'user_password' => $_POST['xoo-el-password'],
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
+ 'user_login' => sanitize_user( wp_unslash( $_POST['xoo-el-username'] ) ),
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
+ 'user_password' => wp_unslash( $_POST['xoo-el-password'] ),
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
'remember' => isset( $_POST['xoo-el-rememberme'] ),
);
@@ -210,6 +220,7 @@
);
if( in_array( $message_code, $show_lostpw_on_errors ) ){
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( isset( $_POST['_xoo_el_login_has_single'] ) && $message_code === 'incorrect_password' ){
$message = __( 'Wrong password.', 'easy-login-woocommerce' ).$lost_pw_text;
}
@@ -225,8 +236,10 @@
} else {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( ! empty( $_POST['xoo_el_redirect'] ) ) {
- $redirect = sanitize_url( $_POST['xoo_el_redirect'] );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $redirect = sanitize_url( wp_unslash( $_POST['xoo_el_redirect'] ) );
}
$redirect = apply_filters( 'xoo_el_login_redirect', wp_validate_redirect( $redirect ), $user );
@@ -265,10 +278,14 @@
*/
public static function process_registration() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( isset($_POST['_xoo_el_form']) && $_POST['_xoo_el_form'] === 'register' ) {
- $username = isset( $_POST['xoo_el_reg_username'] ) ? sanitize_user( $_POST['xoo_el_reg_username'] ) : '';
- $password = isset( $_POST['xoo_el_reg_pass'] ) ? $_POST['xoo_el_reg_pass'] : '';
- $email = isset( $_POST['xoo_el_reg_email'] ) ? sanitize_email( $_POST['xoo_el_reg_email'] ) : '';
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $username = isset( $_POST['xoo_el_reg_username'] ) ? sanitize_user( wp_unslash( $_POST['xoo_el_reg_username'] ) ) : '';
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ $password = isset( $_POST['xoo_el_reg_pass'] ) ? wp_unslash( $_POST['xoo_el_reg_pass'] ) : '';
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $email = isset( $_POST['xoo_el_reg_email'] ) ? sanitize_email( wp_unslash( $_POST['xoo_el_reg_email'] ) ) : '';
$reg_extra_data = array();
try {
@@ -283,6 +300,7 @@
$doNotValidateOtherFields = array_keys( array_diff_key( $reg_admin_fields, xoo_el_fields()->get_fields('register') ) );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
$fieldValues = xoo_el()->aff->fields->validate_submitted_field_values( $_POST, $doNotValidateOtherFields );
if( is_wp_error( $fieldValues ) ){
@@ -336,16 +354,21 @@
throw new Xoo_Exception( __( 'Please enter an account password.', 'easy-login-woocommerce' ) );
}
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
if( $reg_admin_fields['xoo_el_reg_pass']['settings']['active'] === "yes" && $reg_admin_fields['xoo_el_reg_pass_again']['settings']['active'] === "yes" && $password !== $_POST['xoo_el_reg_pass_again'] ){
throw new Xoo_Exception( __("Passwords don't match","easy-login-woocommerce") );
}
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( isset( $_POST['xoo_el_reg_fname'] ) ){
- $reg_extra_data['first_name'] = sanitize_text_field( $_POST['xoo_el_reg_fname'] );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $reg_extra_data['first_name'] = sanitize_text_field( wp_unslash( $_POST['xoo_el_reg_fname'] ) );
}
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( isset( $_POST['xoo_el_reg_lname'] ) ){
- $reg_extra_data['last_name'] = sanitize_text_field( $_POST['xoo_el_reg_lname'] );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $reg_extra_data['last_name'] = sanitize_text_field( wp_unslash( $_POST['xoo_el_reg_lname'] ) );
}
if( $reg_admin_fields['xoo_el_reg_username']['settings']['active'] !== "yes" ){
@@ -402,8 +425,10 @@
$success_notice = $success_notice;
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( ! empty( $_POST['xoo_el_redirect'] ) && $redirect ) {
- $redirect = wp_sanitize_redirect( $_POST['xoo_el_redirect'] );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $redirect = wp_sanitize_redirect( wp_unslash( $_POST['xoo_el_redirect'] ) );
}
$redirect = apply_filters( 'xoo_el_registration_redirect', wp_validate_redirect( $redirect ), $new_customer );
@@ -617,10 +642,12 @@
// Process lost password form
public static function process_lost_password(){
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( isset($_POST['_xoo_el_form']) && $_POST['_xoo_el_form'] === 'lostPassword' ){
try{
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
$user_login = trim( wp_unslash( $_POST['user_login'] ) );
$recover_pattern = self::$glSettings['m-reset-pw'];
$has_woocommmerce = class_exists('woocommerce');
@@ -747,15 +774,16 @@
public static function process_reset_password(){
- if( !isset( $_POST['xoo-el-resetpw-nonce-field'] ) || !wp_verify_nonce( $_POST['xoo-el-resetpw-nonce-field'], 'xoo-el-resetpw-nonce' ) ){
- return;
- }
-
try {
if( self::$glSettings['m-reset-pw'] === 'link' ){
- $user = check_password_reset_key( $_POST['rp_key'], $_POST['rp_login'] );
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ $rp_key = isset( $_POST['rp_key'] ) ? wp_unslash( $_POST['rp_key'] ) : '';
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $rp_login = isset( $_POST['rp_login'] ) ? sanitize_user( wp_unslash( $_POST['rp_login'] ) ) : '';
+
+ $user = check_password_reset_key( $rp_key, $rp_login );
if( is_wp_error( $user ) ){
throw new Xoo_Exception( __( 'This key is invalid or has already been used. Please reset your password again if needed.', 'easy-login-woocommerce' ) );
@@ -782,11 +810,13 @@
if ( $user instanceof WP_User ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( !isset( $_POST['xoo-el-rp-pass'] ) || !isset( $_POST['xoo-el-rp-pass-again'] ) || $_POST['xoo-el-rp-pass'] !== $_POST['xoo-el-rp-pass-again'] ){
throw new Xoo_Exception( __( "Passwords don't match", 'easy-login-woocommerce' ) );
}
- $new_pass = $_POST['xoo-el-rp-pass'];
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ $new_pass = wp_unslash( $_POST['xoo-el-rp-pass'] );
$errors = new WP_Error();
@@ -932,7 +962,8 @@
$message .= network_site_url( "{$baseurl}key=$key&login=" . rawurlencode( $user_login ), 'login' ) . '&wp_lang=' . $locale . "rnrn";
if ( ! is_user_logged_in() ) {
- $requester_ip = $_SERVER['REMOTE_ADDR'];
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
+ $requester_ip = wp_unslash( $_SERVER['REMOTE_ADDR'] );
if ( $requester_ip ) {
$message .= sprintf(
/* translators: %s: IP address of password reset requester. */
@@ -1048,9 +1079,11 @@
$user = get_user_by( 'login', sanitize_user( wp_unslash( $_GET['login'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$user_id = $user ? $user->ID : 0;
} else {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$user_id = absint( $_GET['id'] );
}
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
self::set_reset_password_cookie( sprintf( '%d:%s', $user_id, wp_unslash( $_GET['key'] ) ) );
wp_safe_redirect( add_query_arg( 'reset_password', 'true', apply_filters( 'xoo_el_redirect_rp_link', get_site_url() ) ) );
@@ -1067,7 +1100,7 @@
*/
public static function set_reset_password_cookie( $value = '' ) {
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
- $rp_path = isset( $_SERVER['REQUEST_URI'] ) ? current( explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) : ''; // WPCS: input var ok, sanitization ok.
+ $rp_path = isset( $_SERVER['REQUEST_URI'] ) ? current( explode( '?', sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ) : ''; // WPCS: input var ok, sanitization ok.
if ( $value ) {
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
@@ -1078,6 +1111,7 @@
public static function remove_query_args(){
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if( ( isset( $_GET['reset_password'] ) || isset( $_GET['show-reset-form'] ) ) && is_user_logged_in() ){
wp_safe_redirect( esc_url( remove_query_arg( array( 'reset_password', 'show-reset-form' ) ) ) );
}
--- a/easy-login-woocommerce/includes/class-xoo-el-frontend.php
+++ b/easy-login-woocommerce/includes/class-xoo-el-frontend.php
@@ -42,17 +42,17 @@
if( $form === 'login' ){
if( $this->glSettings['txt-login-form'] ){
- echo '<div class="xoo-el-form-desc">'.$this->glSettings['txt-login-form'].'</div>';
+ echo '<div class="xoo-el-form-desc">'.wp_kses_post( $this->glSettings['txt-login-form'] ).'</div>';
}
}
else if( $form === 'register' ){
if( $this->glSettings['txt-register-form'] ){
- echo '<div class="xoo-el-form-desc">'.$this->glSettings['txt-register-form'].'</div>';
+ echo '<div class="xoo-el-form-desc">'.wp_kses_post( $this->glSettings['txt-register-form'] ).'</div>';
}
}
else if( $form === 'single' ){
if( $this->glSettings['txt-single-form'] ){
- echo '<div class="xoo-el-form-desc">'.$this->glSettings['txt-single-form'].'</div>';
+ echo '<div class="xoo-el-form-desc">'.wp_kses_post( $this->glSettings['txt-single-form'] ).'</div>';
}
}
@@ -105,13 +105,14 @@
'resend_wait' => 90,
'preventClosing' => $this->glSettings['popup-force'] === "yes",
'hasCodeForms' => !empty( xoo_el_code_forms()->forms ),
- 'isLoggedIn' => is_user_logged_in() ? 'yes' : 'no'
+ 'isLoggedIn' => is_user_logged_in() ? 'yes' : 'no',
+ 'nonce' => wp_create_nonce('xoo-el-nonce')
);
if( class_exists('woocommerce') ){
$localizeData['checkout'] = array(
'loginEnabled' => $this->glSettings['m-en-chkout'],
- 'loginRedirect' => esc_url( $_SERVER['REQUEST_URI'] )
+ 'loginRedirect' => esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) )
);
}
@@ -185,7 +186,7 @@
if( isset( $logout_match[1] ) ){
- $logout_link = !empty( $this->glSettings['m-red-logout'] ) ? $this->glSettings['m-red-logout'] : $_SERVER['REQUEST_URI'];
+ $logout_link = !empty( $this->glSettings['m-red-logout'] ) ? sanitize_url( $this->glSettings['m-red-logout'] ) : sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) );
$change_to_link = wp_logout_url( $logout_link );
foreach ($logout_match[1] as $index => $content ) {
@@ -222,7 +223,7 @@
$popclass .= ' xoo-el-pop-sc';
if( $atts['redirect_to'] === 'same' ){
- $redirect = $_SERVER['REQUEST_URI'];
+ $redirect = sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) );
}
elseif( $atts['redirect_to'] ){
$redirect = $atts['redirect_to'];
@@ -295,7 +296,7 @@
$change_to_text = !empty( $change_to_text ) ? $change_to_text : __('My account','easy-login-woocommerce');
}
else if( $atts['change_to'] === 'logout' ){
- $logout_link = !empty( $this->glSettings['m-red-logout'] ) ? $this->glSettings['m-red-logout'] : $_SERVER['REQUEST_URI'];
+ $logout_link = !empty( $this->glSettings['m-red-logout'] ) ? $this->glSettings['m-red-logout'] : sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) );
$change_to_link = wp_logout_url( $logout_link );
$change_to_text = !empty( $change_to_text ) ? $change_to_text : __('Logout','easy-login-woocommerce');
}
@@ -338,7 +339,7 @@
}
if( $atts['redirect_to'] === 'same' ){
- $redirect = $_SERVER['REQUEST_URI'];
+ $redirect = sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) );
}
elseif( $atts['redirect_to'] ){
$redirect = $atts['redirect_to'];
--- a/easy-login-woocommerce/includes/class-xoo-el-helper.php
+++ b/easy-login-woocommerce/includes/class-xoo-el-helper.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
use XooELFrameworkXoo_Helper;
--- a/easy-login-woocommerce/includes/verification/class-xoo-el-code-form-resetpw.php
+++ b/easy-login-woocommerce/includes/verification/class-xoo-el-code-form-resetpw.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
class Xoo_El_Code_Form_Resetpw extends Xoo_El_Code_Form {
--- a/easy-login-woocommerce/includes/verification/class-xoo-el-code-form.php
+++ b/easy-login-woocommerce/includes/verification/class-xoo-el-code-form.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
use XooELFrameworkXoo_Exception;
@@ -54,8 +56,8 @@
public function hooks(){
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
if( isset( $_POST['xoo_el_code_ajax'] ) && $_POST['xoo_el_code_ajax'] === $this->form_id ){
-
add_action( 'wp_ajax_xoo_el_code_form_submit', array( $this, 'verify_code' ) );
add_action( 'wp_ajax_nopriv_xoo_el_code_form_submit', array( $this, 'verify_code' ) );
}
@@ -277,6 +279,8 @@
public function verify_code(){
+ check_ajax_referer( 'xoo-el-nonce' );
+
try {
$incorrect_limit_reached = $this->incorrect_tries_limit_reached();
@@ -288,6 +292,7 @@
$user_data = $this->get_user_data();
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
if( !isset( $user_data['code'] ) || $user_data['code'] != $_POST['code'] ){
$incorrect = isset( $user_data['incorrect'] ) ? $user_data['incorrect'] + 1 : 1;
--- a/easy-login-woocommerce/includes/verification/class-xoo-el-code-forms.php
+++ b/easy-login-woocommerce/includes/verification/class-xoo-el-code-forms.php
@@ -1,3 +1,5 @@
+<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
+
<?php
--- a/easy-login-woocommerce/includes/xoo-el-functions.php
+++ b/easy-login-woocommerce/includes/xoo-el-functions.php
@@ -1,865 +1,871 @@
-<?php
-
-if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly
-}
-
-if (!function_exists('array_is_list')) {
- function array_is_list(array $arr)
- {
- if ($arr === []) {
- return true;
- }
- return array_keys($arr) === range(0, count($arr) - 1);
- }
-}
-
-if ( ! function_exists( 'xoo_recursive_parse_args' ) ) {
- function xoo_recursive_parse_args( $args, $defaults ) {
- $new_args = (array) $defaults;
-
- foreach ( $args as $key => $value ) {
- if ( is_array( $value ) && isset( $new_args[ $key ] ) && !array_is_list( $value ) ) {
- $new_args[ $key ] = xoo_recursive_parse_args( $value, $new_args[ $key ] );
- }
- else {
- $new_args[ $key ] = $value;
- }
- }
-
- return $new_args;
- }
-}
-
-//Menu items filter
-if( !function_exists( 'xoo_el_nav_menu_items' ) ):
- function xoo_el_nav_menu_items( $items ) {
-
- if( empty( $items ) || !is_array( $items ) ) return;
-
-
- $actions_classes = array(
- 'xoo-el-login-tgr',
- 'xoo-el-reg-tgr',
- 'xoo-el-lostpw-tgr',
- 'xoo-el-logout-menu',
- 'xoo-el-myaccount-menu',
- 'xoo-el-username-menu',
- 'xoo-el-firstname-menu'
- );
-
- $user = wp_get_current_user();
-
- foreach ( $items as $key => $item ) {
-
- $classes = $item->classes;
-
- if( !empty( $action_class = array_values( array_intersect( $actions_classes, $classes ) ) ) ){
-
- $action_class = $action_class[0];
-
- if( is_user_logged_in() ){
-
- if( $action_class === "xoo-el-myaccount-menu" ){
- //do nothing
- continue;
- }
- elseif( $action_class === "xoo-el-logout-menu" ){
- if( $item->url ) continue;
- $glSettings = xoo_el_helper()->get_general_option();
- $logout_redirect = !empty( $glSettings['m-red-logout'] ) ? $glSettings['m-red-logout'] : $_SERVER['REQUEST_URI'];
- $item->url = wp_logout_url( $logout_redirect );
- }
- elseif( $action_class === "xoo-el-firstname-menu"){
-
- $name = !$user->user_firstname ? $user->user_login : $user->user_firstname;
- $item->title = get_avatar($user->ID).str_replace( 'firstname' , $name , $item->title );
- if( class_exists('woocommerce') ){
- $item->url = wc_get_page_permalink( 'myaccount' );
- }
- }
- elseif( $action_class === "xoo-el-username-menu"){
- $item->title = get_avatar($user->ID).str_replace( 'username' , $user->user_login , $item->title );
- if( class_exists('woocommerce') ){
- $item->url = wc_get_page_permalink( 'myaccount' );
- }
- }
- else{
- unset($items[$key]);
- }
-
- }
- else{
- if( $action_class === "xoo-el-logout-menu" || $action_class === "xoo-el-myaccount-menu" || $action_class === "xoo-el-username-menu" || $action_class === "xoo-el-firstname-menu"){
- unset($items[$key]);
- }
-
- }
-
- }
- }
-
- return $items;
- }
- add_filter('wp_nav_menu_objects','xoo_el_nav_menu_items',11);
-endif;
-
-
-//Add notice
-function xoo_el_add_notice( $notice_type = 'error', $message = '', $notice_class = null ){
-
- $title = $text = '';
-
- if( !is_array( $message ) ){
- $message = array(
- 'text' => $message
- );
- }
-
- if( $notice_type === 'error' || $notice_type === 'warning' ){
- $icon = 'xoo-el-icon-notice';
- }
- else if( $notice_type === 'success' ){
- $icon = 'xoo-el-icon-check-badge';
- }
- else{
- $icon = null;
- }
-
- $message = wp_parse_args( $message, array(
- 'icon' => $icon,
- 'title' => '',
- 'text' => ''
- ) );
-
- $title = $message['title'];
- $text = $message['text'];
- $icon = $message['icon'];
-
-
- $classes = 'xoo-el-notice-'.$notice_type.' '.$notice_class;
-
- ob_start();
-
- ?>
-
- <div class="<?php echo $classes ?>">
-
- <?php if( $icon ): ?>
-
- <div class="xoo-el-notice-icon <?php echo $icon ?>"></div>
-
- <?php endif; ?>
-
- <div class="xoo-el-notice-txtcont">
-
- <?php if( $title ): ?>
- <div class="xoo-el-noticetitle"><?php echo $title ?></div>
- <?php endif; ?>
-
- <?php if( $text ): ?>
- <div class="xoo-el-noticetxt"><?php echo $text ?></div>
- <?php endif; ?>
-
- </div>
-
- </div>
-
- <?php
-
- $html = ob_get_clean();
-
- $notice_html = apply_filters( 'xoo_el_notice_html', $html, $text, $classes );
-
- $notice_html = apply_filters( 'xoo_el_notice_html_v2', $html, $message, $classes );
-
- return $notice_html;
-}
-
-//Print notices
-function xoo_el_notice_container( $form, $args ){
-
- global $limit_login_attempts_obj;
-
- $notices = '';
-
- if($form === 'login' && !xoo_el_is_limit_login_ok() ){
- $notices .= '<div class="xoo-el-lla-notice"><div class="xoo-el-notice-error">'.$limit_login_attempts_obj->error_msg().'</div></div>';
- }
-
- $notices .= '<div class="xoo-el-notice"></div>';
-
- echo apply_filters( 'xoo_el_notice_container', wp_kses_post( $notices ), $form );
-
-}
-
-add_action( 'xoo_el_before_form', 'xoo_el_notice_container',20, 2 );
-
-//Is limit login ok
-function xoo_el_is_limit_login_ok(){
- global $limit_login_attempts_obj;
- //return if limit login plugin doesn't exist
- if( !$limit_login_attempts_obj ) return true;
-
- return $limit_login_attempts_obj->is_limit_login_ok();
-
-}
-
-
-//Inline Form Shortcode
-if( !function_exists( 'xoo_el_inline_form' ) ){
- function xoo_el_inline_form_shortcode($user_atts){
-
- if( is_user_logged_in() ) return;
-
- if( !isset( $user_atts['forms'] ) ){
- $defaultForms = 'login';
- if( xoo_el_helper()->get_general_option('m-en-reg') === 'yes' ){
- $defaultForms .= ',register';
- }
- }
- else{
- $defaultForms = 'login,register';
- }
-
- $atts = shortcode_atts( array(
- 'navstyle' => xoo_el_helper()->get_general_option( 'm-nav-pattern' ),
- 'pattern' => xoo_el_helper()->get_general_option( 'm-form-pattern' ),
- 'active' => '',
- 'tabs' => 'login,register',
- 'forms' => $defaultForms,
- 'login_redirect' => '',
- 'register_redirect' => '',
-
- ), $user_atts, 'xoo_el_inline_form');
-
- //On change of attribute from tabs to forms
- $atts['tabs'] = $atts['forms'];
-
- $tabs = array_map( 'trim', explode(',', $atts['tabs']) );
-
- if( $atts['pattern'] === 'single' ){
- $active = 'single';
- }
- else{
- if( !in_array( 'login', $tabs ) || !in_array( 'register', $tabs ) ){
- if( !in_array( 'login', $tabs ) ){
- $active = 'register';
- }
- if( !in_array( 'register', $tabs ) ){
- $active = 'login';
- }
- }
- elseif( $atts['active'] ){
- $active = $atts['active'];
- }
- elseif( !empty( $tabs ) && $tabs[0] ) {
- $active = $tabs[0];
- }
- else{
- $active = 'login';
- }
- }
-
-
- $args = array(
- 'form_active' => $active,
- 'return' => true,
- 'tabs' => $tabs,
- 'navstyle' => $atts['navstyle']
- );
-
- $args['forms']['single']['enable'] = $atts['pattern'] === 'single' ? 'yes' : 'no';
- $args['forms']['register']['enable'] = in_array( 'register', $tabs ) ? 'yes' : 'no';
-
- if( $atts['login_redirect'] ){
- $args['forms']['login']['redirect'] = $atts['login_redirect'] === 'same' ? $_SERVER['REQUEST_URI'] : sanitize_url( $atts['login_redirect'] );
- }
-
- if( $atts['register_redirect'] ){
- $args['forms']['register']['redirect'] = $atts['register_redirect'] === 'same' ? $_SERVER['REQUEST_URI'] : sanitize_url( $atts['register_redirect'] );
- }
-
-
- return xoo_el_get_form( $args );
-
- }
- add_shortcode( 'xoo_el_inline_form', 'xoo_el_inline_form_shortcode' );
-}
-
-
-function xoo_el_get_form( $args = array() ){
-
- $glSettings = xoo_el_helper()->get_general_option();
-
- $defaults = array(
- 'display' => 'inline',
- 'form_active' => 'login',
- 'return' => false,
- 'navstyle' => $glSettings['m-nav-pattern'],
- 'forms' => array(
- 'single' => array(
- 'enable' => $glSettings['m-form-pattern'] === 'single' ? 'yes' : 'no'
- ),
- 'login' => array(
- 'enable' => 'yes'
- ),
- 'register' => array(
- 'enable' => $glSettings['m-en-reg']
- ),
- 'lostpw' => array(
- 'enable' => 'yes'
- ),
- 'resetpw' => array(
- 'enable' => 'yes',
- 'pattern' => $glSettings['m-reset-pw']
- ),
- ),
- 'tabs' => array(
- 'login', 'register',
- )
- );
-
- $args = xoo_recursive_parse_args( $args, $defaults );
-
- if( $args['forms']['single']['enable'] === 'yes' ){
- $defaults['form_active'] = 'single';
- }
-
- $unsetTabs = array();
-
- foreach ($args['forms'] as $key => $form ) {
- if( $form['enable'] !== 'yes' ){
- $unsetTabs[] = $key;
- }
- }
-
- $args['tabs'] = array_diff( $args['tabs'], $unsetTabs );
-
-
-
- if( $glSettings['m-reset-pw'] === 'link' ){
-
- if( ( isset( $_GET['reset_password'] ) || isset( $_GET['show-reset-form'] ) ) ){
-
- $args['form_active'] = 'resetpw';
-
- $user = new WP_Error();
-
- if ( isset( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ) && 0 < strpos( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ], ':' ) ) { // @codingStandardsIgnoreLine
-
- list( $rp_id, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ), 2 ); // @codingStandardsIgnoreLine
- $userdata = get_userdata( absint( $rp_id ) );
- $rp_login = $userdata ? $userdata->user_login : '';
- $user = check_password_reset_key( $rp_key, $rp_login );
-
- $args['forms']['resetpw'] = array_merge( array(
- 'user' => $user,
- 'rp_login' => $rp_login,
- 'rp_key' => $rp_key
- ), $args['forms']['resetpw'] );
-
- }
- }
- else{
- unset( $args['forms'][ 'resetpw' ] );
- }
-
- }
- else if( $glSettings['m-reset-pw'] === 'disable' ){
- unset( $args['forms'][ 'resetpw' ] );
- }
-
-
- //Handling redirects
- if( isset( $_GET['redirect_to'] ) && $_GET['redirect_to'] ){
- $args['forms']['register']['redirect'] = $args['forms']['login']['redirect'] = sanitize_url( $_GET['redirect_to'] );
- }
- else{
-
- if( !isset( $args['forms']['register']['redirect'] ) || !$args['forms']['register']['redirect'] ){
- $regRedirect = xoo_el_helper()->get_general_option( 'm-red-register' );
- $args['forms']['register']['redirect'] = sanitize_url( !empty( $regRedirect ) ? $regRedirect : $_SERVER['REQUEST_URI'] );
- }
-
-
- if( !isset( $args['forms']['login']['redirect'] ) || !$args['forms']['login']['redirect'] ){
- $loginRedirect = xoo_el_helper()->get_general_option( 'm-red-login' );
- $args['forms']['login']['redirect'] = sanitize_url( !empty( $loginRedirect ) ? $loginRedirect : $_SERVER['REQUEST_URI'] );
- }
-
- }
-
-
- $args = apply_filters( 'xoo_el_form_args', $args );
-
-
- return xoo_el_helper()->get_template( 'xoo-el-form.php', array( 'args' => $args ), '', $args['return'] );
-}
-
-
-
-//Override woocommerce form login template
-function xoo_el_override_wc_login_form( $located, $template_name, $args, $template_path, $default_path ){
-
- $glSettings = xoo_el_helper()->get_general_option();
-
- if( $template_name === 'myaccount/form-login.php' && $glSettings['m-en-myaccount'] === "yes" ){
- $located = xoo_el_helper()->locate_template( 'xoo-el-wc-form-login.php', XOO_EL_PATH.'/templates/' );
- }
-
- if( $template_name === 'myaccount/form-lost-password.php' && $glSettings['m-en-myaccount'] === "yes" && $glSettings['m-reset-pw'] === "yes" && !is_user_logged_in() && $glSettings['m-myacclpw-sc'] ){
- $located = xoo_el_helper()->locate_template( 'xoo-el-wc-lost-password.php', XOO_EL_PATH.'/templates/' );
- }
-
- if( $template_name === 'global/form-login.php' && $glSettings['m-en-chkout'] === "yes" ){
- $located = xoo_el_helper()->locate_template( 'xoo-el-wc-checkout-form-login.php', XOO_EL_PATH.'/templates/' );
- }
-
- return $located;
-
-
-}
-add_filter( 'wc_get_template', 'xoo_el_override_wc_login_form', 99999, 5 );
-
-
-function xoo_el_get_myaccount_fields(){
-
- return xoo_el_fields()->get_fields('myaccount');
-
-}
-
-
-//Add fields to woocommerce account edit page
-function xoo_el_myaccount_details(){
-
- $fields = xoo_el_fields()->get_fields('myaccount');
-
- if( empty($fields) ) return;
-
- $args = array(
- 'icon' => false,
- 'validation' => 'yes',
- );
-
- $user_id = get_current_user_id();
-
- $first_half = false;
-
- foreach ( $fields as $field_id => $field_data ) {
-
- $args[ 'cont_class'] = array( 'xoo-aff-myacc-field', 'woocommerce-form-row', 'form-row', 'xoo-aff-'.$field_data['input_type'] );
-
- if( isset( $field_data['settings']['cols'] ) ){
- if( $field_data['settings']['cols'] === 'one' ){
- $args['cont_class'][] = 'form-row-wide';
- $first_half = false;
- }
- else{
- if( $first_half ){
- $args['cont_class'][] = 'form-row-last';
- $first_half = false;
- }
- else{
- $args['cont_class'][] = 'form-row-first';
- $first_half = true;
- }
- }
- }
-
- $field_value = get_user_meta( $user_id, $field_id, true );
-
- $args['value'] = $field_value;
-
-
- $args['label'] = xoo_el()->aff->fields->get_field_label( $field_id );
-
-
- xoo_el()->aff->fields->get_field_html( $field_id, $args );
-
- }
-
-}
-add_action('woocommerce_edit_account_form','xoo_el_myaccount_details', 10);
-
-
-function xoo_el_save_myaccount_details( $user_id ){
-
- $myaccFields = xoo_el_fields()->get_fields('myaccount');
-
- if( empty( $myaccFields ) ) return;
-
- $allFields = xoo_el()->aff->fields->get_fields_data();
-
- $doNotValidateOtherFields = array_keys( array_diff_key( $allFields, $myaccFields ) );
-
- $fieldValues = xoo_el()->aff->fields->validate_submitted_field_values( $_POST, $doNotValidateOtherFields );
-
- if( is_wp_error( $fieldValues ) ){
- foreach ( $fieldValues->get_error_messages() as $error_message ) {
- wc_add_notice( $error_message, 'error' );
- }
- }
- else{
- foreach( $fieldValues as $field_id => $field_value ) {
- update_user_meta( $user_id, $field_id, $field_value );
- }
- }
-
-
-}
-add_action('woocommerce_save_account_details','xoo_el_save_myaccount_details', 10);
-
-
-function xoo_el_register_generate_password(){
- if( !class_exists( 'woocommerce' ) ) return;
- $aff = xoo_el()->aff->fields;
- $fields = $aff->get_fields_data();
- if( isset( $fields['xoo_el_reg_pass'] ) && $fields['xoo_el_reg_pass']['settings']['active'] === "no" ){
- add_filter( 'pre_option_woocommerce_registration_generate_password', function(){ return 'yes'; } );
- }
-}
-add_action( 'init', 'xoo_el_register_generate_password' );
-
-
-//Auto fil woocommerce fields
-function xoo_el_autofill_wc_fields( $customer_id, $customer_data ){
- if( !class_exists( 'woocommerce' ) ) return;
- $customer = new Wc_Customer( $customer_id );
- if( !$customer ) return;
-
- $aff = xoo_el()->aff->fields;
- $fields = $aff->get_fields_data();
- $firstname = isset( $fields['xoo_el_reg_fname'] ) ? $fields['xoo_el_reg_fname'] : false;
- $lastname = isset( $fields['xoo_el_reg_lname'] ) ? $fields['xoo_el_reg_lname'] : false;
-
- if( $firstname ){
- if( isset( $firstname['settings']['xoo_el_merge_wc_field'] ) && $firstname['settings']['xoo_el_merge_wc_field'] === "yes" ){
- update_user_meta( $customer_id, 'billing_first_name', $customer->get_first_name() );
- update_user_meta( $customer_id, 'shipping_first_name', $customer->get_first_name() );
- }
- }
-
- if( $lastname ){
- if( isset( $lastname['settings']['xoo_el_merge_wc_field'] ) && $lastname['settings']['xoo_el_merge_wc_field'] === "yes" ){
- update_user_meta( $customer_id, 'billing_last_name', $customer->get_last_name() );
- update_user_meta( $customer_id, 'shipping_last_name', $customer->get_last_name() );
- }
- }
-}
-add_action( 'xoo_el_created_customer', 'xoo_el_autofill_wc_fields', 10, 2 );
-
-
-function xoo_el_redirect_endpoints(){
-
- if( xoo_el_helper()->get_general_option( 'm-ep-success' ) !== "yes" ) return;
-
- add_filter( 'xoo_el_login_redirect', function( $redirect ){
- $redirect = $redirect ? add_query_arg( 'login', 'success', $redirect ) : $redirect;
- return $redirect;
- } );
-
- add_filter( 'xoo_el_registration_redirect', function( $redirect ){
- $redirect = $redirect ? add_query_arg( 'register', 'success', $redirect ) : $redirect;
- return $redirect;
- } );
-}
-add_action( 'init', 'xoo_el_redirect_endpoints' );
-
-
-function xoo_elext(){
-
- $defaults = wp_kses_allowed_html( 'post' );
-
- $allowed = array(
- 'input' => array(
- 'class' => array(),
- 'name' => array(),
- 'placeholder' => array(),
- 'type' => array(),
- 'id' => array(),
- 'value' => array(),
- 'disabled' => array(),
- 'minlength' => array(),
- 'maxlength' => array(),
- 'checked' => array(),
- 'min' => array(),
- 'max' => array(),
- 'required' => array()
- ),
- 'select' => array(
- 'class' => array(),
- 'name' => array(),
- 'type' => array(),
- 'id' => array(),
- 'disabled' => array(),
- ),
- 'option' => array(
- 'value' => array(),
- 'selected' => array(),
- ),
- );
-
- return array_merge( $defaults, $allowed );
-
-}
-
-
-function xoo_el_popup_form(){
-
- $tabs = xoo_el_helper()->get_general_option( 'popup-forms' );
-
- $args = array(
- 'form_class' => 'xoo-el-form-popup',
- 'display' => 'popup',
- 'form_active' => xoo_el_helper()->get_general_option( 'm-form-pattern' ) === 'single' ? 'single' : xoo_el_helper()->get_general_option( 'ao-default-form' ),
- 'tabs' => $tabs,
- );
-
- xoo_el_get_form( $args );
-}
-
-
-
-function xoo_el_header_image(){
-
- $image = esc_html( xoo_el_helper()->get_style_option( 'sy-head-img' ) );
-
- if( !$image ) return;
-
- ?>
- <img src="<?php echo $image ?>" placeholder="logo" class="xoo-el-head-img">
- <?php
-
-}
-add_action( 'xoo_el_before_header', 'xoo_el_header_image' );
-
-
-function xoo_el_nav_footer_links( $form, $args ){
-
- ?>
-
- <?php if( $form === 'login' && in_array( 'register' , $args['tabs'] ) && isset( $args['navstyle'] ) && $args['navstyle'] === 'links' ): ?>
- <span class="xoo-el-reg-tgr xoo-el-nav-ft"><?php _e( "Don't have an account? Signup now", 'easy-login-woocommerce' ) ?></span>
- <?php endif; ?>
-
- <?php if( $form === 'register' && in_array( 'login' , $args['tabs'] ) && isset( $args['navstyle'] ) && $args['navstyle'] === 'links' ): ?>
- <span class="xoo-el-login-tgr xoo-el-nav-ft"><?php _e( "Already a member? Login", 'easy-login-woocommerce' ) ?></span>
- <?php endif; ?>
-
-
- <?php if( $form === 'lostpw' && isset( $args['navstyle'] ) && $args['navstyle'] === 'links' ): ?>
- <span class="xoo-el-login-tgr xoo-el-nav-ft"><i class="xoo-el-icon-arrow-left2"></i></span>
- <?php endif; ?>
-
- <?php
-
-}
-add_action( 'xoo_el_after_form', 'xoo_el_nav_footer_links',10, 2 );
-
-
-function xoo_el_add_inline_form_redirects( $form, $args ){
-
- if( $args['display'] !== 'inline' ) return;
-
- if( $form === 'login' && isset( $args['forms']['login'] ) && isset( $args['forms']['login']['redirect'] ) ){
- $redirect = $args['forms']['login']['redirect'];
- }
-
- if( $form === 'register' && isset( $args['forms']['register'] ) && isset( $args['forms']['register']['redirect'] ) ){
- $redirect = $args['forms']['register']['redirect'];
- }
-
- if( isset( $redirect ) ){
- ?>
- <input type="hidden" name="xoo_el_redirect" value="<?php echo esc_url( $redirect ); ?>">
- <?php
- }
-
-}
-//add_action( 'xoo_el_form_end', 'xoo_el_add_inline_form_redirects', 10, 2 );
-
-
-/* Country flag fix for OTP login previous version */
-function xoo_el_ml_old_cc_fix( $fields ){
- if( version_compare( XOO_ML_VERSION , '2.5.2', '<' ) && isset( $fields['xoo-ml-reg-phone-cc'] ) ){
- $fields['xoo-ml-reg-phone-cc']['use_select2'] = 'yes';
- }
- return $fields;
-}
-add_filter( 'xoo_ml_el_login_form_input_fields', 'xoo_el_ml_old_cc_fix' );
-
-
-if( defined( 'MAILPOET_VERSION' ) ){
- function xoo_el_mailpoet_subscribe( $data ){
-
- if( isset( $_POST['xoo-mailpoet-subscribe'] ) && trim( $_POST['xoo-mailpoet-subscribe'] ) ){
- $_POST['mailpoet']['subscribe_on_register'] = true;
- }
- else{
- $_POST['mailpoet']['subscribe_on_register_active'] = true;
- }
-
- return $data;
-
- }
- add_filter( 'xoo_el_register_new_customer_data', 'xoo_el_mailpoet_subscribe' );
-}
-
-
-//Paid membership compatibility
-function xoo_el_paid_membership_compat(){
-
- if( !isset( $_POST['action'] ) || $_POST['action'] !== 'xoo_el_form_action' ) return;
-
- remove_action( 'wp_login_failed', 'pmpro_login_failed', 10, 2 );
- remove_filter( 'authenticate', 'pmpro_authenticate_username_password', 30, 3);
-
-}
-add_action( 'init', 'xoo_el_paid_membership_compat' );
-
-
-/* Fix for OTP Login version compare glitch in 3.2.5 & 3.2.6 */
-
-
-function xoo_el_ml_inline_style_glitch_fix(){
-
- if( !function_exists('xoo_ml') || !in_array( XOO_ML_VERSION, array( '3.2.5', '3.2.6' ), true ) ) return;
-
- $instance = Xoo_Ml_Easy_Login_Functions::get_instance();
-
- remove_action( 'wp_enqueue_scripts', array( $instance, 'inline_style' ) );
-
- add_action( 'wp_enqueue_scripts', function(){
-
- if( version_compare( XOO_EL_VERSION, '3.1.2', '<' ) || xoo_el()->aff->has_old_field_layout() ){
-
- $sy_options = get_option( xoo_el()->aff->admin->settings->get_option_key( 'general' ), true );
-
- $focusBGColor = esc_html( $sy_options['s-input-focusbgcolor'] );
- $focusTxtColor = esc_html( $sy_options['s-input-focustxtcolor'] );
- $fieldmargin = esc_html( $sy_options['s-field-bmargin'] );
- $textColor = esc_html( $sy_options['s-field-bmargin'] );
- $inputbgcolor = esc_html( $sy_options['s-input-bgcolor'] );
- $inputtxtcolor = esc_html( $sy_options['s-input-txtcolor'] );
- $inputBorColor = esc_html( $sy_options['s-input-borcolor'] );
- $iconBorColor = esc_html( $sy_options['s-icon-borcolor'] );
- $iconBorWidth = esc_html( $sy_options['s-icon-borwidth'] );
- $inputBorWidth = (int) $sy_options['s-input-borwidth'];
- $inputHeight = (int) $sy_options['s-input-height'];
-
- $style = '.xoo-ml-merged-cc.xoo-ml-focused .xoo-aff-group select + .select2, .xoo-ml-merged-cc.xoo-ml-focused .xoo-aff-group input[type="tel"]{
- background-color: '.$focusBGColor.';
- color: '.$focusTxtColor.';
- }
- .xoo-ml-merged-cc.xoo-ml-focused .xoo-aff-group .select2-selection__rendered, .xoo-ml-merged-cc.xoo-ml-focused .xoo-aff-group .select2-container--default .select2-selection--single .select2-selection__rendered{
- color: '.$focusTxtColor.';
- }
- .xoo-ml-merged-cc{
- margin-bottom: '.$fieldmargin.'px;
- }
- .xoo-ml-merged-cc input:-webkit-autofill:focus{
- -webkit-text-fill-color: '.$focusTxtColor.';
- box-shadow: inset 0 0 20px 20px '.$focusBGColor.';
- }
- .xoo-ml-merged-cc input:-webkit-autofill,
- .xoo-ml-merged-cc input:-webkit-autofill:active{
- -webkit-text-fill-color: '.$inputtxtcolor.';
- box-shadow: inset 0 0 0 30px '.$inputbgcolor.';
- }
- .xoo-ml-merged-cc-cont{
- border-color: '.$inputBorColor.';
- border-width: '.$inputBorWidth.'px;
- }
- .xoo-ml-merged-cc-cont span.select2, .xoo-ml-merged-cc-cont input[type="tel"]{
- height: '. ($inputHeight - ($inputBorWidth * 2)) .'px;
- }
- body.rtl .xoo-aff-cont-phone_code span.xoo-aff-input-icon {
- border-right: 0;
- border-left: '.$iconBorWidth.'px solid '.$iconBorColor.';
- }
- body:not(.rtl) .xoo-ml-merged-cc .xoo-aff-input-group .xoo-aff-input-icon {
- border-right: '.$inputBorWidth.'px solid '.$inputBorColor.';
- }
- .xoo-el-form-container form.xoo-ml-otp-form input.xoo-ml-otp-input{
- background-color: '.$inputbgcolor.';
- color: '.$inputtxtcolor.';
- border-bottom: '.$inputBorWidth.'px solid '.$inputBorColor.';
- }
- .xoo-el-form-container form.xoo-ml-otp-form input.xoo-ml-otp-input:focus{
- background-color: '.$focusBGColor.';
- color: '.$focusTxtColor.';
- }
-
- body:not(.rtl) .xoo-ml-merged-cc-cont:has(.xoo-aff-input-group) {
- border-left: 0;
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
- }
- .xoo-ml-merged-cc select.xoo-ml-phone-cc + .select2.select2-container {
- padding: 0;
- }
- ';
-
- }
- else{
-
- $sy_options = xoo_el()->aff->get_field_option();
-
- $inputBorderOptions = xoo_el()->aff->ff_helper->get_border_options( $sy_options['s-input-border'] );
- $inputBorderCSS = xoo_el()->aff->ff_helper->get_border_css_value( $sy_options['s-input-border'] );
- $inputBorderFocusOptions = xoo_el()->aff->ff_helper->get_border_options( $sy_options['s-input-border-focus'] );
- $inputBorderFocus = xoo_el()->aff->ff_helper->get_border_css_value( $sy_options['s-input-border-focus'] );
- $focusbgcolor = $sy_options['s-input-focusbgcolor'];
- $focustxtcolor = $sy_options['s-input-focustxtcolor'];
- $inputbgcolor = esc_html( $sy_options['s-input-bgcolor'] );
- $inputHeight = (int) $sy_options['s-input-height'];
-
-
-
- $style = "
- .xoo-ml-merged-cc-cont .xoo-aff-input-group .xoo-aff-input-icon{
- border: 0;
- margin: 0;
- }
-
- .xoo-ml-merged-cc-cont{
- {$inputBorderCSS};
- background-color: {$inputbgcolor};
- }
- .xoo-ml-merged-cc-cont .xoo-ml-phone-cc + .select2 .select2-selection.select2-selection--single{
- padding: 0;
- }
- .xoo-ml-focused .xoo-ml-merged-cc-cont{
- {$inputBorderFocus}
- background-color: {$focusbgcolor};
- }
- .xoo-ml-focused .xoo-aff-group select.xoo-aff-field + .select2{
- background-color: {$focusbgcolor};
- color: {$focustxtcolor};
- }
- .xoo-ml-focused .xoo-aff-group .select2-selection__rendered, .xoo-ml-focused .xoo-aff-group .select2-container--default .select2-selection--single .select2-selection__rendered{
- color: {$focustxtcolor};
- }
- .xoo-ml-merged-cc .xoo-aff-group select.xoo-aff-field, .xoo-ml-merged-cc .xoo-aff-group select.xoo-aff-field + .select2, .xoo-ml-merged-cc .xoo-aff-group input[type=tel].xoo-aff-field{
- height: calc( {$inputHeight}px - ".$inputBorderOptions['size'] * 2 ."px );
- line-height: calc( {$inputHeight}px - ".$inputBorderOptions['size'] * 2 ."px );
- border: 0;
- }
- .xoo-ml-merged-cc .xoo-aff-group input[type=tel].xoo-aff-field:focus, .xoo-ml-merged-cc.xoo-ml-focused .xoo-aff-group select.xoo-aff-field + .select2{
- height: calc( {$inputHeight}px - ".$inputBorderFocusOptions['size'] * 2 ."px );
- line-height: calc( {$inputHeight}px - ".$inputBorderFocusOptions['size'] * 2 ."px );
- border: 0;
- }
-
- ";
- }
-
- wp_add_inline_style( 'xoo-ml-style', $style );
- }, 10 );
-
-}
-
-add_action( 'wp_enqueue_scripts', 'xoo_el_ml_inline_style_glitch_fix', 5 );
-
+<?php
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
+
+if (!function_exists('array_is_list')) {
+ function array_is_list(array $arr)
+ {
+ if ($arr === []) {
+ return true;
+ }
+ return array_keys($arr) === range(0, count($arr) - 1);
+ }
+}
+
+if ( ! function_exists( 'xoo_recursive_parse_args' ) ) {
+ function xoo_recursive_parse_args( $args, $defaults ) {
+ $new_args = (array) $defaults;
+
+ foreach ( $args as $key => $value ) {
+ if ( is_array( $value ) && isset( $new_args[ $key ] ) && !array_is_list( $value ) ) {
+ $new_args[ $key ] = xoo_recursive_parse_args( $value, $new_args[ $key ] );
+ }
+ else {
+ $new_args[ $key ] = $value;
+ }
+ }
+
+ return $new_args;
+ }
+}
+
+//Menu items filter
+if( !function_exists( 'xoo_el_nav_menu_items' ) ):
+ function xoo_el_nav_menu_items( $items ) {
+
+ if( empty( $items ) || !is_array( $items ) ) return;
+
+
+ $actions_classes = array(
+ 'xoo-el-login-tgr',
+ 'xoo-el-reg-tgr',
+ 'xoo-el-lostpw-tgr',
+ 'xoo-el-logout-menu',
+ 'xoo-el-myaccount-menu',
+ 'xoo-el-username-menu',
+ 'xoo-el-firstname-menu'
+ );
+
+ $user = wp_get_current_user();
+
+ foreach ( $items as $key => $item ) {
+
+ $classes = $item->classes;
+
+ if( !empty( $action_class = array_values( array_intersect( $actions_classes, $classes ) ) ) ){
+
+ $action_class = $action_class[0];
+
+ if( is_user_logged_in() ){
+
+ if( $action_class === "xoo-el-myaccount-menu" ){
+ //do nothing
+ continue;
+ }
+ elseif( $action_class === "xoo-el-logout-menu" ){
+ if( $item->url ) continue;
+ $glSettings = xoo_el_helper()->get_general_option();
+ $logout_redirect = !empty( $glSettings['m-red-logout'] ) ? sanitize_url( $glSettings['m-red-logout'] ) : ( sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) ) );
+ $item->url = wp_logout_url( $logout_redirect );
+ }
+ elseif( $action_class === "xoo-el-firstname-menu"){
+
+ $name = !$user->user_firstname ? $user->user_login : $user->user_firstname;
+ $item->title = get_avatar($user->ID).str_replace( 'firstname' , $name , $item->title );
+ if( class_exists('woocommerce') ){
+ $item->url = wc_get_page_permalink( 'myaccount' );
+ }
+ }
+ elseif( $action_class === "xoo-el-username-menu"){
+ $item->title = get_avatar($user->ID).str_replace( 'username' , $user->user_login , $item->title );
+ if( class_exists('woocommerce') ){
+ $item->url = wc_get_page_permalink( 'myaccount' );
+ }
+ }
+ else{
+ unset($items[$key]);
+ }
+
+ }
+ else{
+ if( $action_class === "xoo-el-logout-menu" || $action_class === "xoo-el-myaccount-menu" || $action_class === "xoo-el-username-menu" || $action_class === "xoo-el-firstname-menu"){
+ unset($items[$key]);
+ }
+
+ }
+
+ }
+ }
+
+ return $items;
+ }
+ add_filter('wp_nav_menu_objects','xoo_el_nav_menu_items',11);
+endif;
+
+
+//Add notice
+function xoo_el_add_notice( $notice_type = 'error', $message = '', $notice_class = null ){
+
+ $title = $text = '';
+
+ if( !is_array( $message ) ){
+ $message = array(
+ 'text' => $message
+ );
+ }
+
+ if( $notice_type === 'error' || $notice_type === 'warning' ){
+ $icon = 'xoo-el-icon-notice';
+ }
+ else if( $notice_type === 'success' ){
+ $icon = 'xoo-el-icon-check-badge';
+ }
+ else{
+ $icon = null;
+ }
+
+ $message = wp_parse_args( $message, array(
+ 'icon' => $icon,
+ 'title' => '',
+ 'text' => ''
+ ) );
+
+ $title = $message['title'];
+ $text = $message['text'];
+ $icon = $message['icon'];
+
+
+ $classes = 'xoo-el-notice-'.$notice_type.' '.$notice_class;
+
+ ob_start();
+
+ ?>
+
+ <div class="<?php echo esc_attr($classes ) ?>">
+
+ <?php if( $icon ): ?>
+
+ <div class="xoo-el-notice-icon <?php echo wp_kses_post( $icon ) ?>"></div>
+
+ <?php endif; ?>
+
+ <div class="xoo-el-notice-txtcont">
+
+ <?php if( $title ): ?>
+ <div class="xoo-el-noticetitle"><?php echo wp_kses_post( $title ) ?></div>
+ <?php endif; ?>
+
+ <?php if( $text ): ?>
+ <div class="xoo-el-noticetxt"><?php echo wp_kses_post( $text ) ?></div>
+ <?php endif; ?>
+
+ </div>
+
+ </div>
+
+ <?php
+
+ $html = ob_get_clean();
+
+ $notice_html = apply_filters( 'xoo_el_notice_html', $html, $text, $classes );
+
+ $notice_html = apply_filters( 'xoo_el_notice_html_v2', $html, $message, $classes );
+
+ return $notice_html;
+}