json_encode( $data ) ); wp_localize_script( 'learndash_template_script_js', 'sfwd_data', $data ); } } // This will be dequeued via the get_footer hook if the button was not used. if ( ! is_admin() ) { wp_enqueue_script( 'jquery-dropdown-js', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/jquery.dropdown.min.js', array( 'jquery' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['jquery-dropdown-js'] = __FUNCTION__; } } add_action( 'wp_enqueue_scripts', 'learndash_load_resources', apply_filters( 'learndash_load_resources_priority', '10' ) ); function learndash_unload_resources() { global $learndash_shortcode_used; global $learndash_assets_loaded; // If we are showing a known LD post type then leave it all. global $learndash_post_types; if ( ( is_singular( $learndash_post_types ) ) || ( false !== $learndash_shortcode_used ) ) { return; } if ( ( isset( $learndash_assets_loaded['scripts'] ) ) && ( !empty( $learndash_assets_loaded['scripts'] ) ) ) { foreach( $learndash_assets_loaded['scripts'] as $script_tag => $function_loaded ) { // We *should* check these scripts to ensure we dequeue only ones set to load in the footer. Oh well. wp_dequeue_script( $script_tag ); } } } add_action( 'wp_print_footer_scripts', 'learndash_unload_resources', 1 );