redProducts = array(); $i = 0; foreach ( $products as $post ) { if ( $remote ) { $orderedProducts[$i] = new \stdClass(); $orderedProducts[$i]->ID = $post->ID; } else { $orderedProducts[$i] = $post; } $score = Helpers::calcScore( $keyword, $post->post_title ); $orderedProducts[$i]->score = apply_filters( 'dgwt/wcas/search_results/product/score', $score, $keyword, $post->ID, $post ); $i++; } // Sort by relevance usort( $orderedProducts, array( 'DgoraWcas\\Helpers', 'cmpSimilarity' ) ); // Response for remote requests if ( $remote ) { $output['suggestions'] = $orderedProducts; $output['time'] = number_format( microtime( true ) - $start, 2, '.', '' ) . ' sec'; $result = apply_filters( 'dgwt/wcas/page_search_results/output', $output ); if ( $return ) { return $result; } else { echo json_encode( $result ) ; die; } } $relevantProducts = array(); $productsSlots = ( $this->flexibleLimits ? $this->totalLimit : $this->groups['product']['limit'] ); foreach ( $orderedProducts as $post ) { $product = new Product( $post ); if ( !$product->isCorrect() ) { continue; } // Strip