Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pippinsplugins/aa687db0c0c81e6305f35279246d6ece to your computer and use it in GitHub Desktop.
Save pippinsplugins/aa687db0c0c81e6305f35279246d6ece to your computer and use it in GitHub Desktop.
Just a quick sample to demonstrate how you could approach asking "Are you sure" when saving a payment
function custom_prefix_warn_about_old_refunds_js() {
if ( ! isset( $_GET['prevent_accidental_refunds_js'] ) ) {
return false;
}
header('Content-Type: application/javascript');
?>
jQuery( document ).on( 'click', '.edd-order-update-box', function() {
if( $('#edd_refund_in_stripe:checked').length > 0 || $('#edd_refund_in_paypal:checked').length ) {
return(
confirm('Are you sure you want to do this?')
);
}
} );
<?php
die();
}
add_action( 'init', 'custom_prefix_warn_about_old_refunds_js' );
function custom_prefix_enqueue_warn_about_old_refunds_js() {
wp_enqueue_script( 'custom_prefix_prevent_accidental_refunds_js', get_bloginfo( 'wpurl' ) . '/?prevent_accidental_refunds_js', array( 'jquery' ) );
}
add_action( 'admin_enqueue_scripts', 'custom_prefix_enqueue_warn_about_old_refunds_js' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment