WC_REST_CRUD_Controller::get_objects
Get objects.
Метод класса: WC_REST_CRUD_Controller{}
Хуков нет.
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_objects( $query_args );
- $query_args(массив) (обязательный)
- Query args.
Список изменений
| С версии 3.0.0 | Введена. |
Код WC_REST_CRUD_Controller::get_objects() WC REST CRUD Controller::get objects WC 10.7.0
protected function get_objects( $query_args ) {
$query = new WP_Query();
$result = $query->query( $query_args );
$total_posts = $query->found_posts;
if ( $total_posts < 1 && isset( $query_args['paged'] ) && absint( $query_args['paged'] ) > 1 ) {
// Out-of-bounds, run the query again without LIMIT for total count.
unset( $query_args['paged'] );
$count_query = new WP_Query();
$count_query->query( $query_args );
$total_posts = $count_query->found_posts;
}
return array(
'objects' => array_filter( array_map( array( $this, 'get_object' ), $result ) ),
'total' => (int) $total_posts,
'pages' => (int) ceil( $total_posts / (int) $query->query_vars['posts_per_page'] ),
);
}