llms_get_post( obj|int $post, mixed $error = false )

Retrieve the LLMS Post Model for a give post by ID or WP_Post Object


Description Description


Parameters Parameters

$post

(obj|int) (Required) instance of WP_Post or a WP Post ID

$error

(mixed) (Optional) determine what to return if the LLMS class isn't found post = WP_Post falsy = false

Default value: false


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/llms.functions.core.php

function llms_get_post( $post, $error = false ) {

	$post = get_post( $post );
	if ( ! $post ) {
		return $post;
	}

	$post_type = explode( '_', str_replace( 'llms_', '', $post->post_type ) );
	$class = 'LLMS';
	foreach ( $post_type as $part ) {
		$class .= '_' . ucfirst( $part );
	}

	if ( class_exists( $class ) ) {
		return new $class( $post );
	} elseif ( 'post' === $error ) {
		return $post;
	}

	return false;

}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: