Plugin Directory

Changeset 2307785


Ignore:
Timestamp:
05/19/2020 08:53:27 AM (6 years ago)
Author:
silvermuru
Message:

Version 1.3.6 - supports multiple forms in one page/view

Location:
ws-contact-form
Files:
8 added
7 edited
5 copied

Legend:

Unmodified
Added
Removed
  • ws-contact-form/tags/1.3.6/readme.txt

    r2050592 r2307785  
    33Tags:  contact, contact form, contact form plugin, contact forms, contact us, email, feedback form, feedback forms, form, forms
    44Requires at least: 4.4
    5 Tested up to: 5.1
    6 Stable tag: 1.3.5
     5Tested up to: 5.4.1
     6Stable tag: 1.3.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    25252. Activate the plugin through the 'Plugins' screen in WordPress
    26263. Fill settings fields on Wordpress Admin Settings > WS Contact Form page
    27 4. Paste plugin shortcode to your post/page in Text view activated or in text widget
     274. Paste plugin shortcode to your post/page in Text view activated or into text widget
    2828
    2929== Frequently Asked Questions ==
     
    3838
    3939== Changelog ==
     40
     41= 1.3.6 =
     42
     43* Tested with Wordpress 5.4.1
     44* Updated version number
     45* Now possible to put to page/post multiple contact forms
    4046
    4147= 1.3.5 =
  • ws-contact-form/tags/1.3.6/ws-contact-form.php

    r2050592 r2307785  
    11<?php
    22/**
    3 * Plugin Name: WS Contact Form
    4 * Plugin URI: https://www.silvermuru.ee/en/wordpress/plugins/ws-contact-form/
    5 * Description: Simple contact form for Wordpress
    6 * Version: 1.3.5
    7 * Author: WebShark
    8 * Author URI: https://www.webshark.ee/
    9 * Text Domain: ws-contact-form
    10 **/
     3 * Plugin Name: WS Contact Form
     4 * Plugin URI: https://www.silvermuru.ee/en/wordpress/plugins/ws-contact-form/
     5 * Description: Simple contact form for Wordpress
     6 * Version: 1.3.6
     7 * Author: UusWeb.ee
     8 * Author URI: https://www.wordpressi-kodulehe-tegemine.ee/
     9 * Text Domain: ws-contact-form
     10 **/
    1111
    1212if ( !defined( 'ABSPATH' ) ) {
     
    1414}
    1515
    16 class WS_Contact_Form { 
    17     public function __construct(){
    18         add_action( 'plugins_loaded', array( $this, 'ws_contact_form_load_textdomain' ) );
     16class WS_Contact_Form {
     17    public function __construct(){
     18        add_action( 'plugins_loaded', array( $this, 'ws_contact_form_load_textdomain' ) );
    1919        add_action( 'wp_footer', array( $this, 'ws_contact_form_sript' ) );
    2020        add_action( 'wp_enqueue_scripts', array( $this, 'ws_contact_form_style' ) );
     
    2424        add_filter( 'widget_text', 'do_shortcode' );
    2525    }
    26    
     26
    2727    public function ws_contact_form_load_textdomain() {
    28         load_plugin_textdomain( 'ws-contact-form', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' ); 
    29     }
    30    
     28        load_plugin_textdomain( 'ws-contact-form', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
     29    }
     30
    3131    public function ws_contact_form_shortcode( $atts, $content = null ){
    3232        ob_start();
     
    3434            echo '<h3> ' . get_option('wscontact-form-title-option') . '</h3>';
    3535        }
     36
     37        $random_form_id = wp_rand(1, 1000);
    3638        ?>
    37         <form id="ws_contact_form" class="ws-form-group">
     39        <form id="ws_contact_form" class="ws-form-group" data-id="<?php echo $random_form_id; ?>">
    3840            <div class="ws-hidden ws-message-response ws-message-successful" id="ws_contact_success"><?php _e( 'Message is sent successfully!', 'ws-contact-form' ); ?></div>
    3941            <div class="ws-hidden ws-message-response ws-message-error" id="ws_contact_error"><?php _e( 'There is problem with form', 'ws-contact-form' ); ?></div>
     
    4648        return ob_get_clean();
    4749    }
    48    
     50
    4951    public function ws_contact_form_sript() {
    5052        wp_register_script( 'ws-contact-form-script', plugin_dir_url(__FILE__) . 'js/scripts.js', array( 'jquery' ), false );
    5153        wp_enqueue_script( 'ws-contact-form-script' );
    5254    }
    53    
     55
    5456    public function ws_contact_form_style() {
    55         wp_register_style( 'ws-contact-form-style', plugin_dir_url(__FILE__) . 'css/style.css', true );
     57        wp_register_style( 'ws-contact-form-style', plugin_dir_url(__FILE__) . 'css/style.css', true );
    5658        wp_enqueue_style( 'ws-contact-form-style' );
    57     }
     59    }
    5860
    5961    public function ws_contact_form_sendmail()
     
    6163        $ws_cf_sender_name = get_option('wscontact-form-sender-name-option');
    6264        $ws_cf_sender_email = get_option('wscontact-form-sender-email-option');
    63            
     65
    6466        $email = $_POST['ws_contact_email'];
    6567        $headers = "From: " . $ws_cf_sender_name . " <" . get_option('wscontact-form-sender-email-option') . "> \r\n Reply-To: " . $email;
    6668        $message = $_POST['ws_contact_comment'];
    6769        $name = $_POST['ws_contact_name'];
    68        
     70
    6971        function ws_email_valid($email) {
    7072            $email_pattern = "/^[a-z\d](\.?[a-z\d_\-]+)*@([a-z\d](\.?[a-z\d\-]+)*\.[a-z]{2,4})$/i";
     
    9193        die();
    9294    }
    93    
    94    
     95
     96
    9597}
    9698
     
    99101    $wpse_ws_contact_form_plugin_admin = new WS_Contact_Form_admin();
    100102}
    101    
     103
    102104$wpse_ws_contact_form_plugin = new WS_Contact_Form();
    103105?>
  • ws-contact-form/trunk/js/scripts.js

    r1418779 r2307785  
    11jQuery(function() {
    2     jQuery('#ws_send_form').click(function(){
    3         jQuery('.ws-message-response').slideUp();
     2    jQuery('.ws-form-group button').click(function(){
     3        var form = jQuery(this).parent('form').data('id');
    44
    5         var name = jQuery('#ws_contact_name').val();
    6         var email = jQuery('#ws_contact_email').val();
    7         var comment = jQuery('#ws_contact_comment').val();
    8        
    9         var hasError_name = true;
    10         if (name.length < 3) {
    11             jQuery('#ws_contact_name').addClass('ws-warning-input');
     5        jQuery(this).closest('form.ws-form-group').children('.ws-message-response').slideUp();
     6
     7        var name = jQuery('[data-id="' + form + '"]').children('input[name="ws_contact_name"]').val();
     8        var email = jQuery('[data-id="' + form + '"]').children('input[name="ws_contact_email"]').val();
     9        var comment = jQuery('[data-id="' + form + '"]').children('textarea[name="ws_contact_comment"]').val();
     10
     11        var hasError_name = true;
     12        if (name.length < 3) {
     13            jQuery('[data-id="' + form + '"]').children('input[name="ws_contact_name"]').addClass('ws-warning-input');
    1214            hasError_name = true;
    1315        }
    1416        else {
    15             jQuery('#ws_contact_name').removeClass('ws-warning-input');
     17            jQuery('[data-id="' + form + '"]').children('input[name="ws_contact_name"]').removeClass('ws-warning-input');
    1618            hasError_name = false;
    1719        }
    18        
    19         var hasError_email = true;
    20         if (!ws_validateEmail(email) || email.length < 3) {
    21             jQuery('#ws_contact_email').addClass('ws-warning-input');
     20
     21        var hasError_email = true;
     22        if (!ws_validateEmail(email) || email.length < 3) {
     23            jQuery('[data-id="' + form + '"]').children('input[name="ws_contact_email"]').addClass('ws-warning-input');
    2224            hasError_email = true;
    2325        }
    2426        else {
    25             jQuery('#ws_contact_email').removeClass('ws-warning-input');
     27            jQuery('[data-id="' + form + '"]').children('input[name="ws_contact_email"]').removeClass('ws-warning-input');
    2628            hasError_email = false;
    2729        }
    28        
    29         var hasError_comment = true;
     30
     31        var hasError_comment = true;
    3032        if (comment.length < 3) {
    31             jQuery('#ws_contact_comment').addClass('ws-warning-textarea');
     33            jQuery('[data-id="' + form + '"]').children('textarea[name="ws_contact_comment"]').addClass('ws-warning-textarea');
    3234            hasError_comment = true;
    3335        }
    3436        else {
    35             jQuery('#ws_contact_comment').removeClass('ws-warning-textarea');
     37            jQuery('[data-id="' + form + '"]').children('textarea[name="ws_contact_comment"]').removeClass('ws-warning-textarea');
    3638            hasError_comment = false;
    3739        }
     
    4143            jQuery.post('/wp-admin/admin-ajax.php',
    4244                {
    43                     action: 'contacthomepage', 
    44                     ws_contact_name: name, 
    45                     ws_contact_email: email, 
     45                    action: 'contacthomepage',
     46                    ws_contact_name: name,
     47                    ws_contact_email: email,
    4648                    ws_contact_comment: comment,
    47                     ws_ajax_send_form: 1, 
     49                    ws_ajax_send_form: 1,
    4850                    ws_chack: 'fg' + 'yu'
    4951                },
    5052                function(data){
    5153                    if(data == 'OK'){
    52                         jQuery('input, textarea').val('');
    53                         jQuery('#ws_contact_success').slideDown();
     54                        jQuery('[data-id="' + form + '"]').children('input, textarea').val('');
     55                        jQuery('[data-id="' + form + '"]').children('.ws-message-successful').slideDown();
    5456                    } else {
    55                         jQuery('#ws_contact_error').slideDown();
     57                        jQuery('[data-id="' + form + '"]').children('.ws-message-error').slideDown();
    5658                    }
    5759                }
     
    6062        else
    6163        {
    62             jQuery('#ws_contact_error').slideDown();
     64            jQuery('[data-id="' + form + '"]').children('.ws-message-error').slideDown();
    6365        }
    6466        return false;
     
    7072    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    7173    if ( !emailReg.test($email) ) {
    72             return false;
     74        return false;
    7375    } else {
    74             return true;
     76        return true;
    7577    }
    7678}
  • ws-contact-form/trunk/readme.txt

    r2050592 r2307785  
    33Tags:  contact, contact form, contact form plugin, contact forms, contact us, email, feedback form, feedback forms, form, forms
    44Requires at least: 4.4
    5 Tested up to: 5.1
    6 Stable tag: 1.3.5
     5Tested up to: 5.4.1
     6Stable tag: 1.3.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    25252. Activate the plugin through the 'Plugins' screen in WordPress
    26263. Fill settings fields on Wordpress Admin Settings > WS Contact Form page
    27 4. Paste plugin shortcode to your post/page in Text view activated or in text widget
     274. Paste plugin shortcode to your post/page in Text view activated or into text widget
    2828
    2929== Frequently Asked Questions ==
     
    3838
    3939== Changelog ==
     40
     41= 1.3.6 =
     42
     43* Tested with Wordpress 5.4.1
     44* Updated version number
     45* Now possible to put to page/post multiple contact forms
    4046
    4147= 1.3.5 =
  • ws-contact-form/trunk/ws-contact-form.php

    r2050592 r2307785  
    11<?php
    22/**
    3 * Plugin Name: WS Contact Form
    4 * Plugin URI: https://www.silvermuru.ee/en/wordpress/plugins/ws-contact-form/
    5 * Description: Simple contact form for Wordpress
    6 * Version: 1.3.5
    7 * Author: WebShark
    8 * Author URI: https://www.webshark.ee/
    9 * Text Domain: ws-contact-form
    10 **/
     3 * Plugin Name: WS Contact Form
     4 * Plugin URI: https://www.silvermuru.ee/en/wordpress/plugins/ws-contact-form/
     5 * Description: Simple contact form for Wordpress
     6 * Version: 1.3.6
     7 * Author: UusWeb.ee
     8 * Author URI: https://www.wordpressi-kodulehe-tegemine.ee/
     9 * Text Domain: ws-contact-form
     10 **/
    1111
    1212if ( !defined( 'ABSPATH' ) ) {
     
    1414}
    1515
    16 class WS_Contact_Form { 
    17     public function __construct(){
    18         add_action( 'plugins_loaded', array( $this, 'ws_contact_form_load_textdomain' ) );
     16class WS_Contact_Form {
     17    public function __construct(){
     18        add_action( 'plugins_loaded', array( $this, 'ws_contact_form_load_textdomain' ) );
    1919        add_action( 'wp_footer', array( $this, 'ws_contact_form_sript' ) );
    2020        add_action( 'wp_enqueue_scripts', array( $this, 'ws_contact_form_style' ) );
     
    2424        add_filter( 'widget_text', 'do_shortcode' );
    2525    }
    26    
     26
    2727    public function ws_contact_form_load_textdomain() {
    28         load_plugin_textdomain( 'ws-contact-form', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' ); 
    29     }
    30    
     28        load_plugin_textdomain( 'ws-contact-form', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
     29    }
     30
    3131    public function ws_contact_form_shortcode( $atts, $content = null ){
    3232        ob_start();
     
    3434            echo '<h3> ' . get_option('wscontact-form-title-option') . '</h3>';
    3535        }
     36
     37        $random_form_id = wp_rand(1, 1000);
    3638        ?>
    37         <form id="ws_contact_form" class="ws-form-group">
     39        <form id="ws_contact_form" class="ws-form-group" data-id="<?php echo $random_form_id; ?>">
    3840            <div class="ws-hidden ws-message-response ws-message-successful" id="ws_contact_success"><?php _e( 'Message is sent successfully!', 'ws-contact-form' ); ?></div>
    3941            <div class="ws-hidden ws-message-response ws-message-error" id="ws_contact_error"><?php _e( 'There is problem with form', 'ws-contact-form' ); ?></div>
     
    4648        return ob_get_clean();
    4749    }
    48    
     50
    4951    public function ws_contact_form_sript() {
    5052        wp_register_script( 'ws-contact-form-script', plugin_dir_url(__FILE__) . 'js/scripts.js', array( 'jquery' ), false );
    5153        wp_enqueue_script( 'ws-contact-form-script' );
    5254    }
    53    
     55
    5456    public function ws_contact_form_style() {
    55         wp_register_style( 'ws-contact-form-style', plugin_dir_url(__FILE__) . 'css/style.css', true );
     57        wp_register_style( 'ws-contact-form-style', plugin_dir_url(__FILE__) . 'css/style.css', true );
    5658        wp_enqueue_style( 'ws-contact-form-style' );
    57     }
     59    }
    5860
    5961    public function ws_contact_form_sendmail()
     
    6163        $ws_cf_sender_name = get_option('wscontact-form-sender-name-option');
    6264        $ws_cf_sender_email = get_option('wscontact-form-sender-email-option');
    63            
     65
    6466        $email = $_POST['ws_contact_email'];
    6567        $headers = "From: " . $ws_cf_sender_name . " <" . get_option('wscontact-form-sender-email-option') . "> \r\n Reply-To: " . $email;
    6668        $message = $_POST['ws_contact_comment'];
    6769        $name = $_POST['ws_contact_name'];
    68        
     70
    6971        function ws_email_valid($email) {
    7072            $email_pattern = "/^[a-z\d](\.?[a-z\d_\-]+)*@([a-z\d](\.?[a-z\d\-]+)*\.[a-z]{2,4})$/i";
     
    9193        die();
    9294    }
    93    
    94    
     95
     96
    9597}
    9698
     
    99101    $wpse_ws_contact_form_plugin_admin = new WS_Contact_Form_admin();
    100102}
    101    
     103
    102104$wpse_ws_contact_form_plugin = new WS_Contact_Form();
    103105?>
Note: See TracChangeset for help on using the changeset viewer.