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

Commit 70ce81c

Browse files
authored
Merge pull request #335 from ahmedofali/master
Detect woocommerce and polylang if installed as mu-plugins Fix #312
2 parents f9e7209 + be1417a commit 70ce81c

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

src/Hyyan/WPI/Plugin.php

+2-14
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,7 @@ public static function canActivate()
109109
$woocommerce = false;
110110

111111
/* check polylang plugin */
112-
if (
113-
(
114-
is_plugin_active('polylang/polylang.php') ||
115-
is_plugin_active('polylang-pro/polylang.php')
116-
) ||
117-
(
118-
is_plugin_active_for_network('polylang/polylang.php') ||
119-
is_plugin_active_for_network('polylang-pro/polylang.php')
120-
)
121-
) {
112+
if (class_exists('Polylang')) {
122113
if (isset($GLOBALS['polylang'], \PLL()->model, PLL()->links_model)) {
123114
if (pll_default_language()) {
124115
$polylang = true;
@@ -127,10 +118,7 @@ public static function canActivate()
127118
}
128119

129120
/* check woocommerce plugin */
130-
if (
131-
is_plugin_active('woocommerce/woocommerce.php') ||
132-
is_plugin_active_for_network('woocommerce/woocommerce.php')
133-
) {
121+
if (class_exists('WooCommerce')) {
134122
$woocommerce = true;
135123
}
136124

src/Hyyan/WPI/Utilities.php

+1-14
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,7 @@ public static function woocommerceVersionCheck($version)
226226
*/
227227
public static function polylangVersionCheck($version)
228228
{
229-
if (!function_exists('get_plugin_data')) {
230-
require_once ABSPATH . 'wp-admin/includes/plugin.php';
231-
}
232-
233-
$filepath = ABSPATH . 'wp-content/plugins/polylang/polylang.php';
234-
if (! file_exists($filepath)) {
235-
$filepath = ABSPATH . 'wp-content/plugins/polylang-pro/polylang.php';
236-
if (! file_exists($filepath)) {
237-
error_log('Polylang version not tested - polylang file not found');
238-
return true;
239-
}
240-
}
241-
$data = get_plugin_data($filepath, false, false);
242-
if (version_compare($data['Version'], $version, '>=')) {
229+
if (defined('POLYLANG_VERSION') && version_compare(POLYLANG_VERSION, $version, '>=')) {
243230
return true;
244231
}
245232

0 commit comments

Comments
 (0)