ap_get_recent_activity( Wp_Post|integer|false $_post = false, null $deprecated = null )

Description #

Return recent activity of question or answer.

Parameters #

  • $_post
    Wp_Post | integer | false (Optional) WordPress post object or false for global post. Default value: false
  • $deprecated
    null (Optional) Deprecated. Default value: null

Changelog #

VersionDescription
4.1.8Deprecated argument $get_cached.
4.1.2Introduced.

Source #

File: includes/activity.php

function ap_get_recent_activity( $_post = false, $deprecated = null ) {
	if ( null !== $deprecated ) {
		_deprecated_argument( __FUNCTION__, '4.1.8' );
	}

	global $wpdb;
	$_post = ap_get_post( $_post );

	// Return if not anspress posts.
	if ( ! ap_is_cpt( $_post ) ) {
		return;
	}

	$type   = $_post->post_type;
	$column = 'answer' === $type ? 'a_id' : 'q_id';

	$q_where = '';

	if ( 'q_id' === $column && is_question() ) {
		$q_where = " AND (activity_a_id = 0 OR activity_action IN('new_a', 'unselected','selected') )";
	}

	$activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->ap_activity} WHERE activity_{$column} = %d$q_where ORDER BY activity_date DESC LIMIT 1", $_post->ID ) ); // phpcs:ignore WordPress.DB

	// Parse.
	if ( $activity ) {
		$activity = ap_activity_parse( $activity );
	}

	return $activity;
}

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