Skip to content

Commit c8c0086

Browse files
authored
Merge pull request #56 from k1sul1/master
Allow user to define credential mode
2 parents 4b37971 + d60cc81 commit c8c0086

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

assets/scripts/wplf-form.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/class-cpt-wplf-form.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,17 +512,20 @@ function maybe_enqueue_frontend_script() {
512512
global $post;
513513

514514
// register the script, but only enqueue it if the current post contains a form in it
515-
wp_register_script(
516-
'wplf-form-js',
517-
plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ),
515+
wp_register_script(
516+
'wplf-form-js',
517+
plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ),
518518
apply_filters( 'wplf_frontend_script_dependencies', array() ),
519-
WPLF_VERSION,
519+
WPLF_VERSION,
520520
true
521521
);
522522

523523
if( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'libre-form') || $post->post_type === 'wplf-form') ) {
524524
wp_enqueue_script( 'wplf-form-js' );
525-
wp_localize_script( 'wplf-form-js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
525+
wp_localize_script( 'wplf-form-js', 'ajax_object', array(
526+
'ajax_url' => admin_url( 'admin-ajax.php' ),
527+
'ajax_credentials' => apply_filters('wplf_ajax_fetch_credentials_mode', 'same-origin')
528+
) );
526529
}
527530
}
528531

readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ If you use shortcodes outside the content, ex. custom fields or by `do_shortcode
8787

8888
```php
8989
wp_enqueue_script('wplf-form-js');
90-
wp_localize_script( 'wplf-form-js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
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+
) );
9194
```
9295

9396
### Client side callbacks

0 commit comments

Comments
 (0)