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

Commit

Permalink
Merge pull request #335 from ahmedofali/master
Browse files Browse the repository at this point in the history
Detect woocommerce and polylang if installed as mu-plugins
Fix #312
  • Loading branch information
hyyan committed Apr 30, 2018
2 parents f9e7209 + be1417a commit 70ce81c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
16 changes: 2 additions & 14 deletions src/Hyyan/WPI/Plugin.php
Expand Up @@ -109,16 +109,7 @@ public static function canActivate()
$woocommerce = false;

/* check polylang plugin */
if (
(
is_plugin_active('polylang/polylang.php') ||
is_plugin_active('polylang-pro/polylang.php')
) ||
(
is_plugin_active_for_network('polylang/polylang.php') ||
is_plugin_active_for_network('polylang-pro/polylang.php')
)
) {
if (class_exists('Polylang')) {
if (isset($GLOBALS['polylang'], \PLL()->model, PLL()->links_model)) {
if (pll_default_language()) {
$polylang = true;
Expand All @@ -127,10 +118,7 @@ public static function canActivate()
}

/* check woocommerce plugin */
if (
is_plugin_active('woocommerce/woocommerce.php') ||
is_plugin_active_for_network('woocommerce/woocommerce.php')
) {
if (class_exists('WooCommerce')) {
$woocommerce = true;
}

Expand Down
15 changes: 1 addition & 14 deletions src/Hyyan/WPI/Utilities.php
Expand Up @@ -226,20 +226,7 @@ public static function woocommerceVersionCheck($version)
*/
public static function polylangVersionCheck($version)
{
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

$filepath = ABSPATH . 'wp-content/plugins/polylang/polylang.php';
if (! file_exists($filepath)) {
$filepath = ABSPATH . 'wp-content/plugins/polylang-pro/polylang.php';
if (! file_exists($filepath)) {
error_log('Polylang version not tested - polylang file not found');
return true;
}
}
$data = get_plugin_data($filepath, false, false);
if (version_compare($data['Version'], $version, '>=')) {
if (defined('POLYLANG_VERSION') && version_compare(POLYLANG_VERSION, $version, '>=')) {
return true;
}

Expand Down

0 comments on commit 70ce81c

Please sign in to comment.