AnsPress_Notification_Query::prefetch_comments()

Description #

Pre fetch comments and append data to object.

Source #

File: addons/free/notification/query.php

	public function prefetch_comments() {
		global $wpdb;

		if ( empty( $this->ids['comment'] ) ) {
			return;
		}

		$ids = esc_sql( sanitize_comma_delimited( $this->ids['comment'] ) );
		$comments = $wpdb->get_results( "SELECT c.*, p.post_type, p.post_title FROM {$wpdb->comments} c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE comment_ID in ({$ids})" );

		foreach ( (array) $comments as $_comment ) {
			$this->append_ref_data( 'comment', $_comment->comment_ID, $_comment );
		}
	}

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