mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
* removed hidden inputs on view mode;
* handle data attribute instead of the hidden input; * WPCS;
This commit is contained in:
@@ -107,9 +107,9 @@ jQuery(document).ready(function() {
|
||||
var form_id = 0;
|
||||
var mode = '';
|
||||
if ( jQuery('div.um-field-image[data-key="' + key + '"]').length === 1 ) {
|
||||
var $formWrapper = jQuery('div.um-field-image[data-key="' + key + '"]').closest('.um-form');
|
||||
form_id = $formWrapper.find('input[name="form_id"]').val();
|
||||
mode = $formWrapper.attr('data-mode');
|
||||
let $formWrapper = jQuery('div.um-field-image[data-key="' + key + '"]').closest('.um-form');
|
||||
form_id = $formWrapper.data('form_id');
|
||||
mode = $formWrapper.data('mode');
|
||||
}
|
||||
|
||||
if ( jQuery('.cropper-hidden').length > 0 && UM.frontend.cropper.obj ) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html(),a=(um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a),jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file"));jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(a)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a,e,t=jQuery(this),i=jQuery(this).attr("data-key"),r=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),u=r.find("img").attr("src"),r=r.find("img").data("file"),d=0,m=(jQuery(this).parents("#um_upload_single").data("user_id")&&(d=jQuery(this).parents("#um_upload_single").data("user_id")),0),n="";1===jQuery('div.um-field-image[data-key="'+i+'"]').length&&(m=(e=jQuery('div.um-field-image[data-key="'+i+'"]').closest(".um-form")).find('input[name="form_id"]').val(),n=e.attr("data-mode")),0<jQuery(".cropper-hidden").length&&UM.frontend.cropper.obj?(e=UM.frontend.cropper.obj.getData(),e=Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height),jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:u,coord:e,user_id:d,key:i,set_id:m,set_mode:n,nonce:um_scripts.nonce},success:function(e){e.success&&(a=new Date,"profile_photo"===i?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+a.getTime()):"cover_photo"===i&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+a.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing"))&&jQuery(".um-cover-overlay").show(),jQuery(".um-single-image-preview[data-key="+i+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+a.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find(".um-btn-auto-width").html(t.attr("data-change")),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(a=new Date,jQuery(".um-single-image-preview[data-key="+i+"]").fadeIn().find("img").attr("src",u+"?"+a.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find(".um-btn-auto-width").html(t.attr("data-change")),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find("input[type=hidden]").val(r))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";jQuery(this).data("modal-size")&&(t=jQuery(this).data("modal-size")),jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery('input[type="hidden"][name="user_id"]').length)&&jQuery("#"+a).attr("data-user_id",jQuery('input[type="hidden"][name="user_id"]').val()),um_new_modal(a,t)})});
|
||||
jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html(),a=(um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a),jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file"));jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(a)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a,e,t=jQuery(this),r=jQuery(this).attr("data-key"),i=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),u=i.find("img").attr("src"),i=i.find("img").data("file"),d=0,m=(jQuery(this).parents("#um_upload_single").data("user_id")&&(d=jQuery(this).parents("#um_upload_single").data("user_id")),0),n="";1===jQuery('div.um-field-image[data-key="'+r+'"]').length&&(m=(e=jQuery('div.um-field-image[data-key="'+r+'"]').closest(".um-form")).data("form_id"),n=e.data("mode")),0<jQuery(".cropper-hidden").length&&UM.frontend.cropper.obj?(e=UM.frontend.cropper.obj.getData(),e=Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height),jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:u,coord:e,user_id:d,key:r,set_id:m,set_mode:n,nonce:um_scripts.nonce},success:function(e){e.success&&(a=new Date,"profile_photo"===r?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+a.getTime()):"cover_photo"===r&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+a.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing"))&&jQuery(".um-cover-overlay").show(),jQuery(".um-single-image-preview[data-key="+r+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+a.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+r+"]").parents(".um-field").find(".um-btn-auto-width").html(t.attr("data-change")),jQuery(".um-single-image-preview[data-key="+r+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(a=new Date,jQuery(".um-single-image-preview[data-key="+r+"]").fadeIn().find("img").attr("src",u+"?"+a.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+r+"]").parents(".um-field").find(".um-btn-auto-width").html(t.attr("data-change")),jQuery(".um-single-image-preview[data-key="+r+"]").parents(".um-field").find("input[type=hidden]").val(i))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";jQuery(this).data("modal-size")&&(t=jQuery(this).data("modal-size")),jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery('input[type="hidden"][name="user_id"]').length)&&jQuery("#"+a).attr("data-user_id",jQuery('input[type="hidden"][name="user_id"]').val()),um_new_modal(a,t)})});
|
||||
@@ -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