uo_grid_view_style
Filters the URL for the course grid view CSS file, allowing customization of its location.
add_filter( 'uo_grid_view_style', $callback, 10, 1 );
Description
Filters the URL for the course grid view CSS file. Developers can modify this URL to point to a custom stylesheet or prevent the default CSS from loading by returning an empty string or false. This hook fires after checking for the presence of the `uo_courses` shortcode or the `uncanny-toolkit-pro/course-grid` block.
Usage
add_filter( 'uo_grid_view_style', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Filters the URL for the course grid view stylesheet.
*
* This function allows developers to modify the default stylesheet URL
* for the course grid view. For example, it could be used to load a
* custom stylesheet or conditionally load different stylesheets based
* on certain criteria.
*
* @param string $style_url The default URL for the course grid view stylesheet.
* @return string The modified URL for the course grid view stylesheet.
*/
add_filter( 'uo_grid_view_style', 'my_custom_course_grid_style_url', 10, 1 );
function my_custom_course_grid_style_url( $style_url ) {
// Example: Conditionally load a different stylesheet if on a specific page.
if ( is_page( 'courses' ) ) {
// Replace with the actual URL of your custom stylesheet.
return get_stylesheet_directory_uri() . '/css/my-custom-course-grid.css';
}
// You can also add inline styles or modify the existing URL.
// For instance, appending a version query parameter for cache busting.
// $style_url = add_query_arg( 'ver', '1.2.3', $style_url );
return $style_url;
}
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/show-all-courses.php:175
public static function uo_grid_view_style() {
global $post;
if ( empty( $post->ID ) ) {
return;
}
if ( ! has_shortcode( $post->post_content, 'uo_courses' ) && ! has_block( 'uncanny-toolkit-pro/course-grid', $post ) && ! self::has_reusable_block_shortcode( $post->post_content ) ) {
return;
}
wp_enqueue_style( 'course-grid-view-core', plugins_url( '/assets/legacy/frontend/css/course-grid-view-core.css', dirname( __FILE__ ) ), array(), UNCANNY_TOOLKIT_PRO_VERSION );
$grid_view_css = apply_filters( 'uo_grid_view_style', plugins_url( '/assets/legacy/frontend/css/course-grid-view.css', dirname( __FILE__ ) ) );
wp_enqueue_style( 'course-grid-view', $grid_view_css, array(), UNCANNY_TOOLKIT_PRO_VERSION );
// wp_enqueue_style( 'uo-menu-slug-css-fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css' );
}