The functions.php of each child theme in WordPress can be used to customize themes and plugins using filters and hooks. On the one hand, we list all filters and hooks here and give examples of how to use them. The lists and examples are constantly being expanded.
Single course page
The following filters and hooks are available on the single course page:
cbs_before_single_course
: Parameter$course_id
cbs_after_single_course
: Parameter$course_id
cbs_before_single_course_intro
: Parameter$course_id
cbs_after_single_course_intro
: Parameter$course_id
cbs_single_course_before_availability
: Parameter$course_id
,$date
cbs_single_course_after_availability
: Parameter$course_id
,$date
cbs_single_course_before_booking_options
: Parameter$course_id
,$date
cbs_single_course_after_booking_options
: Parameter$course_id
,$date
Examples
Archive course day
The following filters and hooks are available to you on the archive course day:
cbs_before_archive_course
: Parameter$day
,$date
cbs_after_archive_course
: Parameter$day
,$date
Shortcode timetable
The following filters and hooks are available to you in the shortcode for the timetable [timetable]
and the Gutenberg block:
cbs_before_archive_course
: Parameter$day
,$date
cbs_after_archive_course
: Parameter$day
,$date
Global functions
You can use the following functions in your own PHP code:
cbs_get_courses( $args = array() )
cbs_get_courses
is the easiest way to get courses and their attributes. You can pass some optional parameters to the request using the $args
array:
id
: Course IDpost_id
: Post IDcategory
: Category of the postday
: Day of the week of the course in formatdate( 'N' )
(ISO 8601 numeric representation of the day of the week)date
: Date of the coursestart
: Course start timeend
: Course end timeuser_id
: Trainer of the course
Here are some code examples:
$courses = cbs_get_courses( array( 'id' => $course_id ) );
$courses = cbs_get_courses( array( 'post_id' => $post_id ) );
$courses = cbs_get_courses( array( 'day' => $day, 'date' => $date ) );
The return value is a PHP object with the same parameters that can be used for the array $args
. An example output might look like this:
foreach ( $courses as $course ) :
$course_day = $course->day; // e.g. 1 for Monday
endforeach;
cbs_get_weekday( $course_day )
cbs_get_weekday
returns the day of the week in the language set in WordPress as a string. The parameter $course_day
corresponds to the value from the database in ISO 8601 date( 'N' )
format.
cbs_get_weekday_permalink( $course_day )
cbs_get_weekday_permalink
returns the weekday url. The parameter $course_day
corresponds to the value from the database in ISO 8601 date( 'N' )
format.
cbs_get_weekday_permalink( $course_day )
cbs_get_weekday_permalink
returns the weekday url. The parameter $course_day
corresponds to the value from the database in ISO 8601 date( 'N' )
format.
Git repository
All filters and hooks are also managed by us in a Git repository and updated regularly. You can easily clone a file from here or use it for your project.