From aaf2691bdf6e3af31ff0855255f7d24d9db3e745 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Thu, 10 Oct 2024 08:38:47 +0530 Subject: [PATCH] Make it work --- includes/Config.php | 9 +++++++ includes/Plugins.php | 56 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/includes/Config.php b/includes/Config.php index 7671983..4b988f3 100644 --- a/includes/Config.php +++ b/includes/Config.php @@ -66,4 +66,13 @@ public static function has_ai_sitegen() { public static function can_migrate_site() { return self::get_site_capability( 'canMigrateSite' ); } + + /** + * Gets the current site's capability if it has solution. + * + * @return boolean + */ + public static function has_solution() { + return self::get_site_capability( 'hasSolution' ); + } } diff --git a/includes/Plugins.php b/includes/Plugins.php index ad23d49..bc19ff5 100644 --- a/includes/Plugins.php +++ b/includes/Plugins.php @@ -55,13 +55,55 @@ final class Plugins { ), ), 'site-capabilities' => array( - 'hasEcomdash' => array( + 'hasEcomdash' => array( array( 'slug' => 'nfd_slug_ecomdash_wordpress_plugin', 'activate' => true, 'priority' => 220, ), ), + 'hasYithExtended' => array( + array( + 'slug' => 'woocommerce', + 'activate' => true, + 'priority' => 300, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_booking', + 'activate' => true, + 'priority' => 100, + ), + array( + 'slug' => 'yith-woocommerce-ajax-search', + 'activate' => true, + 'priority' => 120, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_gift_cards', + 'activate' => true, + 'priority' => 140, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_wishlist', + 'activate' => true, + 'priority' => 160, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_customize_myaccount_page', + 'activate' => true, + 'priority' => 180, + ), + array( + 'slug' => 'nfd_slug_yith_woocommerce_ajax_product_filter', + 'activate' => true, + 'priority' => 200, + ), + array( + 'slug' => 'nfd_slug_wonder_cart', + 'activate' => true, + 'priority' => 210, + ), + ), ), 'ecommerce' => array( 'default' => array( @@ -213,6 +255,13 @@ final class Plugins { ), ); + /** + * An array of capabilities that should not be run if the site has solution. + * + * @return array + */ + protected static $solution_override_capabilities = array( 'hasYithExtended' ); + /** * Get the list of initial plugins to be installed for a particular hosting plan. * @@ -227,6 +276,11 @@ public static function get_init() { $plugins_data_for_site_capabilities = self::$init_list['site-capabilities']; foreach ( $plugins_data_for_site_capabilities as $site_capability => $plugins_data ) { + // Skip capability installation if solution is present. + if ( Config::has_solution() && + in_array( $site_capability, self::$solution_override_capabilities ) ) { + continue; + } // Check if the capability is enabled on Hiive if ( true === Config::get_site_capability( $site_capability ) ) { // Check if there are plugins for the flag.