llms_get_post_content( string $content )

Post Template Include


Description Description

Adds LifterLMS template content before and after the post’s default content.


Top ↑

Parameters Parameters

$content

(string) (Required) WP_Post post_content.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/functions/llms-functions-content.php

	function llms_get_post_content( $content ) {

		global $post;
		if ( ! $post instanceof WP_Post ) {
			return $content;
		}

		$restrictions = llms_page_restricted( $post->ID );

		if ( in_array( $post->post_type, array( 'course', 'llms_membership', 'lesson', 'llms_quiz' ), true ) ) {

			$post_type       = str_replace( 'llms_', '', $post->post_type );
			$template_before = 'single-' . $post_type . '-before';
			$template_after  = 'single-' . $post_type . '-after';

			if ( $restrictions['is_restricted'] ) {
				$content = llms_get_post_sales_page_content( $post, $content );
				if ( in_array( $post->post_type, array( 'lesson', 'llms_quiz' ), true ) ) {
					$content         = '';
					$template_before = 'no-access-before';
					$template_after  = 'no-access-after';
				}
			}

			ob_start();
			load_template( llms_get_template_part_contents( 'content', $template_before ), false );
			$before = ob_get_clean();

			ob_start();
			load_template( llms_get_template_part_contents( 'content', $template_after ), false );
			$after = ob_get_clean();

			$content = do_shortcode( $before . $content . $after );

		}

		/**
		 * Filter the post_content of a LifterLMS post type.
		 *
		 * @since Unknown
		 *
		 * @param string  $content      Post content.
		 * @param WP_Post $post         Post object.
		 * @param array   $restrictions Result from `llms_page_restricted()` for the current post.
		 */
		return apply_filters( 'llms_get_post_content', $content, $post, $restrictions );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.17.0 Refactored.
3.25.2 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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