Skip to content

Commit 42b06dd

Browse files
authored
Merge pull request #61 from ideag/patch-1
move loading frontend scripts to the shortcode
2 parents b4c79a9 + 5c77189 commit 42b06dd

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

classes/class-cpt-wplf-form.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,13 @@ class="libre-form libre-form-<?php echo esc_attr( $id . ' ' . $xclass ); ?>"
541541
</form>
542542
<?php
543543
$output = ob_get_clean();
544+
545+
wp_enqueue_script( 'wplf-form-js' );
546+
wp_localize_script( 'wplf-form-js', 'ajax_object', array(
547+
'ajax_url' => admin_url( 'admin-ajax.php' ),
548+
'ajax_credentials' => apply_filters( 'wplf_ajax_fetch_credentials_mode', 'same-origin' ),
549+
) );
550+
544551
return $output;
545552
}
546553

@@ -563,16 +570,6 @@ function maybe_enqueue_frontend_script() {
563570
WPLF_VERSION,
564571
true
565572
);
566-
567-
if ( is_a( $post, 'WP_Post' ) ) {
568-
if ( has_shortcode( $post->post_content, 'libre-form' ) || $post->post_type === 'wplf-form' ) {
569-
wp_enqueue_script( 'wplf-form-js' );
570-
wp_localize_script( 'wplf-form-js', 'ajax_object', array(
571-
'ajax_url' => admin_url( 'admin-ajax.php' ),
572-
'ajax_credentials' => apply_filters( 'wplf_ajax_fetch_credentials_mode', 'same-origin' ),
573-
) );
574-
}
575-
}
576573
}
577574

578575

0 commit comments

Comments
 (0)