| @@ -1,10 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 3 | 5 | use AcyMailing\Classes\PluginClass; |
| 4 | 6 | |
| 5 | -function acym_isExtensionActive($extension) | |
| 7 | +function acym_isExtensionActive(string $extension): bool | |
| 6 | 8 | { |
| 9 | + // Test first as mu-plugins don't have an active status for WP | |
| 7 | 10 | if (acym_isMuPlugin($extension)) return true; |
| 8 | 11 | |
| 9 | 12 | if (function_exists('is_plugin_active')) return is_plugin_active($extension); |
| 10 | 13 | |
| @@ -10,14 +13,14 @@ | ||
| 10 | 13 | |
| 11 | 14 | return file_exists(WP_PLUGIN_DIR.DS.$extension); |
| 12 | 15 | } |
| 13 | 16 | |
| 14 | -function acym_isMuPlugin($extension) | |
| 17 | +function acym_isMuPlugin(string $extension): bool | |
| 15 | 18 | { |
| 16 | 19 | return file_exists(WPMU_PLUGIN_DIR.DS.$extension); |
| 17 | 20 | } |
| 18 | 21 | |
| 19 | -function acym_getPluginPath($plugin) | |
| 22 | +function acym_getPluginPath(string $plugin): string | |
| 20 | 23 | { |
| 21 | 24 | $corePath = ACYM_BACK.'dynamics'.DS.$plugin.DS.'plugin.php'; |
| 22 | 25 | if (file_exists($corePath)) return $corePath; |
| 23 | 26 | |
| @@ -23,51 +26,51 @@ | ||
| 23 | 26 | |
| 24 | 27 | return ACYM_ADDONS_FOLDER_PATH.$plugin.DS.'plugin.php'; |
| 25 | 28 | } |
| 26 | 29 | |
| 27 | -function acym_coreAddons() | |
| 30 | +function acym_coreAddons(): array | |
| 28 | 31 | { |
| 29 | 32 | return [ |
| 30 | 33 | (object)[ |
| 31 | 34 | 'title' => acym_translation('ACYM_ARTICLE'), |
| 32 | 35 | 'folder_name' => 'post', |
| 33 | - 'version' => '10.0.1', | |
| 36 | + 'version' => '11.1.0', | |
| 34 | 37 | 'active' => '1', |
| 35 | 38 | 'category' => 'Content management', |
| 36 | 39 | 'level' => 'starter', |
| 37 | 40 | 'uptodate' => '1', |
| 38 | 41 | 'description' => '- Insert WordPress posts in your emails<br/>- Insert the latest posts of a category in an automatic email', |
| 39 | - 'latest_version' => '10.0.1', | |
| 42 | + 'latest_version' => '11.1.0', | |
| 40 | 43 | 'type' => 'CORE', |
| 41 | 44 | ], |
| 42 | 45 | (object)[ |
| 43 | 46 | 'title' => acym_translation('ACYM_PAGE'), |
| 44 | 47 | 'folder_name' => 'page', |
| 45 | - 'version' => '10.0.1', | |
| 48 | + 'version' => '11.1.0', | |
| 46 | 49 | 'active' => '1', |
| 47 | 50 | 'category' => 'Content management', |
| 48 | 51 | 'level' => 'starter', |
| 49 | 52 | 'uptodate' => '1', |
| 50 | 53 | 'description' => '- Insert pages in your emails', |
| 51 | - 'latest_version' => '10.0.1', | |
| 54 | + 'latest_version' => '11.1.0', | |
| 52 | 55 | 'type' => 'CORE', |
| 53 | 56 | ], |
| 54 | 57 | (object)[ |
| 55 | 58 | 'title' => acym_translation('ACYM_CREATE_USER'), |
| 56 | 59 | 'folder_name' => 'createuser', |
| 57 | - 'version' => '10.0.1', | |
| 60 | + 'version' => '11.1.0', | |
| 58 | 61 | 'active' => '1', |
| 59 | 62 | 'category' => 'User management', |
| 60 | 63 | 'level' => 'starter', |
| 61 | 64 | 'uptodate' => '1', |
| 62 | 65 | 'description' => '- Automatically creates a site user when an AcyMailing subscriber is created', |
| 63 | - 'latest_version' => '10.0.1', | |
| 66 | + 'latest_version' => '11.1.0', | |
| 64 | 67 | 'type' => 'CORE', |
| 65 | 68 | ], |
| 66 | 69 | ]; |
| 67 | 70 | } |
| 68 | 71 | |
| 69 | -function acym_isTrackingSalesActive() | |
| 72 | +function acym_isTrackingSalesActive(): bool | |
| 70 | 73 | { |
| 71 | 74 | $trackingWoocommerce = false; |
| 72 | 75 | acym_trigger('onAcymIsTrackingWoocommerce', [&$trackingWoocommerce], 'plgAcymWoocommerce'); |
| 73 | 76 | |
| @@ -73,9 +76,9 @@ | ||
| 73 | 76 | |
| 74 | 77 | return $trackingWoocommerce; |
| 75 | 78 | } |
| 76 | 79 | |
| 77 | -function acym_loadPlugins() | |
| 80 | +function acym_loadPlugins(): void | |
| 78 | 81 | { |
| 79 | 82 | $dynamicsLoadedLast = ['managetext']; |
| 80 | 83 | $dynamics = acym_getFolders(ACYM_BACK.'dynamics'); |
| 81 | 84 | |
| @@ -104,13 +107,15 @@ | ||
| 104 | 107 | $dynamics[] = $pluginFolder; |
| 105 | 108 | } |
| 106 | 109 | } |
| 107 | 110 | |
| 111 | + // Some plugins need to be called last | |
| 108 | 112 | $dynamics = array_merge($dynamics, $dynamicsLoadedLast); |
| 109 | 113 | |
| 110 | 114 | global $acymPlugins; |
| 111 | 115 | global $acymAddonsForSettings; |
| 112 | 116 | |
| 117 | + // Load the installed integrations | |
| 113 | 118 | $integrationsRaw = []; |
| 114 | 119 | $acyVersion = acym_config()->get('version'); |
| 115 | 120 | do_action_ref_array('acym_load_installed_integrations', [&$integrationsRaw, $acyVersion]); |
| 116 | 121 | |
| @@ -132,8 +137,9 @@ | ||
| 132 | 137 | $dynamicFile = acym_getPluginPath($oneDynamic); |
| 133 | 138 | } |
| 134 | 139 | $className = 'plgAcym'.ucfirst($oneDynamic); |
| 135 | 140 | |
| 141 | + // Load the plugin | |
| 136 | 142 | if (isset($acymPlugins[$className]) || !file_exists($dynamicFile) || (!class_exists($className) && !include_once $dynamicFile)) { |
| 137 | 143 | continue; |
| 138 | 144 | } |
| 139 | 145 | |
| @@ -146,8 +152,9 @@ | ||
| 146 | 152 | if (in_array($oneDynamic, $integrationsClasses)) { |
| 147 | 153 | $pluginClass->addIntegrationIfMissing($plugin); |
| 148 | 154 | } |
| 149 | 155 | |
| 156 | + // If it's for another CMS or if the related extension isn't installed, skip it | |
| 150 | 157 | if (in_array($plugin->cms, ['all', 'WordPress'])) { |
| 151 | 158 | $acymAddonsForSettings[$className] = $plugin; |
| 152 | 159 | } |
| 153 | 160 | |