public function render($form, $ajax)
 {
     if (!class_exists('GFFormDisplay') || self::isDisabled()) {
         return $form;
     }
     self::enqueueScripts($form, $ajax);
     self::updateRenderedCount();
     $next = GFFormDisplay::get_max_field_id($form) + 1;
     $template = sprintf($this->template, get_option('rg_gforms_captcha_public_key'));
     $opts = array('type' => 'section', '_is_entry_detail' => NULL, 'id' => $next, 'label' => '', 'adminLabel' => '', 'isRequired' => false, 'size' => 'medium', 'errorMessage' => '', 'inputs' => NULL, 'displayOnly' => true, 'labelPlacement' => '', 'content' => '', 'formId' => $form['id'], 'pageNumber' => GFFormDisplay::get_current_page($form['id']), 'conditionalLogic' => '', 'cssClass' => $this->buCAPTCHAIdentifier . '_section');
     $form['fields'][] = GF_Fields::create($opts);
     $captcha_opts = array('type' => 'html', 'id' => $next + 1, 'content' => apply_filters('bu_gravityforms_global_recaptcha_div', $template), 'cssClass' => $this->buCAPTCHAIdentifier);
     $form['fields'][] = GF_Fields::create(array_merge($opts, $captcha_opts));
     return $form;
 }
Exemplo n.º 2
0
 /**
  * Check if the rest of the form has passed validation, is the last page, and that the honeypot field has not been completed.
  *
  * @param array $validation_result Contains the validation result, the form object, and the failed validation page number.
  *
  * @return array $validation_result
  */
 public function maybe_validate($validation_result)
 {
     $form = $validation_result['form'];
     $is_last_page = GFFormDisplay::is_last_page($form);
     $failed_honeypot = false;
     if ($is_last_page && rgar($form, 'enableHoneypot')) {
         $honeypot_id = GFFormDisplay::get_max_field_id($form) + 1;
         $failed_honeypot = !rgempty("input_{$honeypot_id}");
     }
     if (!$validation_result['is_valid'] || !$is_last_page || $failed_honeypot) {
         return $validation_result;
     }
     return $this->validation($validation_result);
 }
 /**
  * Check if the rest of the form has passed validation, is the last page, and that the honeypot field has not been completed.
  *
  * @param array $validation_result Contains the validation result, the form object, and the failed validation page number.
  *
  * @return array $validation_result
  */
 public function maybe_validate($validation_result)
 {
     $form = $validation_result['form'];
     $is_last_page = GFFormDisplay::is_last_page($form);
     $failed_honeypot = false;
     if ($is_last_page && rgar($form, 'enableHoneypot')) {
         $honeypot_id = GFFormDisplay::get_max_field_id($form) + 1;
         $failed_honeypot = !rgempty("input_{$honeypot_id}");
     }
     $is_heartbeat = rgpost('action') == 'heartbeat';
     // Validation called by partial entries feature via the heartbeat API.
     if (!$validation_result['is_valid'] || !$is_last_page || $failed_honeypot || $is_heartbeat) {
         return $validation_result;
     }
     return $this->validation($validation_result);
 }
 private static function is_ready_for_capture($validation_result)
 {
     $form = $validation_result['form'];
     $is_last_page = GFFormDisplay::is_last_page($form);
     $failed_honeypot = false;
     if ($is_last_page && rgar($form, 'enableHoneypot')) {
         $honeypot_id = GFFormDisplay::get_max_field_id($form) + 1;
         $failed_honeypot = !rgempty("input_{$honeypot_id}");
     }
     $is_heartbeat = rgpost('action') == 'heartbeat';
     // Validation called by partial entries feature via the heartbeat API.
     if (!$validation_result['is_valid'] || !$is_last_page || $failed_honeypot || $is_heartbeat) {
         return false;
     }
     //getting config that matches condition (if conditions are enabled)
     $config = self::get_config($validation_result["form"]);
     if (!$config) {
         return false;
     }
     //making sure credit card field is visible
     $creditcard_field = self::get_creditcard_field($validation_result["form"]);
     if (RGFormsModel::is_field_hidden($validation_result["form"], $creditcard_field, array())) {
         return false;
     }
     return $config;
 }