Exemple #1
0
/**
 * Callback function for test_1_key field
 *
 * @since 1.2
 */
function test_1_key_callback()
{
    $license = get_option('test_1_license_key');
    $status = get_option('test_1_license_status');
    ?>

  <label>
		<input type="text" id="test_1_license_key" class="regular-text" name="test_1_license_key" value="<?php 
    echo esc_attr($license);
    ?>
"/>
		<span style="vertical-align: middle;" class="dashicons dashicons-admin-network"></span> <?php 
    echo __('Enter your license key', 'test1');
    ?>
	</label>

		<div id="test-1-reponse" style="width:600px; padding-top:1em;">

			<?php 
    if (false !== $license) {
        if ($status !== false && $status == 'valid') {
            $license_data = get_transient('_test_1_license_data');
            echo test_1_action_remove_license($license_data->expires);
        } elseif ($status === false or $status != 'invalid') {
            echo test_1_action_add_license();
        }
    }
    ?>

		</div>

<?php 
}
Exemple #2
0
/**
 * Activate license
 *
 * @since 1.2
 */
function test_1_activate_license()
{
    $license = trim(get_option('test_1_license_key'));
    $nonce = $_POST['test_1_nonce'];
    // run a quick security check
    if (!wp_verify_nonce($nonce, 'test-1-nonce')) {
        wp_die(__('Cheatin&#8217; uh?', 'test1'));
    }
    $license_data = test_1_edd_software_call('activate_license', $license);
    update_option('test_1_license_status', $license_data->license);
    if ($license_data->license == 'valid') {
        set_transient('_test_1_license_data', $license_data, DAY_IN_SECONDS);
        delete_transient('_test_1_license_error');
        echo test_1_action_remove_license($license_data->expires);
    } else {
        set_transient('_test_1_license_error', $license_data->error);
        echo '<p style="color:red;"><span class="dashicons dashicons-info"></span> ' . test_1_ajax_notices() . '</p>';
    }
    die;
}