@@ -13,6 +13,7 @@ Features:
1313- Option to send a copy of submitted forms via email
1414- Preview your forms
1515- Full file upload support with input type=file
16+ - Multilingual form support with Polylang
1617
1718## Screenshots
1819
@@ -67,7 +68,7 @@ Send a thank you email to the email in the submission
6768add_action( 'wplf_post_validate_submission', 'my_email_thankyou' );
6869function my_email_thankyou( $return ) {
6970 // do nothing if form validation failed
70- if( ! $return->ok ) {
71+ if ( ! $return->ok ) {
7172 return;
7273 }
7374
@@ -80,44 +81,6 @@ function my_email_thankyou( $return ) {
8081}
8182```
8283
83- ### Use shortcodes outside post content
84-
85- By default, scripts are only loaded when the shortcode is within the content.
86- If you use shortcodes outside the content, ex. custom fields or by ` do_shortcode ` , you need to manually enqueue the scripts for the submit to work.
87-
88- ``` php
89- wp_enqueue_script('wplf-form-js');
90- wp_localize_script( 'wplf-form-js', 'ajax_object', array(
91- 'ajax_url' => admin_url( 'admin-ajax.php' ),
92- 'ajax_credentials' => apply_filters('wplf_frontend_script_credentials', 'same-origin')
93- ) );
94- ```
95-
96- ### Client side callbacks
97-
98- WP Libre Form supports client side callbacks after form submission using window.wplf object. Example usage:
99-
100- ```
101- window.wplf.successCallbacks.push(function(response){
102- alert("You succesfully submitted form " + response.form_id);
103- });
104-
105- window.wplf.errorCallbacks.push(function(response){
106- alert("Form submission failed!");
107- });
108- ```
109-
110- These callbacks are executed in the order they appear.
111-
112- ### Add CSS classes to form output
113-
114- You can use the xclass attribute inside the shortcode to add your own extra classes.
115-
116- ```
117- [libre-form id="1" xclass="extra"]
118- ```
119-
120-
12184### Filter: wplf_validate_submission
12285
12386Used to add validation to your forms
@@ -189,7 +152,20 @@ function wplf_recaptcha( $return ) {
189152}
190153```
191154
192- ### Multilingual
155+ ## Javascript API
156+
157+ ### Client side callbacks
158+
159+ WP Libre Form supports client side callbacks after form submission using window.wplf object. Example usage:
160+
161+ ```
162+ window.wplf.successCallbacks.push(res => alert('Form submission success: ' + res.form_id));
163+ window.wplf.errorCallbacks.push(() => alert('Form submission failed!'));
164+ ```
165+
166+ These callbacks are executed in the order they appear.
167+
168+ ## Multilingual
193169
194170You can create multilingual forms using Polylang. WPLF will register and automatically fetch the translation when you use special template tags.
195171
@@ -205,3 +181,53 @@ add_filter( 'wplf_load_polylang' , function() {
205181 return false;
206182} );
207183```
184+
185+ ## Adding classes to the rendered form element
186+
187+ You can use the xclass attribute inside the shortcode to add your own extra classes for CSS.
188+
189+ ```
190+ [libre-form id="1" xclass="extra"]
191+ ```
192+
193+ ## Using the shortcode outside post content
194+
195+ By default, scripts are only loaded when the shortcode is within the content.
196+ If you use shortcodes outside the content, ex. custom fields or by ` do_shortcode ` , you need to manually enqueue the scripts for the submit to work.
197+
198+ ``` php
199+ wp_enqueue_script('wplf-form-js');
200+ wp_localize_script( 'wplf-form-js', 'ajax_object', array(
201+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
202+ 'ajax_credentials' => apply_filters('wplf_frontend_script_credentials', 'same-origin')
203+ ) );
204+ ```
205+
206+ ## Contributing
207+
208+ Please make sure your code conforms to the code style used in the rest of the plugin.
209+
210+ We use the standard WordPress code style, with a few major exceptions to make it nicer for modern GitHub projects:
211+
212+ * Indedation is 2 spaces, not tabs.
213+ * Yoda conditions aren't enforced
214+
215+ ### PHP Codesniffer
216+
217+ This project comes with a phpcs configuration (` phpcs.xml ` ) you can use to check your code like so:
218+
219+ Run phpcs in the project root directory:
220+
221+ ```
222+ phpcs --extensions=php --standard=./phpcs.xml -n -p .
223+ ```
224+
225+ Before you can run phpcs, you need to install PHP Codesniffer and WordPress coding standards like so:
226+
227+ ```
228+ composer create-project wp-coding-standards/wpcs:dev-master --no-dev $HOME/wpcs
229+ ```
230+
231+ Or read the official installation instructions here:
232+
233+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
0 commit comments