Last active
May 17, 2025 13:29
-
-
Save yuriinalivaiko/5199b87a3deac34aa069d49bb727343b to your computer and use it in GitHub Desktop.
Code snippets for the "User Locations" extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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