uo_course_grid_resume_button
Filters the HTML for the resume course button, allowing customization before it displays on the course grid.
add_filter( 'uo_course_grid_resume_button', $callback, 10, 1 );
Description
Filters the HTML output of the "Resume Course" button displayed on the course grid. Developers can modify the button's HTML or conditionally remove it by returning an empty string or false. The current course object is also provided for context.
Usage
add_filter( 'uo_course_grid_resume_button', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to modify the resume button HTML for courses in the grid.
*
* This example checks if the course is marked as 'premium' and if so,
* appends a "Premium Access" label to the resume button.
*
* @param string $resume_button_html The original HTML for the resume button.
* @param object $course The current course object.
* @return string The modified HTML for the resume button.
*/
add_filter( 'uo_course_grid_resume_button', function( $resume_button_html, $course ) {
// Ensure we have a valid course object and the resume button HTML is not empty.
if ( ! is_a( $course, 'WP_Post' ) || empty( $resume_button_html ) ) {
return $resume_button_html;
}
// Let's assume you have a custom field or post meta to indicate a premium course.
// Replace 'is_premium_course' with your actual meta key.
$is_premium = get_post_meta( $course->ID, 'is_premium_course', true );
if ( 'yes' === $is_premium ) {
// Append a small badge or text to indicate premium access.
$resume_button_html .= '<span class="premium-label">Premium Access</span>';
}
return $resume_button_html;
}, 10, 2 );
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/templates/course-grid.php:249
array(
$resume_button_html,
$course,
),
'3.7.11',
'uo_course_grid_resume_button'
);
echo apply_filters( 'uo_course_grid_resume_button', $resume_button_html, $course );
}
}
}
?>
<?php do_action_deprecated( 'uo-course-grid-after-action-buttons', array( $course ), '3.7.11', 'uo_course_grid_after_action_buttons' ); ?>
<?php do_action( 'uo_course_grid_after_action_buttons', $course ); ?>
</div>