Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with feature activation during install #2734

Merged
merged 6 commits into from
May 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Deactivate any features not selected during install.
  • Loading branch information
JakePT committed May 2, 2022
commit 93dead50f66927d69096b58d3e774e4b97b09b83
15 changes: 10 additions & 5 deletions includes/classes/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,19 @@ public function maybe_set_features() {
return;
}

if ( empty( $_POST['features'] ) || ! is_array( $_POST['features'] ) ) {
if ( ! isset( $_POST['features'] ) || ! is_array( $_POST['features'] ) ) {
return;
}

$features = array_map( 'sanitize_text_field', $_POST['features'] );
foreach ( $features as $feature ) {
\ElasticPress\Features::factory()->activate_feature( $feature );
$registered_features = \ElasticPress\Features::factory()->registered_features;
$activation_features = wp_list_filter( $registered_features, array( 'available_during_installation' => true ) );

foreach ( $activation_features as $slug => $feature ) {
if ( in_array( $slug, $_POST['features'], true ) ) {
\ElasticPress\Features::factory()->activate_feature( $slug );
} else {
\ElasticPress\Features::factory()->deactivate_feature( $slug );
}
}

$this->install_status = 4;
Expand All @@ -150,4 +156,3 @@ public static function factory() {
return $instance;
}
}