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 ? __('Thank you for supporting the future of Sprout Invoices.', 'sprout-invoices') : __('License is not active.', 'sprout-invoices'); $response = array('activated' => $activated, 'response' => $message, 'error' => !$activated); header('Content-type: application/json'); echo wp_json_encode($response); exit; }
?> </h4> <?php _e('An active license for Sprout Invoices provides support and updates. By activating your license, you can get automatic plugin updates from the WordPress dashboard. Updates provide you with the latest bug fixes and the new features each major release brings.', 'sprout-invoices'); ?> </p> </div> <div class="activation_inputs clearfix"> <input type="text" name="<?php echo SI_Updates::LICENSE_KEY_OPTION; ?> " id="<?php echo SI_Updates::LICENSE_KEY_OPTION; ?> " value="<?php echo SI_Updates::license_key(); ?> " class="text-input fat-input <?php echo 'license_' . SI_Updates::license_status(); ?> " size="40"> <?php if (SI_Updates::license_status() != false && SI_Updates::license_status() == 'valid') { ?> <button id="activate_license" class="button button-large" disabled="disabled"><?php _e('Activate License', 'sprout-invoices'); ?> </button> <button id="deactivate_license" class="button button-large"><?php _e('Deactivate License', 'sprout-invoices'); ?>