| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTAutoUpgradeController extends CJTController { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $controllerInfo = array('model' => 'setup'); |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
*/ |
| 25 |
protected function enableAction() { |
| 26 |
// Initializing! |
| 27 |
$model = $this->model; |
| 28 |
$cjtWebServer = cssJSToolbox::getCJTWebSiteURL(); |
| 29 |
// Get all CJT-Plugins (Include CJT Plugin itself + all its extensions) that has activate |
| 30 |
// license key! |
| 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'); |
| 43 |
// Activate Automatic upgrade for all activated licenses/components! |
| 44 |
foreach ($activeLicenses as $name => $state) { |
| 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); |
| 60 |
} |
| 61 |
} |
| 62 |
} // End class. |
| 63 |
|