| 1 |
<?php |
| 2 |
|
| 3 |
namespace ImportWP\Common\AddonAPI; |
| 4 |
|
| 5 |
class AddonManager |
| 6 |
{ |
| 7 |
/** |
| 8 |
* @var Addon[] |
| 9 |
*/ |
| 10 |
private $_addons = []; |
| 11 |
|
| 12 |
/** |
| 13 |
* @var AddonManager |
| 14 |
*/ |
| 15 |
private static $instance; |
| 16 |
|
| 17 |
/** |
| 18 |
* @return AddonManager Instance |
| 19 |
*/ |
| 20 |
public static function instance() |
| 21 |
{ |
| 22 |
if (!isset(self::$instance) && !(self::$instance instanceof AddonManager)) { |
| 23 |
self::$instance = new AddonManager(); |
| 24 |
} |
| 25 |
|
| 26 |
return self::$instance; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Protected constructor to prevent creating a new instance of the |
| 31 |
* class via the `new` operator from outside of this class. |
| 32 |
*/ |
| 33 |
protected function __construct() {} |
| 34 |
|
| 35 |
/** |
| 36 |
* As this class is a singleton it should not be clone-able |
| 37 |
*/ |
| 38 |
protected function __clone() {} |
| 39 |
|
| 40 |
/** |
| 41 |
* As this class is a singleton it should not be able to be unserialized |
| 42 |
*/ |
| 43 |
public function __wakeup() {} |
| 44 |
|
| 45 |
/** |
| 46 |
* Register Addon |
| 47 |
* |
| 48 |
* @param Addon $addon |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
public function register($addon) |
| 52 |
{ |
| 53 |
$this->_addons[] = $addon; |
| 54 |
} |
| 55 |
|
| 56 |
public function getAddonList() |
| 57 |
{ |
| 58 |
|
| 59 |
$addons = []; |
| 60 |
|
| 61 |
// WooCommerce |
| 62 |
if (class_exists('WooCommerce') && !function_exists('iwp_woocommerce_setup')) { |
| 63 |
$addons[] = [ |
| 64 |
'name' => 'WooCommerce', |
| 65 |
'slug' => 'woocommerce', |
| 66 |
'url' => 'https://www.importwp.com/integrations/import-woocommerce-products/', |
| 67 |
]; |
| 68 |
} |
| 69 |
|
| 70 |
// Pods |
| 71 |
if (function_exists('pods_is_plugin_active') && !function_exists('iwp_pods_setup')) { |
| 72 |
$addons[] = [ |
| 73 |
'name' => 'Pods', |
| 74 |
'slug' => 'pods', |
| 75 |
'url' => 'https://www.importwp.com/integrations/pods/', |
| 76 |
]; |
| 77 |
} |
| 78 |
|
| 79 |
// JetEngine |
| 80 |
if (class_exists('Jet_Engine') && !function_exists('iwp_jet_engine_setup')) { |
| 81 |
$addons[] = [ |
| 82 |
'name' => 'JetEngine', |
| 83 |
'slug' => 'jetengine', |
| 84 |
'url' => 'https://www.importwp.com/integrations/jet-engine/', |
| 85 |
]; |
| 86 |
} |
| 87 |
|
| 88 |
// Yoast SEO |
| 89 |
if (function_exists('wpseo_init') && !function_exists('iwp_yoast_setup')) { |
| 90 |
$addons[] = [ |
| 91 |
'name' => 'Yoast SEO', |
| 92 |
'slug' => 'yoast-seo', |
| 93 |
'url' => 'https://www.importwp.com/integrations/import-export-yoast-seo/', |
| 94 |
]; |
| 95 |
} |
| 96 |
|
| 97 |
// Rank Math SEO |
| 98 |
if (function_exists('rank_math') && !function_exists('iwp_rank_math_setup')) { |
| 99 |
$addons[] = [ |
| 100 |
'name' => 'Rank Math SEO', |
| 101 |
'slug' => 'rank-math', |
| 102 |
'url' => 'https://www.importwp.com/integrations/rank-math-seo/', |
| 103 |
]; |
| 104 |
} |
| 105 |
|
| 106 |
// Polylang |
| 107 |
if (defined('POLYLANG') && !function_exists('iwp_polylang_setup')) { |
| 108 |
$addons[] = [ |
| 109 |
'name' => 'Polylang', |
| 110 |
'slug' => 'polylang', |
| 111 |
'url' => 'https://www.importwp.com/integrations/polylang/', |
| 112 |
]; |
| 113 |
} |
| 114 |
|
| 115 |
// WPML |
| 116 |
if (class_exists('\SitePress') && !function_exists('iwp_wpml_setup')) { |
| 117 |
$addons[] = [ |
| 118 |
'name' => 'WPML', |
| 119 |
'slug' => 'wpml', |
| 120 |
'url' => 'https://www.importwp.com/integrations/import-wpml-translations/', |
| 121 |
]; |
| 122 |
} |
| 123 |
|
| 124 |
return $addons; |
| 125 |
} |
| 126 |
} |
| 127 |
|