Download the PHP package anttiviljami/wp-libre-form without Composer
On this page you can find all versions of the php package anttiviljami/wp-libre-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download anttiviljami/wp-libre-form
More information about anttiviljami/wp-libre-form
Files in anttiviljami/wp-libre-form
Package wp-libre-form
Short Description Easy native HTML5 forms for WordPress
License GPLv3
Informations about the package wp-libre-form
WP Libre Form
Use standard HTML5 markup to create fully functional forms for WordPress
Features
- Uses only HTML5 syntax to build forms. No GUIs, shortcodes, no bullshit
- Works with any valid HTML form. Just copy any form from any website and it will work. It's magic!
- Submissions are saved as custom post type posts. Form values are saved as custom fields.
- Validates required fields tagged with the native HTML5
required
attribute. - It's hackable. Add your own functionality with hooks and APIs.
- Email notifications of received form submissions
- Full file upload support to Media Library with input type=file
- Multilingual support with Polylang
- Predefined static HTML forms via filter hooks
- Dynamic values, like %USER_EMAIL% for pre-populating form data
Why?
Modern HTML markup is already a great way to build forms. With Libre Form, there's no need to learn clunky form builders that are hard to customise.
Just use standard HTML inputs to build, or copy a form to your WordPress site that will just magically work. No need to touch PHP code if you don't want to.
Required field validation, email notifications, file uploads to WP gallery and lots more are included by default in the core of the plugin, but you can also add your own functionality with hooks and APIs provided by Libre Form.
Try it
TryoutWP has provided us with a live demo, which you can find here. It reflects the current release, not the master branch.
Screenshots
Editing a Form
Form displayed in the default Twentysixteen theme
Submissions view
Single submission view
Installation
The Composer Way (preferred)
Install the plugin via Composer
Activate the plugin
The Old Fashioned Way
This plugin is available on the official WordPress.org plugin directory.
You can also install the plugin by directly uploading the zip file as instructed below:
- Download the plugin
- Upload to the plugin to /wp-content/plugins/ via the WordPress plugin uploader or your preferred method
- Activate the plugin
Filter / Action API
Filter: wplf_validate_submission
Used to add validation to your forms.
Form specific hooks
This filter supports form specific hooks:
wplf_{form_id}_validate_submission
wplf_{form_slug}_validate_submission
These filters are only applied for the target form by ID or slug.
Example: Google ReCaptcha integration
Action: wplf_post_validate_submission
Triggers after the form validation is done.
Form specific hooks
This action supports form specific hooks:
wplf_{form_id}_post_validate_submission
wplf_{form_slug}_post_validate_submission
These actions are only run for the target form by ID or slug.
Example: Send a thank you email to the email in the submission
Filter: wplf_disable_validate_additional_fields
Dynamically generated fields are disabled by default. If you want to allow fields that are not set in the form to be submitted you can use this filter.
Form specific hooks
This filter supports form specific hooks:
wplf_{form_id}_disable_validate_additional_fields
wplf_{form_slug}_disable_validate_additional_fields
These filters are only applied for the target form by ID or slug.
Disabling additonal fields validation for all forms:
Filter: wplf_allowed_additional_form_fields
You can provide your own set of allowed field names, instead of disabling additional field validation entirely.
Form specific hooks
This filter supports form specific hooks:
wplf_{form_id}_allowed_additional_form_fields
wplf_{form_slug}_allowed_additional_form_fields
These filters are only applied for the target form by ID or slug.
Disabling additonal fields validation for all forms:
Filter: wplf_dynamic_values
Add or customize dynamic values available in forms.
Example: new value
Filter: wplf_uploaded_file_name
If you choose to not add uploaded files to the media library, you can change the file upload name.
Filter: wplf_uploaded_file_path
If you choose to not add uploaded files to the media library, you can change the file upload path.
Plugins
1.5 exposes a new function, wplf()
. It simply returns the class instance of WP Libre Form.
It allows you to register your plugin as a WP Libre Form plugin, which in turn allows you to expose an API and a settings page for your plugin, should you want to.
If you use spaces in the name, you can access the plugin instance like this:
wplf()->plugins->{"Your plugin"}->somePublicMethod()
Javascript API
Client side callbacks
WP Libre Form supports client side callbacks after form submission using window.wplf object. Example usage:
These callbacks are executed in the order they appear.
To avoid running your JavaScript too early, add wplf-form-js
to your enqueue dependencies:
Otherwise you might run into errors like "Cannot read property 'push' of undefined".
REST API driven sites
You can get forms out of the REST API. Just use /wp/v2/wplf-form
to retrieve forms. You can get a singular form by using filters:
/wp/v2/wplf-form?slug=form-slug
However, if you're sending forms from a different domain than WP site URL, you'll run across a CORS issue submitting the form, which you can get around with this:
Do note that the above code snippet opens your form submissions to the world.
You can also use the "official" JS bundle if you want to.
Multilingual
You can create multilingual forms using Polylang. WPLF will register and automatically fetch the translation when you use special template tags.
Example:
You can also disable this feature, and create your own middleware for WPML, if you'd like.
Adding extra classes to the form element
You can use the xclass attribute inside the shortcode to add your own extra classes for CSS.
Adding extra attributes to the form element
You can add any custom attributes to the form element easily by adding them to the shortcode
The attribute will render as is on the <form>
element
Importing forms from a predefined HTML template
Sometimes a project might require static forms which are not supposed to be editable in the admin panel.
This plugin allows you to define HTML forms in your project source code and import them into the form admin for specific forms.
Creating a static HTML template
The simplest way is to create a HTML5 file and read its contents. Other options include using Twig to render HTML templates.
Remember: WPLF will insert form
tags on its own, meaning you only have
to create the markup which sits directly inside the form
tags.
Importing a template into WPLF
Once you're done creating a form template, you need to inform
WPLF about it. You can use the wplf_import_html_template
filter hook for this:
The $template
variable should be a raw HTML string. If it is set to
null
no template will be imported.
After a template is imported for a certain form the form's editview will be set to read only mode, meaning you must make changes to the static HTML template in code instead of editing the form inside the admin panel.
Otherwise the form should function normally, meaning you can use WPLF features as always.