is_option_on() || ! $this->check_honeypot_filter() ) { // never flag as honeypot spam if disabled. return true; } return ! $this->is_honeypot_spam(); } /** * @return boolean */ private function is_honeypot_spam() { $is_honeypot_spam = $this->is_legacy_honeypot_spam(); if ( ! $is_honeypot_spam ) { // Check the newer honeypot input name which is randomly generated so it's more difficult to detect. $class_name = self::get_honeypot_class_name(); $honeypot_value = FrmAppHelper::get_param( $class_name, '', 'get', 'sanitize_text_field' ); $is_honeypot_spam = '' !== $honeypot_value; } $form = $this->get_form(); $atts = compact( 'form' ); return apply_filters( 'frm_process_honeypot', $is_honeypot_spam, $atts ); } /** * Check the old frm_verify key. We'll continue to consider any entry with an frm_verify value as spam. * * @return bool */ private function is_legacy_honeypot_spam() { $legacy_honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' ); return '' !== $legacy_honeypot_value; } /** * @return mixed either true, or false. */ private function check_honeypot_filter() { $form = $this->get_form(); return apply_filters( 'frm_run_honeypot', true, compact( 'form' ) ); } /** * @return string */ private function check_honeypot_setting() { $form = $this->get_form(); $key = $this->get_option_key(); return $form->options[ $key ]; } /** * @param int $form_id * * @return void */ public static function maybe_render_field( $form_id ) { $honeypot = new self( $form_id ); if ( $honeypot->should_render_field() ) { $honeypot->render_field(); } } /** * @return bool */ public function should_render_field() { return $this->is_option_on() && $this->check_honeypot_filter(); } /** * @return void */ public function render_field() { $honeypot = $this->check_honeypot_setting(); $form = $this->get_form(); $class_name = self::get_honeypot_class_name(); $input_attrs = array( 'id' => 'frm_email_' . absint( $form->id ), 'type' => 'strict' === $honeypot ? 'email' : 'text', 'class' => 'frm_verify', 'name' => $class_name, 'value' => FrmAppHelper::get_param( $class_name, '', 'get', 'wp_kses_post' ), ); if ( 'strict' !== $honeypot ) { $input_attrs['autocomplete'] = 'false'; } ?>
/>