Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…c57cd1696fdd7ae03e8b41aedf from refs/tags/v1.0.x-beta
  • Loading branch information
prcdevgitbot committed Oct 9, 2024
1 parent 5b3e310 commit 0d35f3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions includes/facets/class-facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ class Facets {
private $version;

/**
* Initialize the EP Facets class.
* Current Site ID
*/
protected $ep_facets;
private $site_id;

/**
* The unique identifier of this plugin.
*/
public static $handle = 'prc-platform-facets';

/**
Expand All @@ -33,6 +36,7 @@ class Facets {
*/
public function __construct( $version, $loader ) {
$this->version = $version;
$this->site_id = get_current_blog_id();

// Include middleware for FacetWP and ElasticPress.
require_once plugin_dir_path( __FILE__ ) . 'providers/facet-wp/class-facetwp-middleware.php';
Expand All @@ -41,6 +45,7 @@ public function __construct( $version, $loader ) {
// Include block files.
$this->load_blocks();

// Initialize hybrid facets system.
$this->init($loader);
}

Expand Down Expand Up @@ -82,7 +87,7 @@ public static function format_label($label) {
* @return string
*/
public static function construct_cache_key($query = [], $selected = []) {
$invalidate = '10/05/2024b';
$invalidate = '10/09/2024b';
// Remove pagination from the query args
$query = array_merge($query, array(
'paged' => 1
Expand Down Expand Up @@ -110,7 +115,7 @@ public static function construct_cache_group() {
}

public function init($loader = null) {
if ( null !== $loader ) {
if ( null !== $loader && $this->site_id === PRC_PRIMARY_SITE_ID ) {
// FacetWP Back Compat:
// We need to determine when to load these middlewares. If it's a search page, lets use EP, otherwise use FacetWP.
new FacetWP_Middleware($loader);
Expand Down
4 changes: 2 additions & 2 deletions includes/facets/providers/facet-wp/class-facetwp-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function process_taxonomy_facet($facet) {
continue;
}
$taxonomy_facet['choices'][] = [
'count' => $facet_obj['count'],
'count' => isset($facet_obj['count']) ? $facet_obj['count'] : 0,
'label' => \PRC\Platform\Facets::format_label($facet_obj['label']),
'slug' => $facet_obj['value'],
'facetSlug' => $facet_slug,
Expand Down Expand Up @@ -156,7 +156,7 @@ protected function process_non_taxonomy_facet($facet) {
}
foreach ($facet['choices'] as $facet_obj) {
$standard_facet['choices'][] = [
'count' => $facet_obj['count'],
'count' => isset($facet_obj['count']) ? $facet_obj['count'] : 0,
'label' => \PRC\Platform\Facets::format_label($facet_obj['label']),
'slug' => $facet_obj['value'],
'facetSlug' => $facet_slug,
Expand Down

0 comments on commit 0d35f3b

Please sign in to comment.