apply_filters( 'learndash_lesson_attributes', array $attributes, WP_Post $lesson )
Filters attributes of a lesson. Used to modify details about a lesson like label, icon and class name.
Description #
Parameters #
- $attributes
-
(array) Array of lesson attributes.
- $lesson
-
(WP_Post) The lesson post object.
Source #
Examples #
Note: Extended code example below not guaranteed, you may need to consult with a developer
<?php /** * Example usage for learndash_lesson_attributes filter. */ add_filter( 'learndash_lesson_attributes', function( $attributes, $lesson ) { // May add any custom logic using $attributes, $lesson. // Example 1: Customize the 'Sample Lesson' text. if ( ( isset( $lesson['sample'] ) ) && ( 'is_sample' === $lesson['sample'] ) ) { // This example assumes the first arrayt set is the "Sample Lesson". $attributes[0]['label'] = 'Free Preview'; } // Always return $attributes. return $attributes; }, 10, 2 );
Changelog #
Version | Description |
---|---|
3.0.0 | Introduced. |