Make WordPress Core

Ticket #20045: 20045_disable_user_delete_submit.patch

File 20045_disable_user_delete_submit.patch, 1.8 KB (added by Dan Rivera, 13 years ago)

jquery disables confirm deletion button until radio is selected.

  • wp-admin/users.php

     
    188188
    189189        include ('admin-header.php');
    190190?>
     191<script type="text/javascript">
     192jQuery(document).ready(function($){
     193       
     194        // Disable submit button initially
     195        $('#submit').attr('disabled', 'disabled');
     196       
     197        var delete_option0 = $('#delete_option0'),
     198                delete_option1 = $('#delete_option1');
     199
     200        //Enable submit button when user selects either option
     201        delete_option0.on('change.confirm_delete_user', function(){ updateFormEnabled(); });
     202        delete_option1.on('change.confirm_delete_user', function(){ updateFormEnabled(); });
     203       
     204       
     205        function updateFormEnabled() {
     206               
     207                //enable the submit button
     208                $('#submit').removeAttr('disabled');
     209               
     210                //stop listening to changes
     211                delete_option0.off('change.confirm_delete_user');
     212                delete_option1.off('change.confirm_delete_user');
     213        }
     214
     215});
     216
     217
     218</script>
    191219<form action="" method="post" name="updateusers" id="updateusers">
    192220<?php wp_nonce_field('delete-users') ?>
    193221<?php echo $referer; ?>
     
    214242<?php if ( $go_delete ) : ?>
    215243        <fieldset><p><legend><?php echo _n( 'What should be done with posts and links owned by this user?', 'What should be done with posts and links owned by these users?', $go_delete ); ?></legend></p>
    216244        <ul style="list-style:none;">
    217                 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
     245                <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
    218246                <?php _e('Delete all posts and links.'); ?></label></li>
    219247                <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
    220248                <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>';