Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Abstract_Repository_Posts::get_model( int|WP_Post $id )


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Parameters Parameters

$id

(Required)


Top ↑

Return Return

(WP_Post|PUM_Abstract_Model_Post)


Top ↑

Source Source

File: classes/Abstract/Repository/Posts.php

	protected function get_model( $id ) {
		$post = is_a( $id, 'WP_Post' ) ? $id : get_post( $id );

		/**
		 * Only convert to models if the model set is valid and not the WP_Post default.
		 */
		$model = $this->model;
		if ( ! $model || 'WP_Post' === $model || ! class_exists( $model ) || is_a( $post, $model ) ) {
			return $post;
		}

		if ( ! $this->cached_model_exists( $post ) ) {
			$object = new $model( $post );

			$this->cache['objects'][ $post->ID ] = array(
				'object' => $object,
				'hash' => $this->get_post_hash( $post )
			);
		}

		return $this->cache['objects'][ $post->ID ]['object'];
	}


Top ↑

User Contributed Notes User Contributed Notes

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