Make WordPress Core

Changeset 3721


Ignore:
Timestamp:
04/19/2006 08:02:16 AM (20 years ago)
Author:
matt
Message:

A better comment delete button

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/comment.php

    r3671 r3721  
    1818    }
    1919}
     20
     21if ( isset( $_POST['deletecomment'] ) )
     22    $action = 'deletecomment';
    2023
    2124switch($action) {
     
    8083    echo "<input type='submit' value='" . __('Yes') . "' />";
    8184    echo "&nbsp;&nbsp;";
    82     echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';\" />\n";
     85    echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit-comments.php';\" />\n";
    8386    echo "</form>\n";
    8487    echo "</div>\n";
     
    8790
    8891case 'deletecomment':
     92
     93    check_admin_referer();
     94
     95    $comment = (int) $_REQUEST['comment'];
     96    $p = (int) $_REQUEST['p'];
     97    if ( isset($_REQUEST['noredir']) ) {
     98        $noredir = true;
     99    } else {
     100        $noredir = false;
     101    }
     102
     103    $postdata = get_post($p) or
     104        die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
     105
     106    if ( ! $comment = get_comment($comment) )
     107             die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
     108
     109    if ( !current_user_can('edit_post', $comment->comment_post_ID) )
     110        die( __('You are not allowed to edit comments on this post.') );
     111
     112    if ( 'spam' == $_REQUEST['delete_type'] )
     113        wp_set_comment_status($comment->comment_ID, 'spam');
     114    else
     115        wp_delete_comment($comment->comment_ID);
     116
     117    if (($_SERVER['HTTP_REFERER'] != '') && (false == $noredir)) {
     118        header('Location: ' . $_SERVER['HTTP_REFERER']);
     119    } else {
     120        header('Location: '. get_settings('siteurl') .'/wp-admin/edit-comments.php');
     121    }
     122    exit();
     123    break;
     124
     125case 'unapprovecomment':
    89126
    90127    check_admin_referer();
     
    98135    }
    99136
    100     $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    101 
    102     if ( ! $comment = get_comment($comment) )
    103              die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
    104 
    105     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    106         die( __('You are not allowed to edit comments on this post.') );
    107 
    108     if ( 'spam' == $_GET['delete_type'] )
    109         wp_set_comment_status($comment->comment_ID, 'spam');
    110     else
    111         wp_delete_comment($comment->comment_ID);
     137    if ( ! $comment = get_comment($comment) )
     138        die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
     139
     140    if ( !current_user_can('edit_post', $comment->comment_post_ID) )
     141        die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
     142
     143    wp_set_comment_status($comment->comment_ID, "hold");
    112144
    113145    if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
     
    119151    break;
    120152
    121 case 'unapprovecomment':
     153case 'approvecomment':
    122154
    123155    check_admin_referer();
     
    135167
    136168    if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    137         die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
    138 
    139     wp_set_comment_status($comment->comment_ID, "hold");
    140 
    141     if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
    142         header('Location: ' . $_SERVER['HTTP_REFERER']);
    143     } else {
    144         header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
    145     }
    146     exit();
    147     break;
    148 
    149 case 'approvecomment':
    150 
    151     check_admin_referer();
    152 
    153     $comment = (int) $_GET['comment'];
    154     $p = (int) $_GET['p'];
    155     if (isset($_GET['noredir'])) {
    156         $noredir = true;
    157     } else {
    158         $noredir = false;
    159     }
    160 
    161     if ( ! $comment = get_comment($comment) )
    162         die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    163 
    164     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    165169        die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    166170
     
    196200    break;
    197201} // end switch
     202
    198203include('admin-footer.php');
     204
    199205?>
  • trunk/wp-admin/edit-comments.php

    r3720 r3721  
    124124                    echo '<span class="approve"> | <a href="comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Approve') . '</a> </span>';
    125125                }
    126                 echo " | <a href=\"comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), wp_specialchars( $comment->comment_author, 1 ))  . "' );\">" . __('Mark Comment as Spam') . "</a> ]";
     126                echo " | <a href=\"comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), wp_specialchars( $comment->comment_author, 1 ))  . "' );\">" . __('Spam') . "</a> ]";
    127127            } // end if any comments to show
    128128            // Get post title
  • trunk/wp-admin/edit-form-comment.php

    r3664 r3721  
    1818</script>
    1919<fieldset id="namediv">
    20     <legend><?php _e('Name:') ?></legend>
     20    <legend><label for="name"><?php _e('Name:') ?></label></legend>
    2121    <div>
    22       <input type="text" name="newcomment_author" size="22" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
     22      <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
    2323    </div>
    2424</fieldset>
    2525<fieldset id="emaildiv">
    26         <legend><?php _e('E-mail:') ?></legend>
     26        <legend><label for="email"><?php _e('E-mail:') ?></label></legend>
    2727        <div>
    28           <input type="text" name="newcomment_author_email" size="30" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
     28          <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
    2929    </div>
    3030</fieldset>
    3131<fieldset id="uridiv">
    32         <legend><?php _e('URI:') ?></legend>
     32        <legend><label for="URL"><?php _e('URI:') ?></label></legend>
    3333        <div>
    3434          <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
     
    6060<?php if ( current_user_can('edit_posts') ) : ?>
    6161    <tr>
    62         <th scope="row"><?php _e('Edit time'); ?>:</th>
    63         <td><?php touch_time(('editcomment' == $action), 0); ?></td>
     62        <th scope="row" valign="top"><?php _e('Edit time'); ?>:</th>
     63        <td><?php touch_time(('editcomment' == $action), 0); ?> </td>
    6464    </tr>
    6565<?php endif; ?>
    6666
    6767    <tr>
    68         <th scope="row"><?php _e('Delete'); ?>:</th>
    69         <td><p><a class="delete" href="comment.php?action=confirmdeletecomment&amp;noredir=true&amp;comment=<?php echo $comment->comment_ID; ?>&amp;p=<?php echo $comment->comment_post_ID; ?>"><?php _e('Delete comment') ?></a></p></td>
     68        <th scope="row" valign="top"><?php _e('Delete'); ?>:</th>
     69        <td><input name="deletecomment" class="button" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"return confirm('" . __("You are about to delete this comment \\n  \'Cancel\' to stop, \'OK\' to delete.") . "')\""; ?> />
     70        <input type="hidden" name="comment" value="<?php echo $comment->comment_ID ?>" />
     71        <input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
     72        <input type="hidden" name="noredir" value="1" />
     73    </td>
    7074    </tr>
    7175</table>
  • trunk/wp-admin/post.php

    r3683 r3721  
    1818    }
    1919}
    20 if (isset($_POST['deletepost']))
    21 $action = "delete";
     20
     21if ( isset( $_POST['deletepost'] ) )
     22    $action = 'delete';
    2223
    2324switch($action) {
  • trunk/wp-admin/wp-admin.css

    r3684 r3721  
    469469}
    470470
    471 #deletepost:hover {
     471#deletepost:hover, #deletecomment:hover {
    472472    background: #ce0000;
    473473    color: #fff;
     
    724724.alternate.active .name {
    725725    background: #8B8;
     726}
     727
     728#namediv, #emaildiv, #uridiv {
     729    float: left;
    726730}
    727731
Note: See TracChangeset for help on using the changeset viewer.