facets endpoint - fix ordination in selected items (taxonomy)
This commit is contained in:
parent
9bcf796512
commit
74130c6bc0
|
@ -162,22 +162,31 @@ class REST_Facets_Controller extends REST_Controller {
|
||||||
|
|
||||||
if( $selected && $request['getSelected'] && $request['getSelected'] === '1' ){
|
if( $selected && $request['getSelected'] && $request['getSelected'] === '1' ){
|
||||||
$ids = $this->get_terms_ids( $terms );
|
$ids = $this->get_terms_ids( $terms );
|
||||||
|
$realResponse = [];
|
||||||
|
|
||||||
foreach( $selected as $index => $term_id ){
|
foreach( $selected as $index => $term_id ){
|
||||||
|
|
||||||
if( in_array($term_id,$ids) ){
|
$term_selected = $this->terms_repository->fetch($term_id, $this->taxonomy);
|
||||||
|
$realResponse[] = $term_selected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach( $terms as $index => $term ){
|
||||||
|
|
||||||
|
if( in_array($term->WP_Term->term_id,$selected) ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$term_selected = $this->terms_repository->fetch($term_id, $this->taxonomy);
|
$realResponse[] = $term;
|
||||||
array_unshift($terms, $term_selected);
|
|
||||||
|
|
||||||
if( isset($request['number']) && ($index+1) >= $request['number']){
|
if( isset($request['number']) && count($realResponse) >= $request['number']){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
$terms = $realResponse;
|
||||||
|
}
|
||||||
|
|
||||||
$restTermClass = new REST_Terms_Controller();
|
$restTermClass = new REST_Terms_Controller();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue