/** * After the final list of post IDs has been produced, * sort them by distance if needed */ function sort_by_distance($post_ids, $class) { $helper = FacetWP_Helper::instance(); $ordered_posts = $helper->facet_types['proximity']->ordered_posts; if (!empty($ordered_posts)) { // Sort the post IDs according to distance $intersected_ids = array(); foreach ($ordered_posts as $p) { if (in_array($p, $post_ids)) { $intersected_ids[] = $p; } } $post_ids = $intersected_ids; } return $post_ids; }
public function output_facets() { global $listify_facetwp; $facets = $listify_facetwp->get_facets(); $facetwp = FacetWP_Helper::instance(); $count = count($facets); $count = floor(12 / ($count == 0 ? 1 : $count)); $columns = 'col-sm-12 col-md-' . $count . ''; $class = ''; if ('side' == $this->position()) { $columns = null; $class = 'widget'; } $output = array(); foreach ($facets as $facet) { $facet_obj = $facetwp->get_facet_by_name($facet); $title = $facet_obj['label']; $facet = '[facetwp facet="' . $facet . '"]'; $output[] = '<aside class="' . $class . ' widget-job_listing-archive ' . $columns . '"><h2 class="widget-title">' . esc_attr($title) . '</h2>' . do_shortcode($facet) . '</aside>'; } return implode('', $output); }