Plugin Directory

Changeset 2016363


Ignore:
Timestamp:
01/21/2019 03:56:57 PM (7 years ago)
Author:
DaoByDesign
Message:

Added do-not-store for when forms are stored in the DB (i.e. Flamingo). Improved wrapper ID masking and customization.

Location:
contact-form-7-honeypot/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • contact-form-7-honeypot/trunk/honeypot.php

    r1822267 r2016363  
    66Author: Nocean
    77Author URI: http://www.nocean.ca
    8 Version: 1.13
     8Version: 1.14
    99Text Domain: contact-form-7-honeypot
    1010Domain Path: /languages/
     
    8585    // Test if new 4.6+ functions exists
    8686    if (function_exists('wpcf7_add_form_tag')) {
    87         wpcf7_add_form_tag( 'honeypot', 'wpcf7_honeypot_formtag_handler', true );
     87        wpcf7_add_form_tag(
     88            'honeypot',
     89            'wpcf7_honeypot_formtag_handler',
     90            array(
     91                'name-attr' => true,
     92                'do-not-store' => true,
     93                'not-for-mail' => true
     94            )
     95        );
    8896    } else {
    8997        wpcf7_add_shortcode( 'honeypot', 'wpcf7_honeypot_formtag_handler', true );
     
    109117
    110118    $class = wpcf7_form_controls_class( 'text' );
    111     $unique_id = uniqid('hp');
    112119    $atts = array();
    113120    $atts['class'] = $tag->get_class_option( $class );
    114121    $atts['id'] = $tag->get_option( 'id', 'id', true );
     122   
     123    $atts['wrapper_id'] = $tag->get_option('wrapper-id');
     124    $wrapper_id = (!empty($atts['wrapper_id'])) ? reset($atts['wrapper_id']) : uniqid('wpcf7-');
     125
    115126    $atts['message'] = apply_filters('wpcf7_honeypot_accessibility_message', __('Please leave this field empty.','contact-form-7-honeypot'));
    116127    $atts['name'] = $tag->name;
     
    125136    $autocomplete_value = ($atts['validautocomplete']) ? 'off' : 'nope';
    126137
    127     // Check if we should move the CSS off the element and into the footer [todo: find a way to move to head]
    128     if (!empty($atts['move_inline_css'])) {
    129         $hp_css = '#'.$unique_id.' {'.$atts['css'].'}';
    130         wp_register_style( 'wpcf7-'.$unique_id.'-inline', false);
    131         wp_enqueue_style( 'wpcf7-'.$unique_id.'-inline' );
    132         wp_add_inline_style( 'wpcf7-'.$unique_id.'-inline', $hp_css );
     138    // Check if we should move the CSS off the element and into the footer
     139    if (!empty($atts['move_inline_css']) && $atts['move_inline_css'][0] === 'true') {
     140        $hp_css = '#'.$wrapper_id.' {'.$atts['css'].'}';
     141        wp_register_style( 'wpcf7-'.$wrapper_id.'-inline', false);
     142        wp_enqueue_style( 'wpcf7-'.$wrapper_id.'-inline' );
     143        wp_add_inline_style( 'wpcf7-'.$wrapper_id.'-inline', $hp_css );
    133144        $el_css = '';
    134145    } else {
     
    136147    }
    137148
    138     $html = '<span id="'.$unique_id.'" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" '.$el_css.'>';
     149    $html = '<span id="'.$wrapper_id.'" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" '.$el_css.'>';
    139150    if (!$atts['nomessage']) {
    140151        $html .= '<label ' . $inputid_for . ' class="hp-message">'.$atts['message'].'</label>';
     
    232243                    <tr>
    233244                        <th scope="row">
     245                            <label for="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>"><?php echo esc_html( __( 'Wrapper ID (optional)', 'contact-form-7-honeypot' ) ); ?></label>
     246                        </th>
     247                        <td>
     248                            <input type="text" name="wrapper-id" class="wrapper-id-value oneline option" id="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>" /><br>
     249                            <em><?php echo esc_html( __( 'By default the markup that wraps this form item has a random ID. You can customize it here. If you\'re unsure, leave blank.', 'contact-form-7-honeypot' ) ); ?></em>
     250                        </td>
     251                    </tr>
     252
     253                    <tr>
     254                        <th scope="row">
    234255                            <label for="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>"><?php echo esc_html( __( 'Use W3C Valid Autocomplete (optional)', 'contact-form-7-honeypot' ) ); ?></label>
    235256                        </th>
     
    256277                        <td>
    257278                            <input type="checkbox" name="nomessage:true" id="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>" class="messagekillvalue option" /><br />
    258                             <em><?php echo __('If checked, the accessibility label will not be generated. <strong>This is not recommended</strong>. If you\'re unsure, leave this unchecked.','contact-form-7-honeypot'); ?></em>
     279                            <em><?php echo __('If checked, the accessibility label will not be generated. This is not recommended, but may improve spam blocking. If you\'re unsure, leave this unchecked.','contact-form-7-honeypot'); ?></em>
    259280                        </td>
    260281                    </tr>
  • contact-form-7-honeypot/trunk/readme.txt

    r1999070 r2016363  
    33Requires at least: 3.5
    44Tested up to: 5.0
    5 Stable tag: 1.13
     5Stable tag: 1.14
    66Contributors: DaoByDesign
    77Donate link: http://www.nocean.ca/buy-us-a-coffee/
     
    6969
    7070== Changelog ==
     71= 1.14 =
     72Added do-not-store for when forms are stored in the DB (i.e. Flamingo). Improved wrapper ID masking and customization.
     73
    7174= 1.13 =
    7275Additional functionality to improve spam-stopping power.
Note: See TracChangeset for help on using the changeset viewer.