Skip to content

Commit 4a554c1

Browse files
authored
add filter for frontend dependencies
This filter makes it much easier to extend WPLF client side. Basically it allows users to include custom scripts before WPLF. This is useful with Google reCAPTCHA, if you only want to include the reCAPTCHA api.js on pages that have forms on them. Sky is the limit.
1 parent 2e6dba8 commit 4a554c1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

classes/class-cpt-wplf-form.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,13 @@ 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( 'wplf-form-js', plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ), array(), WPLF_VERSION, true );
515+
wp_register_script(
516+
'wplf-form-js',
517+
plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ),
518+
apply_filters( 'wplf_frontend_script_dependencies', array() ),
519+
WPLF_VERSION,
520+
true
521+
);
516522

517523
if( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'libre-form') || $post->post_type === 'wplf-form') ) {
518524
wp_enqueue_script( 'wplf-form-js' );

0 commit comments

Comments
 (0)