From a735fcf02f3361a4fc05d5427ef1174d7362f7b6 Mon Sep 17 00:00:00 2001 From: Bernhard Kau Date: Mon, 14 Oct 2024 18:59:15 +0200 Subject: [PATCH] Add filter to change honeypot styles This filter can be used to change the styles of the honeypot field. It can also use an empty value, and then load the styles from an external file, if a strict CSP is used for the site. --- antispam_bee.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/antispam_bee.php b/antispam_bee.php index 86ab8926..d29b9656 100755 --- a/antispam_bee.php +++ b/antispam_bee.php @@ -1305,11 +1305,25 @@ public static function replace_comment_field_callback( $matches ) { } } + /** + * Filter to change the inline styles of the honeypot field. + * + * This filter can also be used to use an empty value and load the styles from an external file, if a strict + * CSP is used for the site. + * + * @see: https://wordpress.org/support/topic/honeypot-textarea-visible-with-strict-csp-header/ + * + * @param string $honeypot_styles The inline styles for the honeypot. + * + * @return string The inline styles for the honeypot. + */ + $honeypot_styles = apply_filters( 'antispam_bee_honeypot_styles', 'padding:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;position:absolute !important;white-space:nowrap !important;height:1px !important;width:1px !important;overflow:hidden !important;' ); + $output .= ' name="' . esc_attr( self::get_secret_name_for_post( self::$_current_post_id ) ) . '" '; $output .= $matches['between1'] . $matches['between2'] . $matches['between3']; $output .= $matches['after'] . '>'; $output .= $matches['content']; - $output .= ''; + $output .= ''; $output .= $id_script; $output .= $init_time_field;