-
-
Save katmoody/fae020f8ba2007084db1 to your computer and use it in GitHub Desktop.
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
/* Creates random keys for confirm checkbox */ | |
function generate_confirm_key($length = 50) { | |
$characters = '-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; | |
$randomString = ''; | |
for ($i = 0; $i < $length; $i++) { | |
$randomString .= $characters[rand(0, strlen($characters) - 1)]; | |
} | |
return $randomString; | |
} | |
/* Add comment confirm checkbox */ | |
function insert_comment_checkbox() { | |
echo '<div style="width:100%;height:1px;margin-bottom:20px"></div>'; | |
echo '<input type="checkbox" name="confirm-' . generate_confirm_key() . '" id="confirm-' . generate_confirm_key() . '" value="true" required><label for="confirm-' . generate_confirm_key() . '"><div style="margin-top:-4px;margin-left:4px;color:#CC0000">Confirm</div></label></form>'; | |
} | |
/* Add comment confirm action */ | |
add_action( 'comment_form', 'insert_comment_checkbox' ); | |
/* Add login confirm checkbox */ | |
function insert_login_checkbox() { | |
echo '<p class="forgetmenot"><label for="confirm-' . generate_confirm_key() . '"><input type="checkbox" name="confirm-' . generate_confirm_key() . '" id="confirm-' . generate_confirm_key() . '" value="true" required><label for="confirm-' . generate_confirm_key() . '"> <span style="color:#CC0000">Confirm</span></label></p><br /><br />'; | |
} | |
/* Add login confirm action */ | |
add_action( 'login_form', 'insert_login_checkbox' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment