| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
if (!class_exists('BVContactForm7Handler')) : |
| 5 |
|
| 6 |
class BVContactForm7Handler { |
| 7 |
private $form_id; |
| 8 |
private $bypass_params = array(); |
| 9 |
|
| 10 |
public function __construct($form_id, $bypass_params) { |
| 11 |
$this->form_id = $form_id; |
| 12 |
$this->bypass_params = $bypass_params; |
| 13 |
} |
| 14 |
|
| 15 |
public function bypass() { |
| 16 |
if (array_key_exists('should_bypass_captcha', $this->bypass_params)) { |
| 17 |
$this->bypassCaptcha(); |
| 18 |
} |
| 19 |
|
| 20 |
if (array_key_exists('should_bypass_email', $this->bypass_params)) { |
| 21 |
$this->bypassEmail(); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
private function bypassCaptcha() { |
| 26 |
add_filter('wpcf7_skip_spam_check', '__return_true', PHP_INT_MAX); |
| 27 |
} |
| 28 |
|
| 29 |
private function bypassEmail() { |
| 30 |
add_action('wpcf7_before_send_mail', function ($contact_form, &$abort) { |
| 31 |
$abort = true; |
| 32 |
}, PHP_INT_MAX, 2); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
endif; |