| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* | |
| 3 | +* | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| @@ -6,22 +6,22 @@ | ||
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | -* | |
| 10 | +* | |
| 11 | 11 | */ |
| 12 | 12 | class CJTAutoUpgradeController extends CJTController { |
| 13 | - | |
| 13 | + | |
| 14 | 14 | /** |
| 15 | 15 | * put your comment there... |
| 16 | - * | |
| 16 | + * | |
| 17 | 17 | * @var mixed |
| 18 | 18 | */ |
| 19 | 19 | protected $controllerInfo = array('model' => 'setup'); |
| 20 | - | |
| 20 | + | |
| 21 | 21 | /** |
| 22 | 22 | * put your comment there... |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | */ |
| 25 | 25 | protected function enableAction() { |
| 26 | 26 | // Initializing! |
| 27 | 27 | $model = $this->model; |
| @@ -29,8 +29,10 @@ | ||
| 29 | 29 | $extensions =& CJTPlugin::getInstance()->extensions(); |
| 30 | 30 | // Get all CJT-Plugins (Include CJT Plugin itself + all its extensions) that has activate |
| 31 | 31 | // license key! |
| 32 | 32 | $activeLicenses = $model->getStatedLicenses(); |
| 33 | + // Import EDD updater Class! | |
| 34 | + cssJSToolbox::import('framework:third-party:easy-digital-download:auto-upgrade.class.php'); | |
| 33 | 35 | // Activate Automatic upgrade for all activated licenses/components! |
| 34 | 36 | foreach ($activeLicenses as $name => $state) { |
| 35 | 37 | // Get extension def doc. |
| 36 | 38 | // Act only if extension has XMl DOC! This might happened i fthe extension |
| @@ -39,17 +41,22 @@ | ||
| 39 | 41 | // Check CJT Server only if updateSrc points to Wordpress Repository |
| 40 | 42 | $updateSrcServer = (string) $extDef->license->attributes()->updateSrc; |
| 41 | 43 | if (!$updateSrcServer || ($updateSrcServer == 'CJT')) { |
| 42 | 44 | // Initializingn vars for a single state/component! |
| 43 | - $pluginFile = WP_PLUGIN_DIR . '/' . $state['component']['pluginBase']; | |
| 45 | + $pluginFile = ABSPATH . PLUGINDIR . '/' . $state['component']['pluginBase']; | |
| 46 | + // Stop using Cached Data as it causes issue, always | |
| 47 | + // get fresh plugin data. | |
| 48 | + $plugin = get_plugin_data($pluginFile); | |
| 44 | 49 | $license =& $state['license']; |
| 50 | + // Edd API parameter to be send along with he check! | |
| 51 | + $requestParams= array( | |
| 52 | + 'version' => $plugin['Version'], | |
| 53 | + 'author' => $plugin['AuthorName'], | |
| 54 | + 'license' => $license['key'], | |
| 55 | + 'item_name' => $name, | |
| 56 | + ); | |
| 45 | 57 | // Set EDD Automatic Updater! |
| 46 | - try { | |
| 47 | - CJTStoreUpdate::autoUpgrade( $name, $license[ 'key' ], $pluginFile ); | |
| 48 | - } | |
| 49 | - catch ( CJTServicesAPICallException $exception ) { | |
| 50 | - die( 'CJT AUTO-UPGRADE EXCAPTION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' ); | |
| 51 | - } | |
| 58 | + $updated = new CJT_EDD_SL_Plugin_Updater($cjtWebServer, $pluginFile, $requestParams); | |
| 52 | 59 | } |
| 53 | 60 | } |
| 54 | 61 | } |
| 55 | 62 | } |