Skip to content

Commit

Permalink
Merge pull request #67 from Zodiac1978/main
Browse files Browse the repository at this point in the history
Remove warning for unsafe email configuration w/o protection

that's perfectly fine! as for the on/off options we could offer a hook or an entry in the plugin configuration menu (maybe in the advanced section) but I'm afraid it's getting too "complex". @Zodiac1978, as user, which way would you prefer to configure these stuff?
  • Loading branch information
erikyo committed Nov 23, 2023
2 parents f23fa9e + b01e6b1 commit 9cf20d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/CF7_AntiSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ private function load_frontend() {

/* It adds hidden fields to the form */
$this->loader->add_filter( 'wpcf7_form_hidden_fields', $plugin_frontend, 'cf7a_add_hidden_fields', 1 );
$this->loader->add_filter( 'wpcf7_config_validator_available_error_codes', $plugin_frontend, 'cf7a_remove_cf7_error_message', 10, 2 );

/* adds the javascript script to frontend */
$this->loader->add_action( 'wp_footer', $plugin_frontend, 'enqueue_scripts' );
Expand Down
18 changes: 18 additions & 0 deletions core/CF7_AntiSpam_Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ public function __construct( $plugin_name, $version ) {
$this->options = CF7_AntiSpam::get_options();
}

/**
* Remove "unsafe email config" error messsage
*
* @param array $error_codes List of error codes.
* @param object $contact_form Current contact form object.
* @return array Modified array of error codes, without "unsafe_email_without_protection".
*/
public function cf7a_remove_cf7_error_message( $error_codes, $contact_form ) {
// List error codes to disable here.
$error_codes_to_disable = array(
'unsafe_email_without_protection',
);

$error_codes = array_diff( $error_codes, $error_codes_to_disable );

return $error_codes;
}

/**
* It takes the form elements, clones the text inputs, adds a class to the cloned inputs, and adds the cloned inputs to the form
*
Expand Down

0 comments on commit 9cf20d3

Please sign in to comment.