learndash_lesson_attributes

apply_filters( 'learndash_lesson_attributes',  array $attributes,  object $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

(object) The lesson post object


Source #

File: themes/ld30/includes/helpers.php


Examples #

 <?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
);