*/ public function ids_after( int $last_read_post_id, Settings $settings ): array { $rows = $this->query_runner->rows( $this->query_runner->prepare( 'SELECT ID FROM ' . $this->posts_table . ' WHERE ID > %d AND ' . $this->checked_condition( $settings ) . ' ORDER BY ID LIMIT %d', $last_read_post_id, self::BATCH_SIZE ) ); return array_map( 'intval', array_column( $rows, 'ID' ) ); } public function total( Settings $settings ): int { $count = $this->query_runner->value( 'SELECT COUNT(*) FROM ' . $this->posts_table . ' WHERE ' . $this->checked_condition( $settings ) ); return (int) $count; } private function checked_condition( Settings $settings ): string { $post_types = array_keys( array_filter( array( self::POST_TYPE => $settings->check_posts, self::PAGE_TYPE => $settings->check_pages, ) ) ); if ( array() === $post_types ) { return self::NOTHING_FOUND; } $type_placeholders = array_fill( 0, count( $post_types ), '%s' ); $placeholders = implode( ', ', $type_placeholders ); return $this->query_runner->prepare( 'post_status = %s AND post_type IN (' . $placeholders . ')', self::READ_STATUS, ...$post_types ); } }