Created
August 30, 2016 21:00
-
-
Save wpcrmsystem/de1dbfb92da5ff437275a602b2870537 to your computer and use it in GitHub Desktop.
Add license key setting field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add license key settings field | |
function wpcrm_custom_license_field() { | |
//get current tab | |
global $wpcrm_active_tab; | |
if ($wpcrm_active_tab == 'licenses') { | |
//your license key field | |
} | |
} | |
add_action( 'wpcrm_system_license_key_field', 'wpcrm_custom_license_field' ); | |
/*Example license key field from one of our plugins | |
/*Your plugin will need to handle saving the license key, license status, as well as checks for valid licenses on your website | |
------------------------------------------------------------------------------------------------------------------------------*/ | |
$wpcrm_my_plugin_key = get_option( 'wpcrm_my_plugin_license_key' ); | |
$wpcrm_my_plugin_status = get_option( 'wpcrm_my_plugin_license_status' ); | |
?> | |
<tr valign="top"> | |
<th scope="row" valign="top"> | |
<?php _e('My Custom License Key','wp-crm-system'); ?> | |
</th> | |
<td> | |
<input id="wpcrm_license_key" name="wpcrm_license_key" type="text" class="regular-text" value="<?php esc_attr_e( $wpcrm_my_plugin_key ); ?>" /> | |
<label class="description" for="wpcrm_license_key"><?php _e('Enter your license key','wp-crm-system'); ?></label> | |
</td> | |
</tr> | |
<?php if( false !== $wpcrm_my_plugin_key ) { ?> | |
<tr valign="top"> | |
<th scope="row" valign="top"> | |
<?php _e('Activate License','wp-crm-system'); ?> | |
</th> | |
<td> | |
<?php if( $wpcrm_my_plugin_status !== false && $wpcrm_my_plugin_status == 'valid' ) { ?> | |
<span style="color:green;"><?php _e('active'); ?></span> | |
<?php wp_nonce_field( 'wpcrm_plugin_license_nonce', 'wpcrm_plugin_license_nonce' ); ?> | |
<input type="submit" class="button-secondary" name="wpcrm_my_plugin_deactivate" value="<?php _e('Deactivate License','wp-crm-system'); ?>"/> | |
<?php } else { | |
wp_nonce_field( 'wpcrm_plugin_license_nonce', 'wpcrm_plugin_license_nonce' ); ?> | |
<input type="submit" class="button-secondary" name="wpcrm_my_plugin_activate" value="<?php _e('Activate License','wp-crm-system'); ?>"/> | |
<?php } ?> | |
</td> | |
</tr> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment