apply_filters( 'learndash_content_tabs', array $tabs, string $context, int $course_id, int $user_id )
Filters LearnDash content Tabs.
Description #
Parameters #
- $tabs
-
(array) An array of tabs array data. The tabs array data can contain keys for id, icon, label, content.
- $context
-
(string) The context where the tabs are shown like course, lesson, topic, quiz, etc.
- $course_id
-
(int) Course ID.
- $user_id
-
(int) User ID.
Source #
Examples #
Note: Extended code example below not guaranteed, you may need to consult with a developer
<?php /** * Example usage for learndash_content_tabs filter. */ add_filter( 'learndash_content_tabs', function( $tabs = array(), $context = '', $course_id = 0, $user_id = 0 ) { // Add optional logic to show the custom tab only on certain courses. // If ( 123 === $course_id ) { // Add tab content here. // } // Add our Custom Downloads Tab. if ( ! isset( $tabs['downloads'] ) ) { $tabs['downloads'] = array( 'id' => 'downloads', // The value here is to a CSS class you control to show an icon. 'icon' => 'ld-downloads-icon', 'label' => 'Downloads', 'content' => '<p>Here is a list of files for the Course:</p> <ul> <li><a href="">File One</a></li> <li><a href="">File Two</a></li> <li><a href="">File Three</a></li> </ul>', ); } // Always return $tabs. return $tabs; }, 30, 4 );
Changelog #
Version | Description |
---|---|
3.0.0 | Introduced. |