Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../includes/Fields
File: PasswordConfirm.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Fields_PasswordConfirm
[3] Fix | Delete
*/
[4] Fix | Delete
class NF_Fields_PasswordConfirm extends NF_Fields_Password
[5] Fix | Delete
{
[6] Fix | Delete
protected $_name = 'passwordconfirm';
[7] Fix | Delete
[8] Fix | Delete
protected $_type = 'passwordconfirm';
[9] Fix | Delete
[10] Fix | Delete
protected $_nicename = 'Password Confirm';
[11] Fix | Delete
[12] Fix | Delete
protected $_section = '';
[13] Fix | Delete
[14] Fix | Delete
protected $_error_message = '';
[15] Fix | Delete
[16] Fix | Delete
protected $_settings = array( 'confirm_field' );
[17] Fix | Delete
[18] Fix | Delete
public function __construct()
[19] Fix | Delete
{
[20] Fix | Delete
parent::__construct();
[21] Fix | Delete
[22] Fix | Delete
$this->_nicename = esc_html__( 'Password Confirm', 'ninja-forms' );
[23] Fix | Delete
[24] Fix | Delete
$this->_settings[ 'confirm_field' ][ 'value' ] = esc_attr__( 'password', 'ninja-forms' );
[25] Fix | Delete
$this->_settings[ 'confirm_field' ][ 'field_types' ] = array( 'password' );
[26] Fix | Delete
$this->_settings[ 'confirm_field' ][ 'field_value_format' ] = 'key';
[27] Fix | Delete
[28] Fix | Delete
add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) );
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
function hide_field_type( $field_types )
[32] Fix | Delete
{
[33] Fix | Delete
$field_types[] = $this->_name;
[34] Fix | Delete
[35] Fix | Delete
return $field_types;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
public function validate( $field, $data )
[39] Fix | Delete
{
[40] Fix | Delete
$errors = parent::validate( $field, $data );
[41] Fix | Delete
[42] Fix | Delete
$password_fields = $this->get_password_fields( $data );
[43] Fix | Delete
[44] Fix | Delete
if( ! is_array( $password_fields ) || empty( $password_fields ) ) return $errors;
[45] Fix | Delete
[46] Fix | Delete
foreach( $password_fields as $password_field ){
[47] Fix | Delete
[48] Fix | Delete
if( $this->is_matching_values( $field, $password_field ) ) continue;
[49] Fix | Delete
[50] Fix | Delete
$errors[] = $this->get_error_message();
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
return $errors;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
private function get_password_fields( $data )
[57] Fix | Delete
{
[58] Fix | Delete
$password_fields = array();
[59] Fix | Delete
[60] Fix | Delete
foreach( $data[ 'fields' ] as $field ){
[61] Fix | Delete
[62] Fix | Delete
if( 'password' != $field[ 'type' ] ) continue;
[63] Fix | Delete
[64] Fix | Delete
$password_fields[] = $field;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
return $password_fields;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
private function is_matching_values( $a, $b )
[71] Fix | Delete
{
[72] Fix | Delete
return $a[ 'value' ] === $b[ 'value' ];
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
private function get_error_message()
[76] Fix | Delete
{
[77] Fix | Delete
if( $this->_error_message ) return $this->_error_message;
[78] Fix | Delete
[79] Fix | Delete
$error_message = esc_html__( 'Passwords do not match', 'ninja-forms' );
[80] Fix | Delete
[81] Fix | Delete
$error_message = apply_filters( 'ninja_forms_password_confirm_mismatch', $error_message );
[82] Fix | Delete
[83] Fix | Delete
return $this->_error_message = $error_message;
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function