Skip to content

Commit

Permalink
adds get_honeypot_input_names function to plugin where is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
erikyo committed Jan 31, 2023
1 parent 7c778c2 commit 5c7ca1c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/cf7a-antispam-flamingo.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function cf7a_flamingo_remove_honeypot( $result ) {
if ( isset( $options['check_honeypot'] ) && intval( $options['check_honeypot'] ) === 1 ) {

$submission = WPCF7_Submission::get_instance();
$honeypot_default_names = $options['honeypot_input_names'];
$honeypot_default_names = get_honeypot_input_names( $options['honeypot_input_names'] );

if ( ! $submission ) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion includes/cf7a-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function cf7a_honeypot_add( $form_elements ) {

/* A list of default names for the honeypot fields. */
$options = get_option( 'cf7a_options', array() );
$input_names = $options['honeypot_input_names'];
$input_names = get_honeypot_input_names( $options['honeypot_input_names'] );
$input_class = sanitize_html_class( $this->options['cf7a_customizations_class'] );
/**
* Controls the maximum number of honeypots.
Expand Down
31 changes: 31 additions & 0 deletions includes/cf7a-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,37 @@ function cf7a_add_cron_steps( $schedules ) {
}
add_filter( 'cron_schedules', 'cf7a_add_cron_steps' );

/**
* It adds a bunch of common honeypot input names to the list of honeypot input names
*
* @param array $custom_names The array of input names to check for.
*
* @return array An array of possible input names.
*/
function get_honeypot_input_names( $custom_names = array() ) {
$defaults = array(
'name',
'email',
'address',
'zip',
'town',
'phone',
'credit-card',
'ship-address',
'billing_company',
'billing_city',
'billing_country',
'email-address',
);

return array_unique(
array_merge(
$defaults,
(array) $custom_names
)
);
}

/**
* It encrypts a string using the WordPress salt as the key
*
Expand Down

0 comments on commit 5c7ca1c

Please sign in to comment.