Yoast\WP\SEO\Bulk_Editor\Infrastructure\Posts

Indexable_Posts_Collector::resolve_total │ private │ Yoast 1.0

Resolves the total number of matching posts.

A partially-filled page means the result set ended within it, so the total is known without a second query: the offset plus the distinct posts on this page. Whether the page ended is judged on the number of rows fetched, before duplicates are removed, since that is what reveals the database had no more rows. A full or empty page does not reveal the total, so it falls back to a count query. Non-editable posts are shown locked rather than removed, so they still count.

Метод класса: Indexable_Posts_Collector{}

Хуков нет.

Возвращает

int. The total number of matching posts.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->resolve_total( $query, $fetched, $distinct ): int;
$query(Posts_Query) (обязательный)
The query that produced the page.
$fetched(int) (обязательный)
The number of rows the page returned, before duplicates are removed.
$distinct(int) (обязательный)
The number of distinct posts on the page, after duplicates are removed.

Код Indexable_Posts_Collector::resolve_total() Yoast 28.9

private function resolve_total( Posts_Query $query, int $fetched, int $distinct ): int {
	if ( $fetched > 0 && $fetched < $query->get_per_page() ) {
		return ( $query->get_offset() + $distinct );
	}

	return (int) $this->build_query( $query )->count();
}