Files
ultimatemember/includes/core/um-actions-global.php
T

66 lines
1.8 KiB
PHP
Raw Normal View History

2018-03-20 13:24:38 +02:00
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2017-12-18 15:36:04 +02:00
2016-01-31 09:39:02 -08:00
2018-03-20 13:24:38 +02:00
/**
* Adds a form identifier to form
*
* @param $args
*/
function um_add_form_identifier( $args ) {
?>
<input type="hidden" name="form_id" id="form_id_<?php echo esc_attr( $args['form_id'] ); ?>" value="<?php echo esc_attr( $args['form_id'] ); ?>" />
2018-03-20 13:24:38 +02:00
<?php
}
add_action( 'um_after_form_fields', 'um_add_form_identifier' );
2014-12-15 22:38:07 +02:00
2016-01-31 09:39:02 -08:00
2018-03-20 13:24:38 +02:00
/**
* Adds a spam timestamp
*
* @param $args
*/
function um_add_security_checks( $args ) {
if ( is_admin() ) {
return;
} ?>
2016-01-31 09:39:02 -08:00
<input type="hidden" name="timestamp" class="um_timestamp" value="<?php echo esc_attr( current_time( 'timestamp' ) ) ?>" />
2016-01-31 09:39:02 -08:00
<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="text" name="<?php echo esc_attr( UM()->honeypot ); ?>" id="<?php echo esc_attr( UM()->honeypot ) . '_' . $args['form_id']; ?>" class="input" value="" size="25" autocomplete="off" />
2018-03-20 13:24:38 +02:00
</p>
2016-01-31 09:39:02 -08:00
2015-11-05 19:51:31 +08:00
<?php
2018-03-20 13:24:38 +02:00
}
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() {
?>
<style type="text/css">
.<?php echo esc_attr( UM()->honeypot ); ?>_name {
2018-03-20 13:24:38 +02:00
display: none !important;
}
</style>
<?php
}
add_action( 'wp_head', 'um_add_form_honeypot_css' );
/**
* Empty the honeypot value
*/
function um_add_form_honeypot_js() {
?>
<script type="text/javascript">
2020-03-02 13:38:36 +02:00
jQuery(window).load(function() {
jQuery("input[name='<?php echo esc_js( UM()->honeypot ); ?>']").val('');
});
2018-03-20 13:24:38 +02:00
</script>
<?php
}
add_action( 'wp_footer', 'um_add_form_honeypot_js', 99999999999999999 );