From e90865819ddf2cc2d5bbe5f7bb104fbda3a209e6 Mon Sep 17 00:00:00 2001 From: Eric Caron Date: Fri, 21 Oct 2022 08:32:07 -0500 Subject: [PATCH] Avoid "Cannot declare class ElasticPressLabs" error Depending on if ElasticPressLabs or ElasticPress plugin is loaded first, there's a situation where `core.php`'s `maybe_load_features` function and ElasticPress' `Features.php`'s `setup_features` both run - which causes the class to attempt two loads. Moving the `register_subfeatures` to `require_once` prevents this conflict, while keeping the other feature loading functionality in place. --- includes/classes/Feature/ElasticPressLabs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/Feature/ElasticPressLabs.php b/includes/classes/Feature/ElasticPressLabs.php index 0160062..b0bb9fe 100644 --- a/includes/classes/Feature/ElasticPressLabs.php +++ b/includes/classes/Feature/ElasticPressLabs.php @@ -179,7 +179,7 @@ private function register_subfeatures() { ); foreach ( $features_files as $filename ) { - require ELASTICPRESS_LABS_INC . 'classes/Feature/' . basename( $filename ); + require_once ELASTICPRESS_LABS_INC . 'classes/Feature/' . basename( $filename ); $class_name = 'ElasticPressLabs\Feature\\' . basename( $filename, '.php' );