Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

FmiKL/wp-contact-form

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordPress Contact Form

An OOP contact form builder for WordPress with Ajax handling.

Features

  • Text, email, tel, url, number, color, checkbox, textarea, select fields
  • Grouped fields with custom HTML wrappers
  • Automatic mail headers from email, name and subject fields
  • Ajax submission with validation and error display
  • Nonce + honeypot spam protection
  • Test mode on localhost

Setup

require_once 'path/to/wp-contact-form/autoload.php';

Usage

function setup_form_contact() {
    $form = new Contact_Manager( 'form-contact', get_option( 'admin_email' ) );

    $form->group_fields(
        '<div class="form-row">%fields</div>',
        $form->add_field( 'text', 'name', 'Name', array(
            'wrapper'     => '<div class="form-group">%field</div>',
            'input_class' => 'form-control',
            'required'    => true,
        ) ),
        $form->add_field( 'email', 'email', 'Email', array(
            'wrapper'     => '<div class="form-group">%field</div>',
            'input_class' => 'form-control',
            'required'    => true,
        ) ),
    );

    $form->add_field( 'textarea', 'message', 'Message', array(
        'wrapper'     => '<div class="form-group">%field</div>',
        'input_class' => 'form-control',
    ) );

    $form->add_button( 'Send', array( 'class' => 'btn btn-primary' ) );

    $form->create_form();
    $form->handle_request();
}
add_action( 'init', 'setup_form_contact' );

License

GPL v2

About

An OOP contact form builder for WordPress with Ajax handling.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.