function load_custom_css_for_learndash( $hook = '' ) {
	// Get the current post type
	global $post;
	$current_post_type = get_post_type( $post );

	// Define the LearnDash post types, including certificates, exams, groups, assignments, and coupons
	$learndash_post_types = array( 'sfwd-courses', 'sfwd-lessons', 'sfwd-topic', 'sfwd-quiz', 'sfwd-question', 'sfwd-certificates', 'ld-exam', 'groups', 'sfwd-assignment' );

	// Check if the current post type is one of the LearnDash post types
	if ( in_array( $current_post_type, $learndash_post_types ) ) {
		// Enqueue the custom CSS file
		wp_register_style( 'custom-learndash-css', get_stylesheet_directory_uri() . '/ld-custom.css', array(), time() );
		wp_enqueue_style( 'custom-learndash-css' );
	}
}

// Load Custom CSS on LD shortcode pages
function load_custom_css_for_learndash_on_shortcodes( $atts = '', $shortcode_context = '' ) {
	wp_register_style( 'custom-learndash-css', get_stylesheet_directory_uri() . '/ld-custom.css', array(), time() );
	wp_enqueue_style( 'custom-learndash-css' );

	return $atts;
}

add_action( 'wp_enqueue_scripts', 'load_custom_css_for_learndash' );
add_filter( 'learndash_shortcode_atts', 'load_custom_css_for_learndash_on_shortcodes', 10, 2 );