Skip to content

Instantly share code, notes, and snippets.

@krasenslavov
Last active March 18, 2022 16:08
Show Gist options
  • Save krasenslavov/963ebe0f3d5a2a287d3ac5e3f9527b2e to your computer and use it in GitHub Desktop.
Save krasenslavov/963ebe0f3d5a2a287d3ac5e3f9527b2e to your computer and use it in GitHub Desktop.
API license key plugin form. Visit blog post https://bit.ly/2xlZKGx
<h1>License Key</h1>
<?php if ($error_message):?>
<div class="notice notice-error is-dismissible">
<p><strong><?php echo $error_message;?></strong></p>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php endif; ?>
<?php if ($success_message):?>
<div class="notice notice-success is-dismissible">
<p><strong><?php echo $success_message;?></strong></p>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php endif; ?>
<form action="?page=plugin-name&action=auth" method="post">
<input type="text" id="user" name="user" value="" required />
<input type="password" id="password" name="password" value="" required />
<input type="submit" value="Login" class="button button-primary" />
</form>
<?php if ($logged_in === true) :?>
<?php if (get_option('license_key_is_confirmed')):?>
<form action="?page=plugin-name&action=deactivate" method="post">
<input type="hidden" name="user" value="<?php echo $_POST['user'];?>" />
<input type="hidden" name="password" value="<?php echo $_POST['password'];?>" />
<input type="text" id="pro-licence" name="pro-licence" value="<?php echo $license_key;?>" readonly />
<input type="submit" value="Deactivate License" class="button button-primary" />
</form>
<?php else:?>
<form action="?page=ctrls&action=activate" method="post">
<input type="hidden" name="user" value="<?php echo $_POST['user'];?>" />
<input type="hidden" name="password" value="<?php echo $_POST['password'];?>" />
<input type="text" id="pro-licence" name="pro-licence" value="<?php echo $license_key;?>" readonly />
<input type="submit" value="Activate License" class="button button-primary" />
</form>
<?php endif;?>
<?php endif;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment