Skip to content

Commit

Permalink
Make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
officiallygod committed Oct 10, 2024
1 parent 0667cf1 commit aaf2691
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
9 changes: 9 additions & 0 deletions includes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}
56 changes: 55 additions & 1 deletion includes/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
Expand Down

0 comments on commit aaf2691

Please sign in to comment.