LLMS_Shortcode_My_Achievements

LLMS_Shortcode_My_Achievements


Source Source

File: includes/shortcodes/class.llms.shortcode.my.achievements.php

class LLMS_Shortcode_My_Achievements extends LLMS_Shortcode {

	/**
	 * Shortcode tag
	 *
	 * @var string
	 */
	public $tag = 'lifterlms_my_achievements';

	/**
	 * Retrieves an array of default attributes which are automatically merged
	 * with the user submitted attributes and passed to $this->get_output()
	 *
	 * @since 3.14.1
	 * @return array
	 */
	protected function get_default_attributes() {
		return array(
			'count'   => null,
			'columns' => 5,
			'user_id' => get_current_user_id(),
		);
	}

	/**
	 * Retrieve the actual content of the shortcode
	 *
	 * $atts & $content are both filtered before being passed to get_output()
	 * output is filtered so the return of get_output() doesn't need its own filter
	 *
	 * @since 3.14.1
	 *
	 * @return string
	 */
	protected function get_output() {

		if ( ! $this->get_attribute( 'user_id' ) ) {
			return '';
		}

		$student = llms_get_student( $this->get_attribute( 'user_id' ) );
		if ( ! $student ) {
			return '';
		}

		$course = new LLMS_Course( $this->get_attribute( 'course_id' ) );

		ob_start();
		lifterlms_template_achievements_loop( $student, $this->get_attribute( 'count' ), $this->get_attribute( 'columns' ) );
		return ob_get_clean();

	}

}


Top ↑

Methods Methods

  • get_default_attributes — Retrieves an array of default attributes which are automatically merged with the user submitted attributes and passed to $this->get_output()
  • get_output — Retrieve the actual content of the shortcode

Top ↑

Changelog Changelog

Changelog
Version Description
3.14.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.