Skip to content

Commit

Permalink
Better enqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
corsacca committed Aug 17, 2023
1 parent 2b5585a commit b9594ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,21 +964,20 @@ public static function echo_form_html_scripts_and_styles( $dt_webform_token, $dt
* to load an entire site header. Therefore these files are to ignore standards.
*/
// @codingStandardsIgnoreStart
$test = wp_script_is( 'jquery', 'enqueued' );
if ( !wp_script_is( 'jquery', 'enqueued' ) ){
?>
<script type="text/javascript" src="<?php echo esc_url( $public_url ) ?>jquery.min.js?v=1"></script>
<script type="text/javascript" src="<?php echo esc_url( $public_url ) ?>jquery-migrate.min.js"></script>
<script type="text/javascript" src="<?php echo esc_url( $public_url ) ?>jquery.validate.min.js"></script>
<script type="text/javascript" src="<?php echo esc_url( $public_url ) ?>public.js?ver=<?php echo esc_html( filemtime( plugin_dir_path( __DIR__ ) . 'public/public.js' ) ) ?>"></script>
<?php
} else {
wp_enqueue_script( 'jquery-migrate');
wp_enqueue_script( 'jquery-validate' , $public_url . 'jquery.validate.min.js', array( 'jquery' ), '1.17.0', false );
wp_enqueue_script( 'dt-webform-public' , $public_url . 'public.js', array( 'jquery' ), filemtime( plugin_dir_path( __DIR__ ) . 'public/public.js' ), false );
}
?>

<script type="text/javascript"
src="<?php echo esc_url( $public_url ) ?>public.js?ver=<?php echo esc_html( filemtime( plugin_dir_path( __DIR__ ) . 'public/public.js' ) ) ?>"></script>
<?php if( get_option( 'dt_google_map_key' ) ) { ?>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?libraries=places&key=<?php echo esc_html( get_option( 'dt_google_map_key' ) ); ?>"
Expand Down
1 change: 1 addition & 0 deletions magic-link/magic-link-webform-app.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function dt_magic_url_base_allowed_css( $allowed_css ){

public function dt_magic_url_base_allowed_js( $allowed_js ){
$allowed_js[] = 'jquery-validate';
$allowed_js[] = 'dt-webform-public';
return $allowed_js;
}

Expand Down

0 comments on commit b9594ee

Please sign in to comment.