Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../includes/Fields
File: Spam.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Fields_Spam
[3] Fix | Delete
*/
[4] Fix | Delete
class NF_Fields_Spam extends NF_Abstracts_Input
[5] Fix | Delete
{
[6] Fix | Delete
protected $_name = 'spam';
[7] Fix | Delete
[8] Fix | Delete
protected $_type = 'spam';
[9] Fix | Delete
[10] Fix | Delete
protected $_section = 'misc';
[11] Fix | Delete
[12] Fix | Delete
protected $_icon = 'ban';
[13] Fix | Delete
[14] Fix | Delete
protected $_templates = 'textbox';
[15] Fix | Delete
[16] Fix | Delete
protected $_settings = array( 'spam_answer' );
[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__( 'Anti-Spam', 'ninja-forms' );
[23] Fix | Delete
[24] Fix | Delete
// Rename Label setting to Question
[25] Fix | Delete
$this->_settings[ 'label' ][ 'label' ] = esc_html__( 'Question', 'ninja-forms' );
[26] Fix | Delete
$this->_settings[ 'label_pos' ][ 'label' ] = esc_html__( 'Question Position', 'ninja-forms' );
[27] Fix | Delete
[28] Fix | Delete
// Manually set Field Key and stop tracking.
[29] Fix | Delete
$this->_settings[ 'key' ][ 'value' ] = 'spam';
[30] Fix | Delete
$this->_settings[ 'manual_key' ][ 'value' ] = TRUE;
[31] Fix | Delete
[32] Fix | Delete
[33] Fix | Delete
// Default Required setting to TRUE and hide setting.
[34] Fix | Delete
$this->_settings[ 'required' ][ 'value' ] = 1;
[35] Fix | Delete
$this->_settings[ 'required' ][ 'group' ] = '';
[36] Fix | Delete
[37] Fix | Delete
add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) );
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Validate
[42] Fix | Delete
*
[43] Fix | Delete
* @param $field
[44] Fix | Delete
* @param $data
[45] Fix | Delete
* @return array $errors
[46] Fix | Delete
*/
[47] Fix | Delete
public function validate( $field, $data )
[48] Fix | Delete
{
[49] Fix | Delete
$errors = parent::validate( $field, $data );
[50] Fix | Delete
[51] Fix | Delete
if(
[52] Fix | Delete
( isset( $field[ 'spam_answer' ] ) && isset( $field[ 'value' ] ) )
[53] Fix | Delete
&& ( $field[ 'spam_answer' ] != $field[ 'value' ] )
[54] Fix | Delete
){
[55] Fix | Delete
$errors = esc_html__( 'Incorrect Answer', 'ninja-forms' );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
return $errors;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
public function get_parent_type()
[62] Fix | Delete
{
[63] Fix | Delete
return 'spam';
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
function hide_field_type( $field_types )
[67] Fix | Delete
{
[68] Fix | Delete
$field_types[] = $this->_name;
[69] Fix | Delete
[70] Fix | Delete
return $field_types;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function