public static function maybe_activate_license() { if (!isset($_REQUEST['security'])) { self::ajax_fail('Forget something?'); } $nonce = $_REQUEST['security']; if (!wp_verify_nonce($nonce, self::NONCE)) { self::ajax_fail('Not going to fall for it!'); } if (!current_user_can('activate_plugins')) { return; } if (!isset($_REQUEST['license'])) { self::ajax_fail('No license key submitted'); } update_option(self::LICENSE_KEY_OPTION, $_REQUEST['license']); self::$license_key = $_REQUEST['license']; $activated = self::activate_license(); $message = $activated ? self::__('Thank you for supporting the future of EDD Segment and Sprout Apps.') : self::__('License is not active.'); $response = array('activated' => $activated, 'response' => $message, 'error' => !$activated); header('Content-type: application/json'); echo json_encode($response); exit; }