WordPress.org

Plugin Directory

Changeset 781430


Ignore:
Timestamp:
10/02/13 19:26:43 (7 months ago)
Author:
joedolson
Message:

dev commit.

Location:
botsmasher/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • botsmasher/trunk/botsmasher.php

    r760869 r781430  
    160160            $options = array_merge( $opts, array( 'bs_api_key'=> $bs_api_key, 'bs_required_label'=>$bs_required_label, 'bs_html_email'=>$bs_html_email, 'bs_filter_comments'=>$bs_filter_comments, 'bs_filter_registrations'=>$bs_filter_registrations ) ); 
    161161            update_option( 'bs_options', $options ); 
    162              
    163162            $message = __("BotSmasher Settings Updated",'botsmasher'); 
    164163            return "<div class='updated'><p>".$message."</p></div>"; 
     
    253252                </div>           
    254253            </div> 
     254             
     255            <div class="postbox" id="bs-shortcode"> 
     256            <h3><?php _e('BotSmasher Shortcode','botsmasher'); ?></h3> 
     257                <div class="inside"> 
     258                <h4><?php _e('Simple Usage', 'botsmasher' ); ?></h4> 
     259                <p><code>[botsmasher]</code></p> 
     260                <p><?php _e( 'The basic BotSmasher shortcode produces a simple contact form with name, email, telephone, subject, and message. The name, email, and message fields are required. Messages will be sent to the administrator email set in WordPress general settings.', 'botsmasher' ); ?></p> 
     261                <h4><?php _e('Shortcode Attributes (defaults shown)', 'botsmasher' ); ?></h4> 
     262                <p><textarea disabled cols="50" rows="4" style="padding: 10px;border: none; background: transparent; width: 100%; font-family: monospace;">[botsmasher recipient="$admin_email" recipientname="$blogname" submit="Send Now" fields="name,email,phone,subject,message" labels="Name, Email, Telephone, Subject, Message" required="message" thanks="Thank you for contacting $blogname. We'll get back to you as soon as possible!" subject="Submission from Contact Form by {name}"]</textarea></p> 
     263                <p><?php _e( 'None of these attributes are required, but if you use them, there are particular things you will need to know:', 'botsmasher' ); ?></p> 
     264                <p><code>recipient</code>: <?php _e('Email or comma-separated string of emails to send messages to.', 'botsmasher' ); ?></p> 
     265                <p><code>recipientname</code>: <?php _e('Name of recipient. (Shown as email "from" name.)', 'botsmasher' ); ?></p> 
     266                <p><code>submit</code>: <?php _e('Text of submit button.', 'botsmasher' ); ?></p> 
     267                <p><code>fields</code>: <?php _e('Fields to include. Whatever you want, but "name" and "email" are always included, whether in this list or not. Include them in the list if you wish to customize their labels. Some keywords will trigger particular input types: e.g., "number", "phone" or "tel", "date", etc. "Message", "Notes", "Textarea" or "Description" will trigger textarea elements.', 'botsmasher' ); ?><strong><?php _e( "Fields listed must be unique.", 'botsmasher' ); ?></strong></p> 
     268                <p><code>labels</code>: <?php _e('Text labels for the above fields. Must be one label for every field listed.', 'botsmasher' ); ?></p> 
     269                <p><code>required</code>: <?php _e('Comma-separated list of required fields. Name and email need not be included, they are always required.', 'botsmasher' ); ?></p> 
     270                <p><code>thanks</code>: <?php _e('Thank you message displayed after form submission.', 'botsmasher' ); ?></p> 
     271                <p><code>subject</code>: <?php _e('Subject line of sent message. Note that the default value includes a template tag "{name}" - this will be replaced by the value submitted in the "name" field. Any included field is available as a template tag using the name of the field wrapped in curly braces.', 'botsmasher' ); ?></p> 
     272                <h4><?php _e( 'Customizing the Email message sent', 'botsmasher' ); ?></h4> 
     273                <p><?php _e( 'The <code>[botsmasher]</code> shortcode is a containing shortcode. Whatever you wrap inside the shortcode container will be used as the template for your email message sent. Alternately, you can use the <code>bs_customize_template</code> filter to generate a custom template.', 'botsmasher' ); ?></p> 
     274<textarea disabled cols="50" rows="9" style="padding: 10px;border: none; background: transparent; font-family: monospace; "> 
     275[botsmasher] 
     276Contact from my website:  
     277 
     278Subject: {subject} 
     279From : {name} ({email})  
     280 
     281{message} 
     282[/botsmasher] 
     283</textarea> 
     284                </div> 
     285            </div>           
     286             
    255287            <div class="postbox" id="get-support"> 
    256288            <h3><?php _e('Get Plug-in Support','botsmasher'); ?></h3> 
  • botsmasher/trunk/bs-contacts.php

    r760869 r781430  
    99            'submit'=> 'Send Now', 
    1010            // Name and Email are always present and required. Only reason to add them is to customize their labels. 
    11             'fields'=> 'name,email,phone,street,street2,city,state,zip,country,date,number,message,custom1', 
    12             'labels'=> 'Name, Email, Telephone, Street, Street(2), City, State, Postal Code, Country, Date, Number, Message,Crazy Field', 
     11            'fields'=> 'name,email,phone,subject,message', 
     12            'labels'=> 'Name,Email,Telephone,Subject,Message', 
    1313            'required'=> 'message', 
    1414            'thanks'=> 'Thank you for contacting '.get_option('blogname').'. We\'ll get back to you as soon as possible!', 
    1515            'subject'=>'Submission from Contact Form by {name}' 
    16         ), $atts) ); 
    17         $template = $content;  
     16        ), $atts, 'botsmasher' ) ); 
     17        $template = apply_filters( 'bs_customize_template', $content, $atts );  
    1818    return bs_contact_form( $recipient, $submit, $fields, $labels, $required, $subject, $thanks, $template, $recipientname ); 
    1919} 
     
    3838    $required = array_map( 'trim', explode( ',', $required ) ); 
    3939    if ( count( $fields ) != count( $labels ) ) { 
    40         return __('Field count and label count does not match. You must have a label specified for all fields.','botsmasher'); 
     40        return __('Field count and label count does not match. You must have a label specified for all defined fields.','botsmasher'); 
    4141    } 
    4242    $labels = array_combine( $fields, $labels ); 
     
    4949        $post = $return['post']; 
    5050        $status = $post['status']; 
    51         if ( trim($status) == 'errors' ) { 
    52             $errors = $post['errors']; 
    53         } else { 
    54             $errors = array(); 
    55         } 
    56     } 
    57      
     51        $errors = ( trim($status) == 'errors' ) ? $post['errors'] : array() ; 
     52    } 
     53    // special case fields 
    5854    if ( in_array( 'name', array_keys( $errors ) ) ) { 
    5955        $error_name = apply_filters( 'bs_filter_name_error', "<div class='bs-error' id='bs_name_error'>".sprintf( __('%s is a required field.', 'botsmasher' ), $labels['name'] )."</div>" ); 
     
    8076                wp_nonce_field('bs_contact_form','bs_contact_form_nonce',false,false)."</div> 
    8177                <p>$error_name 
    82                     <label for='bs_name'>$labels[name] $lr</label> <input$aria_name aria-required='true' required type='text' name='bs_name' id='bs_name' value='$post[name]' placeholder='Your name' /> 
     78                    <label for='bs_name'>$labels[name] $lr</label> <input$aria_name aria-required='true' required type='text' name='bs_name' id='bs_name' value='".trim($post['name'])."' placeholder='Your name' /> 
    8379                </p> 
    8480                <p>$error_email 
    85                     <label for='bs_email'>$labels[email] $lr</label> <input$aria_email aria-required='true' required type='text' name='bs_email' id='bs_email' value='$post[email]' placeholder=\"Email Address\" /> 
     81                    <label for='bs_email'>$labels[email] $lr</label> <input$aria_email aria-required='true' required type='text' name='bs_email' id='bs_email' value='".trim($post['email'])."' placeholder=\"Email Address\" /> 
    8682                </p>"; 
    8783                foreach ( $fields as $value ) { 
     
    138134    $type = bs_set_type( $field ); 
    139135    $options = get_option( 'bs_options' ); 
     136    $value = trim( $value ); 
    140137    $is_required = in_array( $field, $required ); 
    141138    if ( in_array( $field, array_keys( $errors ) ) ) { 
     
    164161// phone,street,street2,city,state,zip,country,date,number,message 
    165162    switch ($field) { 
    166         case "phone": 
    167163        case "street": 
    168164        case "street2": 
     
    171167        case "zip": 
    172168        case "country":$type = 'text';break; 
     169        case "phone":  
     170        case "tel" :  
     171        case "telephone" : $type = 'tel';break;      
    173172        case "date":$type = 'date';break; 
    174173        case "number":$type = 'number';break; 
    175         case "message":$type = 'textarea';break; 
     174        case "message": 
     175        case "notes" :  
     176        case "textarea" :  
     177        case "description" : $type = 'textarea';break; 
     178        case "datetime":$type = 'datetime';break; 
     179        case "email":$type = 'email'; break; 
     180        case "password": $type = 'password'; break; 
     181        case "month" : $type = 'month'; break; 
     182        case "url" : $type = 'url'; break; 
    176183        default:$type = 'text'; 
    177184    } 
     
    182189    // hash ensures that forms are unique (widget won't submit main, etc.) 
    183190    if ( isset( $pd['bs_contact_form'] ) ) { 
     191        $options = get_option( 'bs_options' ); 
    184192        $hash = md5( $recipient.$fields.$labels.$required.$subject.$thanks.$template ); 
    185193        $return = $default_template = ''; 
     
    191199            $post['email'] = sanitize_email( $pd['bs_email'] ); 
    192200            $post['name'] = stripslashes( sanitize_text_field( $pd['bs_name'] ) ); 
    193             $ip = $_SERVER['REMOTE_ADDR']; 
    194             $result = bs_checker( array( 'ip'=>$ip, 'email'=>$post['email'], 'name'=>$post['name'], 'action'=>'check' ) ); 
    195             do_action( 'bs_post_filter_contact', $pd, $recipient, $fields, $labels, $required, $subject, $thanks ); 
     201            if ( !$post['email'] || !$post['name'] ) { 
     202                if ( empty( $post['name'] ) ) { 
     203                    $is_error = true; 
     204                    $errors['name'] = array( 'label'=>$labels['name'], 'name'=>'name', 'post'=>'' ); 
     205                } 
     206                $default_template .= "\n{email}"; 
     207                if ( empty( $post['email'] ) ) { 
     208                    $is_error = true; 
     209                    $errors['email'] = array( 'label'=>$labels['email'], 'name'=>'email', 'post'=>'' ); 
     210                } 
     211            } else { 
     212                $ip = $_SERVER['REMOTE_ADDR']; 
     213                $result = bs_checker( array( 'ip'=>$ip, 'email'=>$post['email'], 'name'=>$post['name'], 'action'=>'check' ) ); 
     214                do_action( 'bs_post_filter_contact', $pd, $recipient, $fields, $labels, $required, $subject, $thanks ); 
     215            } 
     216            $default_template .= "{name}"; 
     217             
    196218            if ( $result ) { // this is spam! 
    197                 return array( 'message'=>__( 'BotSmasher thinks you\'re a spammer. Please contact us if you\'re a real person!', 'botsmasher' ) ); 
     219                return array( 'message'=>__( 'BotSmasher thinks you\'re a spammer. Please contact us if you\'re a real person!', 'botsmasher' ), 'post'=>$post ); 
    198220            } else { 
    199221                foreach ( $fields as $value ) { 
    200222                    switch ($value) { 
    201                         case 'name': 
    202                             $default_template .= "{name}"; 
    203                             if ( empty( $_POST['bs_name'] ) ) { 
    204                                 $errors['name'] = array( 'label'=>$labels[$value], 'name'=>'name', 'post'=>'' ); 
    205                             } 
    206                             break; 
    207                         case 'email': 
    208                             $default_template .= "\n{email}"; 
    209                             if ( empty( $_POST['bs_email'] ) ) { 
    210                                 $errors['email'] = array( 'label'=>$labels[$value], 'name'=>'email', 'post'=>'' ); 
    211                             }                        
    212                             break; 
    213223                        case 'number': 
    214                             $val = ( is_numeric( $_POST["bs_$value"] ) )?$_POST["bs_$value"]:false; 
     224                            $val = ( is_numeric( $pd["bs_$value"] ) )?$pd["bs_$value"]:false; 
    215225                            $val = apply_filters( "bs_sanitize_$value", $val, $labels[$value] ); 
    216226                            if ( $val ) { 
     
    220230                                if ( in_array( $value, $required ) ) { 
    221231                                    $is_error = true;  
    222                                     $errors[$value] = array( 'label'=>$labels[$value], 'name'=>$value, 'post'=>$_POST["bs_$value"] ); 
     232                                    $errors[$value] = array( 'label'=>$labels[$value], 'name'=>$value, 'post'=>$pd["bs_$value"] ); 
    223233                                } 
    224234                            } 
    225235                            break;                   
    226236                        default: 
    227                             $val = apply_filters( "bs_sanitize_$value", sanitize_text_field( $_POST["bs_$value"] ), $labels[$value] ); 
     237                            $val = apply_filters( "bs_sanitize_$value", sanitize_text_field( $pd["bs_$value"] ), $labels[$value] ); 
    228238                            if ( $val ) { 
    229239                                $post[$value] = $val; 
     
    232242                                if ( in_array( $value, $required ) ) { 
    233243                                    $is_error = true;  
    234                                     $errors[$value] = array( 'label'=>$labels[$value], 'name'=>$value, 'post'=>$_POST["bs_$value"] ); 
     244                                    $errors[$value] = array( 'label'=>$labels[$value], 'name'=>$value, 'post'=>$pd["bs_$value"] ); 
    235245                                } 
    236246                            } 
     
    243253                    $post['status'] = ' errors'; 
    244254                    $post['errors'] = $errors; 
     255                    $error_message = ''; 
     256                    foreach ( $errors as $error ) { 
     257                        $error_message .= "<li>".sprintf( __( 'The provided information for <strong>%1$s</strong> did not validate.', 'botsmasher' ), $error['label'] ). "</li>"; 
     258                    } 
     259                    $return = " 
     260                    <div class='bs-errors'> 
     261                        <ul> 
     262                        ".stripslashes( $error_message )." 
     263                        </ul> 
     264                    </div>"; 
     265                    return array( 'message'=>$return, 'post'=>$post ); 
    245266                } else { 
    246267                    $post['status'] = ' submitted'; 
     
    254275                $senderfrom = "From: \"$recipientname\" <$recipient>"; 
    255276                $recipientfrom = "From: \"$post[name]\" <$post[email]>"; 
    256                 if ( get_option( 'bs_html_email' ) == 'true' ) { 
     277                 
     278                if ( $options['bs_html_email'] == 'on' ) { 
    257279                    add_filter('wp_mail_content_type',create_function('', 'return "text/html";')); 
    258280                } 
    259281                wp_mail( $post['email'], $subject, $message, $senderfrom ); 
    260282                wp_mail( $recipient, $subject, $message, $recipientfrom ); 
    261                 if ( get_option( 'bs_html_email' ) == 'true' ) { 
     283                if ( $options['bs_html_email'] == 'on' ) { 
    262284                    remove_filter('wp_mail_content_type',create_function('', 'return "text/html";')); 
    263285                }            
    264                 $return = "<div class='bs-thanks'>".wpautop( stripslashes( $thanks ) )."</div>"; 
     286                $return = "<div class='bs-thanks'>".stripslashes( $thanks )."</div>"; 
    265287            } 
    266288        } 
     
    437459            <tr> 
    438460                <th scope='row'><label for='".$this->get_field_id( 'fields' )."$i'>Label</label>  
    439                     <input type='text' value='".esc_attr($field['label'])."' name='".$this->get_field_name( 'fields' )."[$i][label]' id='".$this->get_field_id( 'fields' )."$i' /></th> 
     461                    <input type='text' value='".esc_attr(trim($field['label']))."' name='".$this->get_field_name( 'fields' )."[$i][label]' id='".$this->get_field_id( 'fields' )."$i' /></th> 
    440462                <td><label for='".$this->get_field_id( 'fields' )."$i'>Required</label>  
    441463                    <input type='checkbox' value='1' $checked name='".$this->get_field_name( 'fields' )."[$i][required]' id='".$this->get_field_id( 'fields' )."$i' /></td> 
  • botsmasher/trunk/css/bs-form.css

    r755333 r781430  
    22.bs-form label span:before { content: '('; } 
    33.bs-form label span:after { content: ')'; } 
    4 .bs-form label { display: inline-block; min-width: 10em; text-align: right; }  
     4.bs-form label { display: block; float: left; min-width: 25%; text-align: right; margin-right: .4em;} 
     5.bs-form input[type=text], .bs-form input[type=email] { padding: 4px; width: 50% } 
     6.bs-form textarea { height: 120px; width: 70%; } 
    57.widget .bs-form label { text-align: left; } 
    6 .bs-notice { font-size: 1.1em; padding: 10px; border: 1px solid; border-radius: 5px;} 
    7 .bs-error { color: #000; background: #ffd; margin-bottom: 4px; padding: 2px 4px; border: 1px solid #900;} 
     8.bs-notice div { font-size: 1.1em; padding: .5em; border: .1em solid; border-radius: .5em; margin: 1em 0;  } 
     9div.bs-thanks { background: #ffd; border-color: #128; } 
     10div.bs-errors {  background: #fdd; color: #400; border-color: #a00;} 
     11.bs-form .bs-error { padding: .2em; margin-bottom: 4px; background: #ffb; border-top: 1px solid; border-bottom: 1px solid; color: #000; margin: 0 -1em .3em; } 
     12.bs-form .bs-error:before { content: "* "; } 
     13.bs-form form { border: 1px solid #ccc; padding: 1em; box-shadow: 0 0 2px #ccc; } 
     14div.bs-errors ul { margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; } 
  • botsmasher/trunk/readme.txt

    r760869 r781430  
    44Tags: botsmasher, spam, anti-spam, captcha, comments, registration, contact form 
    55Requires at least: 3.4.2 
    6 Tested up to: 3.6.0 
     6Tested up to: 3.6.1 
    77Stable tag: 1.0.4 
    88License: GPLv2 or later 
     
    2828= Contact Form = 
    2929 
    30 BotSmasher includes an integrated and accessible contact form with basic customization options. The contact form shortcode is documented on the settings page, but can also be configured via the widget tool.  
     30BotSmasher includes an integrated and accessible contact form with basic customization options. The contact form shortcode is documented on the settings page, but can also be configured via the widget tool. Customize styles by placing a stylesheet called 'bs-form.css' in your theme or child theme directory. 
    3131 
    3232= Translations = 
     
    5353 
    5454* Bug fix: Missing argument in bs_submit_form(); 
     55* Bug fix: Form could be submitted with blank name/email fields. 
     56* Bug fix: Return POST data on spam and blank name/email errors. 
     57* Bug fix: Form was still sent if required fields blank. 
     58* Bug fix: Form errors for 'name' and 'email' fields was not displayed. 
     59* Bug fix: Enabling HTML email did not work. 
     60* Minor style changes on front end forms. 
     61* Added documentation for contact form shortcode. 
    5562 
    5663= 1.0.4 = 
Note: See TracChangeset for help on using the changeset viewer.