Skip to content

Instantly share code, notes, and snippets.

@Steeru
Created May 9, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Steeru/b4de88c67f12b77ee8f8da09b53dade7 to your computer and use it in GitHub Desktop.
Save Steeru/b4de88c67f12b77ee8f8da09b53dade7 to your computer and use it in GitHub Desktop.
function wp_travel_additional_scripts_enqueue() {
if ( ! defined( 'WP_TRAVEL_POST_TYPE' ) ) {
return;
}
if ( is_singular( WP_TRAVEL_POST_TYPE ) || wp_travel_is_cart_page() || wp_travel_is_checkout_page() ) {
$map_data = get_wp_travel_map_data();
wp_dequeue_script( 'wp-travel-maps' );
wp_register_script( 'wp-travel-maps-child-th', get_stylesheet_directory_uri() . '/wp-travel-front-end-map.js', array( 'jquery', 'jquery-gmaps' ), '', 1 );
$wp_travel = array(
'lat' => $map_data['lat'],
'lng' => $map_data['lng'],
'loc' => $map_data['loc'],
);
$wp_travel = apply_filters( 'wp_travel_frontend_data', $wp_travel );
wp_localize_script( 'wp-travel-maps-child-th', 'wp_travel', $wp_travel );
// Enqueued script with localized data.
wp_enqueue_script( 'wp-travel-maps-child-th' );
}
}
add_action( 'wp_enqueue_scripts', 'wp_travel_additional_scripts_enqueue', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment