LLMS_Shortcode_Course_Element::get_output()

Retrieve the actual content of the shortcode


Description Description

$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


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/abstracts/abstract.llms.shortcode.course.element.php

	protected function get_output() {

		// Get a reference to the current page where the shortcode is displayed.
		global $post;
		$current_post = $post;

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

		// We don't have a post object to proceed with.
		if ( ! $course ) {
			return '';
		}

		if ( 'course' !== $course->post_type ) {
			// Get the parent.
			$parent = llms_get_post_parent_course( $course );

			// Post type doesn't have a parent so we can't display a syllabus.
			if ( ! $parent ) {
				return '';
			}

			// We have a course.
			$course = $parent->post;

		}

		ob_start();

		// Hack the global so our syllabus template works.
		if ( $course->ID != $current_post->ID ) {
			$post = $course;
		}

		$this->template_function();

		// Restore the global.
		if ( $course->ID != $current_post->ID ) {
			$post = $current_post;
		}

		return ob_get_clean();

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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