Notifications::prefetch_comments()

Description #

Pre fetch comments and append data to object.

Source #

File: addons/notifications/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})" ); // phpcs:ignore WordPress.DB

		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