Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active May 17, 2025 13:29
Show Gist options
  • Save yuriinalivaiko/5199b87a3deac34aa069d49bb727343b to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/5199b87a3deac34aa069d49bb727343b to your computer and use it in GitHub Desktop.
Code snippets for the "User Locations" extension
<?php
/**
* Defer scripts of the "Ultimate Member - User Locations" extension.
*
* @link https://developer.wordpress.org/reference/classes/wp_scripts/add_data/
* @global WP_Scripts $wp_scripts
*/
function um_user_locations_alter_scripts() {
global $wp_scripts;
if ( wp_script_is( 'um-maps' ) ) {
$wp_scripts->add_data( 'um-maps', 'strategy', 'defer' );
}
if ( wp_script_is( 'um-map-shortcode' ) ) {
$wp_scripts->add_data( 'um-map-shortcode', 'strategy', 'defer' );
}
if ( wp_script_is( 'um-user-location-field' ) ) {
$wp_scripts->add_data( 'um-user-location-field', 'strategy', 'defer' );
}
}
add_action( 'wp_print_scripts', 'um_user_locations_alter_scripts', 7 );
add_action( 'wp_print_footer_scripts', 'um_user_locations_alter_scripts', 7 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment