ap_get_recent_activity( Wp_Post|integer|false $_post = false, null $deprecated = null )
Description #
Return recent activity of question or answer.
Parameters #
- $_postWp_Post | integer | false (Optional) WordPress post object or false for global post. Default value: false
- $deprecatednull (Optional) Deprecated. Default value: null
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;
}
Expand full source code Collapse full source code View on GitHub: includes/activity.php:146
Add your comment