From d5655b6b27c172318c02cc368a610689f16f34da Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Wed, 20 Mar 2024 13:23:18 +0530 Subject: [PATCH] Update PluginService.php --- includes/Services/PluginService.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/Services/PluginService.php b/includes/Services/PluginService.php index 1d1280bed..60b283e55 100644 --- a/includes/Services/PluginService.php +++ b/includes/Services/PluginService.php @@ -33,16 +33,17 @@ public static function initialize() { $flow = Data::current_flow(); if ( 'sitegen' === $flow && SiteGenService::is_enabled() ) { - $init_plugins = SiteGenService::get_plugin_recommendations(); - if ( is_wp_error( $init_plugins ) ) { - return $init_plugins; - } + $init_plugins = Plugins::get_init(); + // Convert { slug->slug } to hash for faster search // As Php uses array as { [0] -> slug_name } and that won't work with array_key_exists $plugin_slugs = array_column( $init_plugins, 'slug', 'slug' ); // Iterate and ensure no duplicates are added - $default_plugins = Plugins::get_init(); + $default_plugins = SiteGenService::get_plugin_recommendations(); + if ( is_wp_error( $default_plugins ) ) { + return $default_plugins; + } foreach ( $default_plugins as $default_plugin ) { if ( ! array_key_exists( $default_plugin['slug'], $plugin_slugs ) ) { $init_plugins[] = $default_plugin;