mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
* removed hidden inputs on view mode;
* handle data attribute instead of the hidden input; * WPCS;
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a form identifier to form
|
||||
@@ -7,13 +9,18 @@
|
||||
* @param $args
|
||||
*/
|
||||
function um_add_form_identifier( $args ) {
|
||||
?>
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( true === UM()->fields()->editing ) {
|
||||
?>
|
||||
<input type="hidden" name="form_id" id="form_id_<?php echo esc_attr( $args['form_id'] ); ?>" value="<?php echo esc_attr( $args['form_id'] ); ?>" />
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action( 'um_after_form_fields', 'um_add_form_identifier' );
|
||||
|
||||
|
||||
/**
|
||||
* Adds a spam timestamp
|
||||
*
|
||||
@@ -22,30 +29,35 @@ add_action( 'um_after_form_fields', 'um_add_form_identifier' );
|
||||
function um_add_security_checks( $args ) {
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<p class="<?php echo esc_attr( UM()->honeypot ); ?>_name">
|
||||
<label for="<?php echo esc_attr( UM()->honeypot ) . '_' . $args['form_id']; ?>"><?php _e( 'Only fill in if you are not human' ); ?></label>
|
||||
<input type="hidden" name="<?php echo esc_attr( UM()->honeypot ); ?>" id="<?php echo esc_attr( UM()->honeypot ) . '_' . $args['form_id']; ?>" class="input" value="" size="25" autocomplete="off" />
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
if ( true === UM()->fields()->editing ) {
|
||||
?>
|
||||
<p class="<?php echo esc_attr( UM()->honeypot ); ?>_name">
|
||||
<label for="<?php echo esc_attr( UM()->honeypot . '_' . $args['form_id'] ); ?>"><?php esc_html_e( 'Only fill in if you are not human' ); ?></label>
|
||||
<input type="hidden" name="<?php echo esc_attr( UM()->honeypot ); ?>" id="<?php echo esc_attr( UM()->honeypot . '_' . $args['form_id'] ); ?>" class="input" value="" size="25" autocomplete="off" />
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action( 'um_after_form_fields', 'um_add_security_checks' );
|
||||
add_action( 'um_account_page_hidden_fields', 'um_add_security_checks' );
|
||||
|
||||
|
||||
/**
|
||||
* Makes the honeypot invisible
|
||||
*/
|
||||
function um_add_form_honeypot_css() {
|
||||
?>
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
if ( true === UM()->fields()->editing ) {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.<?php echo esc_attr( UM()->honeypot ); ?>_name {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action( 'wp_head', 'um_add_form_honeypot_css' );
|
||||
|
||||
@@ -54,11 +66,11 @@ add_action( 'wp_head', 'um_add_form_honeypot_css' );
|
||||
*/
|
||||
function um_add_form_honeypot_js() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery( window ).on( 'load', function() {
|
||||
jQuery('input[name="<?php echo esc_js( UM()->honeypot ); ?>"]').val('');
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
jQuery( window ).on( 'load', function() {
|
||||
jQuery('input[name="<?php echo esc_js( UM()->honeypot ); ?>"]').val('');
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'wp_footer', 'um_add_form_honeypot_js', 99999999999999999 );
|
||||
add_action( 'wp_footer', 'um_add_form_honeypot_js', 99999999999999999 );
|
||||
|
||||
Reference in New Issue
Block a user