ap_prefetch_recent_activities( array $ids, string $col = 'q_id' )
Description #
Prefetch activities of posts.
Parameters #
- $idsarray (Required) Array of post ids.
- $colstring (Optional) Column. Default value: 'q_id'
Source #
File: includes/activity.php
function ap_prefetch_recent_activities( $ids, $col = 'q_id' ) { global $wpdb; $ids_string = esc_sql( sanitize_comma_delimited( $ids ) ); $col = 'q_id' === $col ? 'q_id' : 'a_id'; if ( empty( $ids_string ) ) { return; } $q_where = ''; if ( 'q_id' === $col && is_question() ) { $q_where = " AND (activity_a_id = 0 OR activity_action IN('new_a', 'unselected','selected') )"; } $query = "SELECT t1.* FROM {$wpdb->ap_activity} t1 NATURAL JOIN (SELECT max(activity_date) AS activity_date FROM {$wpdb->ap_activity} WHERE activity_{$col} IN({$ids_string})$q_where GROUP BY activity_{$col}) t2 ORDER BY t2.activity_date"; $activity = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB foreach ( $activity as $a ) { $a = ap_activity_parse( $a ); } return $activity; }
Expand full source code Collapse full source code View on GitHub: includes/activity.php:238
Add your comment