Plugin Directory

Changeset 1355030


Ignore:
Timestamp:
02/21/2016 03:25:40 AM (10 years ago)
Author:
DSpenceIA
Message:

Added support for the Spanish language. Simple Contact Form (Basic) can now be installed on your WordPress page/blog in either English or Spanish by using the "scfb_lan" variable in the [simplecf] shortcode!

Location:
simple-contact-form-basic/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • simple-contact-form-basic/trunk/readme.txt

    r1354595 r1355030  
    77Requires at least: 4.3
    88Tested up to: 4.4
    9 Stable tag: 1.3.1
     9Stable tag: 1.4
    1010
    1111Give website visitors an easy way to contact you, directly through your website, with a simple contact form.
     
    1919Simple Contact Form (Basic) collects four pieces of information about the visitor: Name, Email, Phone Number, and the Message. The Name, Email, and Message are required for the form to be submitted and processed. As part of the processing, before the email is actually sent, data validation ensures that the required fields are provided, and that a valid email address has been given. This ensures you are able to respond to visitor requests, if needed.
    2020
     21Availabe in English and Spanish! (Disponible en las idiomas de Inglés y Español!)
     22
    2123
    2224== Installation ==
     
    26283. Add the [simplecf] shortcode to any of your WordPress Pages, Posts, or Text Widget areas.
    27294. Add the "scfb_to" variable to the [simplecf] shortcode to define an alternative delivery email. For example: [simplecf scfb_to=jdoe@ncroud.com] would install a form on your WordPress page/blog and all submissions for that particular form would be sent to jdoe@ncroud.com instead of the WordPress administrator email.
     305. Add the "scfb_lan" variable to the [simplecf] shortcode to define the language (es = Spanish; en = English). If nothing is specified, the form will default to English.  For example:  [simplecf scfb_lan=es] would install a form on your WordPress page/blog in the Spanish language.
    2831
    2932
     
    4245
    4346== Changelog ==
     47
     48= 1.4 =
     49
     50Release Date: February 20, 2016
     51
     52*Added support for the Spanish language. Simple Contact Form (Basic) can now be installed on your WordPress page/blog in either English or Spanish by using the "scfb_lan" variable in the [simplecf] shortcode.
    4453
    4554= 1.3.1 =
  • simple-contact-form-basic/trunk/simplecf-functions.php

    r1322116 r1355030  
    22/*
    33Simple Contact Form (Basic)
     4
    45Copyright (C) 2015 nCroud Company, LLC
    56
     
    1819*/
    1920
    20 // Displays the HTML form.
    21 function scfb_display_form() {
     21
     22// Display the HTML form.
     23function scfb_display_form($lan) {
     24    // define the form labels
     25    if($lan == 'es') {
     26      define('SCFB_NAME','Su Nombre');
     27      define('SCFB_MAIL','Su Correo Electrónico');
     28      define('SCFB_PHON','Su Teléfono');
     29      define('SCFB_NOTE','Su Mensaje');
     30      define('SCFB_SEND','Envía Mensaje');
     31      define('SCFB_MUST','necesario');
     32    }
     33    else {
     34      define('SCFB_NAME','Your Name');
     35      define('SCFB_MAIL','Your Email');
     36      define('SCFB_PHON','Your Phone');
     37      define('SCFB_NOTE','Your Message');
     38      define('SCFB_SEND','Send Message');
     39      define('SCFB_MUST','required');
     40    }
     41
    2242    echo '<form action="' . esc_url($_SERVER['REQUEST_URI']) . '" method="post">';
    2343    echo '<p>';
    24     echo 'Your Name (required) <br />';
     44    echo SCFB_NAME . ' (' . SCFB_MUST . ') <br />';
    2545    echo '<input type="text" name="simplecf-name" pattern="[a-zA-Z0-9 ]+" value="' . (isset($_POST["simplecf-name"]) ? stripslashes($_POST["simplecf-name"]) : '') . '" size="40" />';
    2646    echo '</p>';
    2747    echo '<p>';
    28     echo 'Your Email (required) <br />';
     48    echo SCFB_MAIL . ' (' . SCFB_MUST . ') <br />';
    2949    echo '<input type="email" name="simplecf-email" value="' . (isset($_POST["simplecf-email"]) ? stripslashes($_POST["simplecf-email"]) : '') . '" size="40" />';
    3050    echo '</p>';
    3151    echo '<p>';
    32     echo 'Phone Number <br />';
     52    echo SCFB_PHON . '<br />';
    3353    echo '<input type="phone" name="simplecf-phone" pattern="[0-9\-]+" value="' . (isset($_POST["simplecf-phone"]) ? stripslashes($_POST["simplecf-phone"]) : '') . '" size="40" />';
    3454    echo '</p>';
    3555    echo '<p>';
    36     echo 'Your Message (required) <br />';
     56    echo SCFB_NOTE . ' (' . SCFB_MUST . ') <br />';
    3757    echo '<textarea rows="10" cols="35" name="simplecf-message">' . (isset($_POST["simplecf-message"]) ? stripslashes($_POST["simplecf-message"]) : '') . '</textarea>';
    3858    echo '</p>';
    39     echo '<p><input id="simplecf-submit" type="submit" name="simplecf-submit" value="Send Message" /></p>';
     59    echo '<p><input id="simplecf-submit" type="submit" name="simplecf-submit" value="' . SCFB_SEND . '" /></p>';
    4060    echo '</form>';
    4161}
    4262
    43 // Deliver message to the WordPress Admin email address.
    44 function scfb_deliver_mail($to) {
     63
     64// Check the submission and deliver the message.
     65function scfb_deliver_mail($to,$lan) {
    4566  // define the delivery email address
    4667  $scfb_to = $to;
    47  
     68
     69  // define the user messages
     70  if($lan == 'es') {
     71      define('SCFB_MISSING','Faltan datos requeridos. Int&eacute;ntelo de nuevo.');
     72      define('SCFB_INVALID','El correo electr&oacute;nico no es v&aacute;lido.');
     73      define('SCFB_SUCCESS','Gracias para su mensaje. Responderemos pronto.');
     74      define('SCFB_UNKNOWN','Error inesperado.');
     75  }
     76  else {
     77      define('SCFB_MISSING','One or more required fields are missing. Please try again.');
     78      define('SCFB_INVALID','The email address is not valid.');
     79      define('SCFB_SUCCESS','Thank you for taking the time to send a message. Expect a response soon.');
     80      define('SCFB_UNKNOWN','An unexpected error occurred.');
     81  }
     82
    4883  // if the submit button is clicked, send the email
    4984  if(isset($_POST['simplecf-submit'])) {
    5085    // check required fields are entered
    5186    if(empty($_POST['simplecf-name']) || empty($_POST['simplecf-email']) || empty($_POST['simplecf-message'])) {
    52       echo '<p class="failure">One or more required fields are missing. Please try again.</p>';
     87      echo '<p class="failure">' . SCFB_MISSING . '</p>';
    5388    }
    5489    else {
    55 
    5690      // sanitize form values
    5791      $scfb_name    = $_POST["simplecf-name"];
     
    6094      $scfb_subject = '[SimpleCF]: ' . get_bloginfo() . ' Contact Form';
    6195      $scfb_message = $_POST["simplecf-message"];
    62  
     96
    6397      // verify the email is valid and, if so, send the message
    6498      if(is_email($scfb_email)) {
    6599        $scfb_valid_email = $scfb_email;
    66                            
     100
    67101        // if the email is a valid format, verify the domain itself is valid
    68102        $scfb_domain = substr(strrchr($scfb_valid_email,'@'),1);
    69        
     103
    70104        if(checkdnsrr($scfb_domain,'MX')) {
    71105          $scfb_headers = "From: $scfb_name <$scfb_valid_email>" . "\r\n";
    72        
     106
    73107          // If email has been processed for sending, display a success message
    74108          if(wp_mail($scfb_to,$scfb_subject,stripslashes($scfb_message),$scfb_headers)) {
    75             echo '<p class="success">Thank you for taking the time to send a message. Expect a response soon.</p>';
    76            
     109            echo '<p class="success">' . SCFB_SUCCESS . '</p>';
     110
    77111            // unset the form field variables
    78112            unset($_POST['simplecf-name']);
     
    82116          }
    83117          else {
    84             echo '<p class="failure">An unexpected error occurred.</p>';
     118            echo '<p class="failure">' . SCFB_UNKNOWN . '</p>';
    85119          }
    86120        }
     
    88122          if(checkdnsrr($scfb_domain,'A')) {
    89123            $scfb_headers = "From: $scfb_name <$scfb_valid_email>" . "\r\n";
    90          
     124           
    91125            // If email has been processed for sending, display a success message
    92126            if(wp_mail($scfb_to,$scfb_subject,stripslashes($scfb_message),$scfb_headers)) {
    93               echo '<p class="success">Thank you for taking the time to send a message. Expect a response soon.</p>';
    94              
     127              echo '<p class="success">' . SCFB_SUCCESS . '</p>';
     128
    95129              // unset the form field variables
    96130              unset($_POST['simplecf-name']);
     
    100134            }
    101135            else {
    102               echo '<p class="failure">An unexpected error occurred.</p>';
     136              echo '<p class="failure">' . SCFB_UNKNOWN . '</p>';
    103137            }
    104138          }
    105139          else {
    106             echo '<p class="failure">The email address is not valid.</p>';
     140            echo '<p class="failure">' . SCFB_INVALID . '</p>';
    107141          }
    108142        }
    109143      }
    110144      else {
    111         echo '<p class="failure">The email address is not valid.</p>';
     145        echo '<p class="failure">' . SCFB_INVALID . '</p>';
    112146      }
    113147    }
     
    115149}
    116150
     151
    117152// The function that powers the WordPress shortcode.
    118153function scfb_shortcode($atts) {
    119154    ob_start();
    120    
    121     // if the email is not provided, use the administrator email
     155
    122156    $scfb_vars = shortcode_atts(array(
     157
     158      // if the email is not provided, use the administrator email
    123159      'scfb_to' => get_option('admin_email'),
     160      // if the language is not define, use english
     161      'scfb_lan' => 'en'
     162
    124163    ), $atts );
    125          
    126     scfb_deliver_mail($scfb_vars['scfb_to']);
    127     scfb_display_form();
     164
     165    scfb_deliver_mail($scfb_vars['scfb_to'],$scfb_vars['scfb_lan']);
     166    scfb_display_form($scfb_vars['scfb_lan']);
    128167
    129168    return ob_get_clean();
    130169}
     170
    131171
    132172// Register the default style sheet.
  • simple-contact-form-basic/trunk/simplecf-main.php

    r1354596 r1355030  
    44Plugin URI: https://wordpress.org/plugins/simple-contact-form-basic/
    55Description: A simple, yet powerful and effective contact form, that integrates easily into any WordPress site just by using a simple shortcode. Visitors can email you directly through your website, providing their name, email, phone, and message, so that you can respond quickly and easily.
    6 Version: 1.3.1
     6Version: 1.4
    77Author: nCroud
    88Author URI: http://www.ncroud.com/
     
    1212/*
    1313Simple Contact Form (Basic)
     14
    1415Copyright (C) 2015 nCroud Company, LLC
    1516
Note: See TracChangeset for help on using the changeset viewer.