Filter uncanny-learndash-toolkit

learndash_resume_css_classes

Filters the CSS classes applied to the resume button on LearnDash course pages before it's displayed.

add_filter( 'learndash_resume_css_classes', $callback, 10, 1 );

Description

Filters the CSS classes applied to the "Resume" button for LearnDash courses. Developers can modify or add classes to customize the button's appearance and behavior. This hook fires just before the resume button is rendered, allowing for dynamic class assignment.


Usage

add_filter( 'learndash_resume_css_classes', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Example: Add a custom class to the LearnDash resume button.
 *
 * This filter allows developers to modify the CSS classes applied to the
 * "Resume" button generated by LearnDash.
 *
 * @param string $css_classes The current CSS classes applied to the button.
 * @return string The modified CSS classes.
 */
add_filter( 'learndash_resume_css_classes', function( $css_classes ) {
	// Add a custom class for styling specific resume buttons.
	// For instance, you might want to distinguish resume buttons
	// for different types of content or user roles.
	$custom_class = 'my-custom-resume-button';

	// Append the custom class to the existing classes.
	// We'll ensure there's a space between classes if $css_classes is not empty.
	if ( ! empty( $css_classes ) ) {
		$css_classes .= ' ' . $custom_class;
	} else {
		$css_classes = $custom_class;
	}

	return $css_classes;
}, 10, 1 ); // Priority 10, accepts 1 argument

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/classes/learn-dash-resume.php:239
src/classes/learn-dash-resume.php:396

$resume_link_text = __( $link_text, 'uncanny-learndash-toolkit' );
						} else {
							$resume_link_text = __( 'Resume', 'uncanny-learndash-toolkit' );
						}

						$resume_link_text = apply_filters( 'learndash_resume_link_text', $resume_link_text );

						$css_classes = apply_filters( 'learndash_resume_css_classes', 'learndash-resume-button' );

						ob_start();

						if ( function_exists( 'learndash_get_step_permalink' ) ) {
							$permalink = learndash_get_step_permalink( $step_id, $step_course_id );
						} else {
							$permalink = get_permalink( $step_id );


Scroll to Top