Ejemplo n.º 1
0
 public static function action_savecomment()
 {
     check_ajax_referer('wp-ajax-edit-comments_save-comment');
     $postID = AECAjax::get_post_id();
     $commentID = AECAjax::get_comment_id();
     AECAjax::maybe_change_comment_status($commentID, $postID);
     $comment = get_comment($commentID, ARRAY_A);
     $comment['comment_content'] = trim(urldecode($_POST['comment_content']));
     if (AECCore::can_edit_name($commentID, $postID)) {
         $comment['comment_author'] = trim(strip_tags(urldecode($_POST['comment_author'])));
     }
     if (AECCore::can_edit_email($commentID, $postID)) {
         $comment['comment_author_email'] = trim(strip_tags(urldecode($_POST['comment_author_email'])));
     }
     if (AECCore::can_edit_url($commentID, $postID)) {
         $comment['comment_author_url'] = trim(strip_tags(urldecode($_POST['comment_author_url'])));
         //Quick JS Test
         if ($comment['comment_author_email'] == "undefined") {
             $comment['comment_author_email'] = '';
         }
         if ($comment['comment_author_url'] == "undefined") {
             $comment['comment_author_url'] = 'http://';
         }
         if ($comment['comment_author'] == "undefined") {
             $comment['comment_author'] = '';
         }
     }
     //For the date function
     if (isset($_POST['aa'])) {
         $aa = (int) urldecode($_POST['aa']);
         $mm = (int) urldecode($_POST['mm']);
         $jj = (int) urldecode($_POST['jj']);
         $hh = (int) urldecode($_POST['hh']);
         $mn = (int) urldecode($_POST['mn']);
         $ss = (int) urldecode($_POST['ss']);
         $jj = $jj > 31 ? 31 : $jj;
         $hh = $hh > 23 ? $hh - 24 : $hh;
         $mn = $mn > 59 ? $mn - 60 : $mn;
         $ss = $ss > 59 ? $ss - 60 : $ss;
         $comment['comment_date'] = "{$aa}-{$mm}-{$jj} {$hh}:{$mn}:{$ss}";
     }
     $response = AECAjax::save_comment($commentID, $postID, $comment);
     $response = apply_filters('wp_ajax_comments_save_comment', $response, $comment, $_POST);
     die(json_encode($response));
 }
    ?>
      <?php 
    if (AECCore::can_edit_email($commentID, $postID)) {
        ?>
      <tr>
        <td><label for="e-mail"><?php 
        _e('E-mail', "ajaxEdit");
        ?>
</label></td>
        <td><span> : </span><input type="text" size="35" name="e-mail" id="e-mail" /></td>
      </tr>
      <?php 
    }
    ?>
      <?php 
    if (AECCore::can_edit_url($commentID, $postID)) {
        ?>
      <tr>
        <td><label for="URL"><?php 
        _e('URL', "ajaxEdit");
        ?>
</label></td>
        <td><span> : </span><input type="text" size="35" name="URL" id="URL" /></td>
      </tr>
      <?php 
    }
    ?>
    </tbody>
    </table>
    <table><tbody>
    <?php