Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Identify woocommerce and polylang if installed as mu-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedofali committed Apr 29, 2018
1 parent c7eb1f7 commit 9e6dd41
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/Hyyan/WPI/Plugin.php
Expand Up @@ -108,15 +108,21 @@ public static function canActivate()
$polylang = false;
$woocommerce = false;

$polylang_file = 'polylang/polylang.php';
$polylang_pro_file = 'polylang-pro/polylang.php';
$woocommerce_file = 'woocommerce/woocommerce.php';

/* check polylang plugin */
if (
(
is_plugin_active('polylang/polylang.php') ||
is_plugin_active('polylang-pro/polylang.php')
is_plugin_active($polylang_file) ||
self::isMuPlugin($polylang_file) ||
is_plugin_active($polylang_pro_file) ||
self::isMuPlugin($polylang_pro_file)
) ||
(
is_plugin_active_for_network('polylang/polylang.php') ||
is_plugin_active_for_network('polylang-pro/polylang.php')
is_plugin_active_for_network($polylang_file) ||
is_plugin_active_for_network($polylang_pro_file)
)
) {
if (isset($GLOBALS['polylang'], \PLL()->model, PLL()->links_model)) {
Expand All @@ -128,8 +134,9 @@ public static function canActivate()

/* check woocommerce plugin */
if (
is_plugin_active('woocommerce/woocommerce.php') ||
is_plugin_active_for_network('woocommerce/woocommerce.php')
is_plugin_active($woocommerce_file) ||
self::isMuPlugin($woocommerce_file) ||
is_plugin_active_for_network($woocommerce_file)
) {
$woocommerce = true;
}
Expand All @@ -139,6 +146,17 @@ public static function canActivate()
($woocommerce && Utilities::woocommerceVersionCheck(self::WOOCOMMERCE_VERSION));
}

/**
* Check if Mu-plugin
*
* @param string $plugin
* @return boolean
*/
public static function isMuPlugin($plugin)
{
return file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $plugin ) ;
}

/**
* On Upgrade
*
Expand Down

0 comments on commit 9e6dd41

Please sign in to comment.