| @@ -25,32 +25,38 @@ | ||
| 25 | 25 | protected function enableAction() { |
| 26 | 26 | // Initializing! |
| 27 | 27 | $model = $this->model; |
| 28 | 28 | $cjtWebServer = cssJSToolbox::getCJTWebSiteURL(); |
| 29 | - $extensions =& CJTPlugin::getInstance()->extensions(); | |
| 30 | 29 | // Get all CJT-Plugins (Include CJT Plugin itself + all its extensions) that has activate |
| 31 | 30 | // license key! |
| 32 | 31 | $activeLicenses = $model->getStatedLicenses(); |
| 32 | + // Always REQUEST CJT server even if not key activated yet. | |
| 33 | + // FREE edition will just do normal check @Wordpress:reporioty | |
| 34 | + if (!isset($activeLicenses[CJTSetupModel::EDD_PRODUCT_NAME]) && (CJTPlugin::Edition != 'free')) { | |
| 35 | + $activeLicenses[CJTSetupModel::EDD_PRODUCT_NAME] = array( | |
| 36 | + 'plugin' => array('Version' => CJTPlugin::VERSION, 'AuthorName' => 'CTK'), | |
| 37 | + 'license' => array('key' => str_repeat('0', 32)), | |
| 38 | + 'component' => array('pluginBase' => 'css-javascript-toolbox/css-js-toolbox.php') | |
| 39 | + ); | |
| 40 | + } | |
| 41 | + // Import EDD updater Class! | |
| 42 | + cssJSToolbox::import('framework:third-party:easy-digital-download:auto-upgrade.class.php'); | |
| 33 | 43 | // Activate Automatic upgrade for all activated licenses/components! |
| 34 | 44 | foreach ($activeLicenses as $name => $state) { |
| 35 | - // Get extension def doc. | |
| 36 | - // Act only if extension has XMl DOC! This might happened i fthe extension | |
| 37 | - // removed while its key still in the database | |
| 38 | - if ($extDef = $extensions->getDefDoc(dirname($state['component']['pluginBase']))) { | |
| 39 | - // Check CJT Server only if updateSrc points to Wordpress Repository | |
| 40 | - $updateSrcServer = (string) $extDef->license->attributes()->updateSrc; | |
| 41 | - if (!$updateSrcServer || ($updateSrcServer == 'CJT')) { | |
| 42 | - // Initializingn vars for a single state/component! | |
| 43 | - $pluginFile = ABSPATH . PLUGINDIR . '/' . $state['component']['pluginBase']; | |
| 44 | - $license =& $state['license']; | |
| 45 | - // 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 | - } | |
| 52 | - } | |
| 53 | - } | |
| 45 | + // Initializingn vars for a single state/component! | |
| 46 | + $pluginFile = ABSPATH . PLUGINDIR . '/' . $state['component']['pluginBase']; | |
| 47 | + // Stop using Cached Data as it causes issue, always | |
| 48 | + // get fresh plugin data. | |
| 49 | + $plugin = get_plugin_data($pluginFile); | |
| 50 | + $license =& $state['license']; | |
| 51 | + // Edd API parameter to be send along with he check! | |
| 52 | + $requestParams= array( | |
| 53 | + 'version' => $plugin['Version'], | |
| 54 | + 'author' => $plugin['AuthorName'], | |
| 55 | + 'license' => $license['key'], | |
| 56 | + 'item_name' => $name, | |
| 57 | + ); | |
| 58 | + // Set EDD Automatic Updater! | |
| 59 | + $updated = new CJT_EDD_SL_Plugin_Updater($cjtWebServer, $pluginFile, $requestParams); | |
| 54 | 60 | } |
| 55 | 61 | } |
| 56 | 62 | } // End class. |