|
10 | 10 | * @copyright KestutisIT |
11 | 11 | * @license MIT License |
12 | 12 | */ |
13 | | - |
14 | | -// Enable or disable this test. If not testing at the moment - disable the test |
15 | | -$testEnabled = TRUE; |
16 | | -if(!$testEnabled) |
17 | | -{ |
18 | | - die('Test is disabled'); |
19 | | -} |
20 | | - |
21 | | -// Require Php 5.4 or newer |
22 | | -if (version_compare(phpversion(), '5.4.0', '<')) |
23 | | -{ |
24 | | - die('Php 5.4 or newer is required. Please upgrade your Php version first.'); |
25 | | -} |
26 | | - |
27 | | -// Start a session |
28 | | -// Note: Requires Php 5.4+ |
29 | | -if(session_status() !== PHP_SESSION_ACTIVE) |
30 | | -{ |
31 | | - session_start(); |
32 | | -} |
33 | | - |
34 | | -$wpBlogHeaderFilePath = '../'; |
35 | | - |
36 | | -define('WP_USE_THEMES', FALSE); // This is a test class, so we don't need to load |
37 | | -require_once($wpBlogHeaderFilePath.'wp-blog-header.php'); // Note: adapt to match your path |
38 | | -require_once(ABSPATH . '/Libraries/EnvatoAPIManager.php'); |
| 13 | +defined( 'ABSPATH' ) or die( 'No script kiddies, please!' ); |
39 | 14 |
|
40 | 15 | if(isset($_POST['envato_check'])) |
41 | 16 | { |
|
157 | 132 |
|
158 | 133 |
|
159 | 134 | // 3. Status of Purchased Plugin ID |
160 | | - $pluginUpdateAvailable = $objToolkit->checkPurchasedItemUpdateAvailable($sanitizedTargetPluginId, $sanitizedInstalledPluginVersion); |
| 135 | + $availablePluginVersion = $objToolkit->getAvailableVersion($sanitizedTargetPluginId); |
| 136 | + $pluginUpdateAvailable = version_compare($sanitizedInstalledPluginVersion, $availablePluginVersion, '<'); |
161 | 137 | // View vars |
162 | 138 | $targetPluginId = intval($sanitizedTargetPluginId); // Ready for print |
163 | 139 | $installedPluginVersion = esc_html($sanitizedInstalledPluginVersion); // Ready for print |
164 | 140 | $nameOfTargetPluginId = esc_html($objToolkit->getItemName($sanitizedTargetPluginId)); |
165 | | - $availablePluginVersion = $objToolkit->getAvailableVersion($sanitizedTargetPluginId); |
| 141 | + // It will return the download link only if the update is available, and it is not yet exceeded downloads limit |
166 | 142 | $pluginUpdateDownloadUrl = $pluginUpdateAvailable ? $objToolkit->getDownloadUrlIfPurchased($sanitizedTargetPluginId) : ''; |
167 | 143 |
|
168 | 144 | // 4. Status of Purchased Theme ID |
169 | | - $themeUpdateAvailable = $objToolkit->checkPurchasedItemUpdateAvailable($sanitizedTargetThemeId, $sanitizedInstalledThemeVersion); |
| 145 | + $availableThemeVersion = $objToolkit->getAvailableVersion($sanitizedTargetThemeId); |
| 146 | + $themeUpdateAvailable = version_compare($sanitizedInstalledThemeVersion, $availableThemeVersion, '<'); |
170 | 147 | // View vars |
171 | 148 | $targetThemeId = intval($sanitizedTargetThemeId); // Ready for print |
172 | 149 | $installedThemeVersion = esc_html($sanitizedInstalledThemeVersion); // Ready for print |
173 | 150 | $nameOfTargetThemeId = esc_html($objToolkit->getItemName($sanitizedTargetThemeId)); |
174 | | - $availableThemeVersion = $objToolkit->getAvailableVersion($sanitizedTargetThemeId); |
| 151 | + // It will return the download link only if the update is available, and it is not yet exceeded downloads limit |
175 | 152 | $themeUpdateDownloadUrl = $themeUpdateAvailable ? $objToolkit->getDownloadUrlIfPurchased($sanitizedTargetThemeId) : ''; |
176 | 153 |
|
177 | 154 | // 5. Envato Item Id of Purchased Plugin |
|
184 | 161 | $targetThemeAuthor = esc_html($sanitizedTargetThemeAuthor); // Ready for print |
185 | 162 | $foundThemeId = $objToolkit->getItemIdByThemeAndAuthorIfPurchased($sanitizedTargetThemeName, $sanitizedTargetThemeAuthor); |
186 | 163 |
|
187 | | - $goBackUrl = pathinfo(__FILE__, PATHINFO_FILENAME).'.php'; |
| 164 | + $goBackUrl = 'index.php'; |
188 | 165 | require('template.TestResults.php'); |
189 | 166 | } else |
190 | 167 | { |
|
0 commit comments