Session::post_in_session( mixed $_post )

Description #

Check if post is in user’s session.

Parameters #

  • $_post
    mixed (Required) WordPress post object or ID.

Changelog #

VersionDescription
4.1.5Introduced.

Source #

File: includes/class/class-session.php

	public function post_in_session( $_post ) {
		$_post         = ap_get_post( $_post );
		$session_type  = 'answer' === $_post->post_type ? 'answers' : 'questions';
		$session_posts = anspress()->session->get( $session_type );

		if ( ! empty( $session_posts ) && ! is_user_logged_in() && '0' === $_post->post_author && in_array( (int) $_post->ID, $session_posts, true ) ) {
			return true;
		}

		return false;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment