'alphagf_fields', 'text' => $this->get_form_editor_field_title(), ); } public function get_form_editor_field_icon() { return 'gform-icon alphagf_icon icon-math-captcha'; } public function get_field_input($form, $value = array(), $entry = null) { if ($this->is_form_editor()) { return $this->get_editor_field_content(); } $form_id = absint($form['id']); $is_entry_detail = $this->is_entry_detail(); $is_form_editor = $this->is_form_editor(); $id = (int) $this->id; $field_id = ($is_entry_detail || $is_form_editor || $form_id === 0) ? 'input_' . $id : 'input_' . $form_id . '_' . $id; $tab_index = GFCommon::get_tabindex(); $placeholder_attribute = $this->get_field_placeholder_attribute(); $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"'; $captcha = ALPHAGF_Math_Captcha::get_instance(); $posted_token = (string) rgpost('input_' . $id . '_hash'); $posted_data = $captcha->parse_token($posted_token); // On multi-page forms the field is re-rendered after it has been solved: keep the same question, // otherwise the answer carried over from the earlier page would no longer match on the final page. if (! $this->failed_validation && $posted_data && $captcha->verify_answer($posted_token, $value)) { $token = $posted_token; $question = $posted_data['q']; } else { $captcha_problem = $captcha->generate_math_problem('easy', array('addition', 'subtraction')); $token = $captcha_problem['token']; $question = $captcha_problem['question']; $value = ''; } $captcha_image = $captcha->generate_svg_captcha($question); $html = '