Notifications::prefetch_posts()

Description #

Pre fetch post contents and append to object.

Source #

File: addons/notifications/query.php

	public function prefetch_posts() {
		if ( empty( $this->ids['post'] ) ) {
			return;
		}

		global $wpdb;

		$ids_str = esc_sql( sanitize_comma_delimited( $this->ids['post'] ) );
		$posts   = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} WHERE ID in ({$ids_str})" ); // phpcs:ignore WordPress.DB

		foreach ( (array) $posts as $_post ) {
			$this->append_ref_data( 'post', $_post->ID, $_post );
		}
	}

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