Make WordPress Core

Ticket #2615: mailapprovecomment.diff

File mailapprovecomment.diff, 3.9 KB (added by mdawaffe, 20 years ago)

Prompt the user for confirmation on mailapprovecomment

  • wp-includes/functions-formatting.php

     
    9898
    9999function wp_specialchars( $text, $quotes = 0 ) {
    100100        // Like htmlspecialchars except don't double-encode HTML entities
    101         $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);-
     101        $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);
    102102        $text = str_replace('<', '&lt;', $text);
    103103        $text = str_replace('>', '&gt;', $text);
    104104        if ( 'double' === $quotes ) {
  • wp-admin/comment.php

     
    4141        break;
    4242
    4343case 'confirmdeletecomment':
     44case 'mailapprovecomment':
    4445
    4546        require_once('./admin-header.php');
    4647
    4748        $comment = (int) $_GET['comment'];
    4849        $p = (int) $_GET['p'];
     50        $formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
    4951
    5052        if ( ! $comment = get_comment($comment) )
    5153                die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    5254
    5355        if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    54                 die( __('You are not allowed to delete comments on this post.') );
     56                die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    5557
    5658        echo "<div class='wrap'>\n";
    5759        if ( 'spam' == $_GET['delete_type'] )
    5860                echo "<p>" . __('<strong>Caution:</strong> You are about to mark the following comment as spam:') . "</p>\n";
    59         else
     61        elseif ( 'confirmdeletecomment' == $action )
    6062                echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
     63        else
     64                echo "<p>" . __('<strong>Caution:</strong> You are about to approve the following comment:') . "</p>\n";
    6165        echo "<table border='0'>\n";
    6266        echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
    6367        echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
     
    6771        echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
    6872
    6973        echo "<form action='".get_settings('siteurl')."/wp-admin/comment.php' method='get'>\n";
    70         echo "<input type='hidden' name='action' value='deletecomment' />\n";
     74        echo "<input type='hidden' name='action' value='$formaction' />\n";
    7175        if ( 'spam' == $_GET['delete_type'] )
    7276                echo "<input type='hidden' name='delete_type' value='spam' />\n";
    7377        echo "<input type='hidden' name='p' value='$p' />\n";
     
    142146        exit();
    143147        break;
    144148
    145 case 'mailapprovecomment':
    146 
    147         $comment = (int) $_GET['comment'];
    148 
    149         if ( ! $comment = get_comment($comment) )
    150                          die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    151 
    152         if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    153                 die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    154 
    155         if ('1' != $comment->comment_approved) {
    156                 wp_set_comment_status($comment->comment_ID, 'approve');
    157                 if (true == get_option('comments_notify'))
    158                         wp_notify_postauthor($comment->comment_ID);
    159         }
    160 
    161         header('Location: ' . get_option('siteurl') . '/wp-admin/moderation.php?approved=1');
    162         exit();
    163         break;
    164 
    165149case 'approvecomment':
    166150
    167151        check_admin_referer();
  • wp-admin/edit.php

     
    249249        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
    250250        if ($comments) {
    251251        ?>
    252 <h3><?php _e('Comments') ?></h3>
     252<h3 id="comments"><?php _e('Comments') ?></h3>
    253253<ol id="the-list">
    254254<?php
    255255$i = 0;