| 1 |
<?php |
| 2 |
|
| 3 |
use AcyMailing\Classes\PluginClass; |
| 4 |
|
| 5 |
function acym_isExtensionActive($extension) |
| 6 |
{ |
| 7 |
if (acym_isMuPlugin($extension)) return true; |
| 8 |
|
| 9 |
if (function_exists('is_plugin_active')) return is_plugin_active($extension); |
| 10 |
|
| 11 |
return file_exists(WP_PLUGIN_DIR.DS.$extension); |
| 12 |
} |
| 13 |
|
| 14 |
function acym_isMuPlugin($extension) |
| 15 |
{ |
| 16 |
return file_exists(WPMU_PLUGIN_DIR.DS.$extension); |
| 17 |
} |
| 18 |
|
| 19 |
function acym_getPluginPath($plugin) |
| 20 |
{ |
| 21 |
$corePath = ACYM_BACK.'dynamics'.DS.$plugin.DS.'plugin.php'; |
| 22 |
if (file_exists($corePath)) return $corePath; |
| 23 |
|
| 24 |
return ACYM_ADDONS_FOLDER_PATH.$plugin.DS.'plugin.php'; |
| 25 |
} |
| 26 |
|
| 27 |
function acym_coreAddons() |
| 28 |
{ |
| 29 |
return [ |
| 30 |
(object)[ |
| 31 |
'title' => acym_translation('ACYM_ARTICLE'), |
| 32 |
'folder_name' => 'post', |
| 33 |
'version' => '10.2.2', |
| 34 |
'active' => '1', |
| 35 |
'category' => 'Content management', |
| 36 |
'level' => 'starter', |
| 37 |
'uptodate' => '1', |
| 38 |
'description' => '- Insert WordPress posts in your emails<br/>- Insert the latest posts of a category in an automatic email', |
| 39 |
'latest_version' => '10.2.2', |
| 40 |
'type' => 'CORE', |
| 41 |
], |
| 42 |
(object)[ |
| 43 |
'title' => acym_translation('ACYM_PAGE'), |
| 44 |
'folder_name' => 'page', |
| 45 |
'version' => '10.2.2', |
| 46 |
'active' => '1', |
| 47 |
'category' => 'Content management', |
| 48 |
'level' => 'starter', |
| 49 |
'uptodate' => '1', |
| 50 |
'description' => '- Insert pages in your emails', |
| 51 |
'latest_version' => '10.2.2', |
| 52 |
'type' => 'CORE', |
| 53 |
], |
| 54 |
(object)[ |
| 55 |
'title' => acym_translation('ACYM_CREATE_USER'), |
| 56 |
'folder_name' => 'createuser', |
| 57 |
'version' => '10.2.2', |
| 58 |
'active' => '1', |
| 59 |
'category' => 'User management', |
| 60 |
'level' => 'starter', |
| 61 |
'uptodate' => '1', |
| 62 |
'description' => '- Automatically creates a site user when an AcyMailing subscriber is created', |
| 63 |
'latest_version' => '10.2.2', |
| 64 |
'type' => 'CORE', |
| 65 |
], |
| 66 |
]; |
| 67 |
} |
| 68 |
|
| 69 |
function acym_isTrackingSalesActive() |
| 70 |
{ |
| 71 |
$trackingWoocommerce = false; |
| 72 |
acym_trigger('onAcymIsTrackingWoocommerce', [&$trackingWoocommerce], 'plgAcymWoocommerce'); |
| 73 |
|
| 74 |
return $trackingWoocommerce; |
| 75 |
} |
| 76 |
|
| 77 |
function acym_loadPlugins() |
| 78 |
{ |
| 79 |
$dynamicsLoadedLast = ['managetext']; |
| 80 |
$dynamics = acym_getFolders(ACYM_BACK.'dynamics'); |
| 81 |
|
| 82 |
$pluginClass = new PluginClass(); |
| 83 |
$plugins = $pluginClass->getPlugins(); |
| 84 |
|
| 85 |
foreach ($dynamics as $key => $oneDynamic) { |
| 86 |
if (!empty($plugins[$oneDynamic]) && 0 === intval($plugins[$oneDynamic]->active)) { |
| 87 |
unset($dynamics[$key]); |
| 88 |
} |
| 89 |
|
| 90 |
if ('managetext' === $oneDynamic) { |
| 91 |
unset($dynamics[$key]); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
$pluginsLoadedLast = ['tableofcontents']; |
| 96 |
foreach ($plugins as $pluginFolder => $onePlugin) { |
| 97 |
if (in_array($pluginFolder, $dynamics) || 0 === intval($onePlugin->active)) { |
| 98 |
continue; |
| 99 |
} |
| 100 |
|
| 101 |
if (in_array($pluginFolder, $pluginsLoadedLast)) { |
| 102 |
array_unshift($dynamicsLoadedLast, $pluginFolder); |
| 103 |
} else { |
| 104 |
$dynamics[] = $pluginFolder; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
$dynamics = array_merge($dynamics, $dynamicsLoadedLast); |
| 109 |
|
| 110 |
global $acymPlugins; |
| 111 |
global $acymAddonsForSettings; |
| 112 |
|
| 113 |
$integrationsRaw = []; |
| 114 |
$acyVersion = acym_config()->get('version'); |
| 115 |
do_action_ref_array('acym_load_installed_integrations', [&$integrationsRaw, $acyVersion]); |
| 116 |
|
| 117 |
$integrations = []; |
| 118 |
foreach ($integrationsRaw as $oneIntegration) { |
| 119 |
$addonName = strtolower(substr($oneIntegration['className'], 7)); |
| 120 |
$integrations[$addonName] = $oneIntegration; |
| 121 |
|
| 122 |
if (!in_array($addonName, $dynamics)) { |
| 123 |
$dynamics[] = $addonName; |
| 124 |
} |
| 125 |
} |
| 126 |
$integrationsClasses = array_keys($integrations); |
| 127 |
|
| 128 |
foreach ($dynamics as $oneDynamic) { |
| 129 |
if (in_array($oneDynamic, $integrationsClasses)) { |
| 130 |
$dynamicFile = $integrations[$oneDynamic]['path'].DS.'plugin.php'; |
| 131 |
} else { |
| 132 |
$dynamicFile = acym_getPluginPath($oneDynamic); |
| 133 |
} |
| 134 |
$className = 'plgAcym'.ucfirst($oneDynamic); |
| 135 |
|
| 136 |
if (isset($acymPlugins[$className]) || !file_exists($dynamicFile) || (!class_exists($className) && !include_once $dynamicFile)) { |
| 137 |
continue; |
| 138 |
} |
| 139 |
|
| 140 |
if (!class_exists($className)) { |
| 141 |
continue; |
| 142 |
} |
| 143 |
|
| 144 |
$plugin = new $className(); |
| 145 |
|
| 146 |
if (in_array($oneDynamic, $integrationsClasses)) { |
| 147 |
$pluginClass->addIntegrationIfMissing($plugin); |
| 148 |
} |
| 149 |
|
| 150 |
if (in_array($plugin->cms, ['all', 'WordPress'])) { |
| 151 |
$acymAddonsForSettings[$className] = $plugin; |
| 152 |
} |
| 153 |
|
| 154 |
if (!in_array($plugin->cms, ['all', 'WordPress']) || !$plugin->installed) { |
| 155 |
continue; |
| 156 |
} |
| 157 |
|
| 158 |
$acymPlugins[$className] = $plugin; |
| 159 |
} |
| 160 |
} |
| 161 |
|