Ticket #2590: comment_post-edit_redirect.HOOKS.fragments.diff

File comment_post-edit_redirect.HOOKS.fragments.diff, 1.4 kB (added by Libertus, 2 years ago)

My take, adding a simiar filter for edited comments, and automatic redirection to the comment by fragment, which makes WordPress much nicer to use.

  • wp-comments-post.php

    old new  
    5757        setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); 
    5858endif; 
    5959 
    60 $location = ( empty( $_POST['redirect_to'] ) ) ? get_permalink( $comment_post_ID ) : $_POST['redirect_to'];  
    61  
     60$location = ( empty( $_POST['redirect_to'] ) ? get_permalink( $comment_post_ID ) : $_POST['redirect_to'] ) . '#comment-' . $comment_id; 
     61$location = apply_filters('comment_post_redirect', $location, $comment); 
    6262wp_redirect( $location ); 
    6363 
    6464?> 
  • wp-admin/comment.php

    old new  
    192192 
    193193        edit_comment(); 
    194194 
    195         $referredby = $_POST['referredby']; 
    196         if (!empty($referredby)) { 
    197                 header('Location: ' . $referredby); 
    198         } else { 
    199                 header ("Location: edit.php?p=$comment_post_ID&c=1#comments"); 
    200         } 
     195        $location = ( empty( $_POST['referredby'] ) ? "edit.php?p=$comment_post_ID&c=1#comments" : $_POST['referredby'] ) . '#comment-' . $comment_ID; 
     196        $location = apply_filters( 'comment_edit_redirect', $location, $comment_ID ); 
     197        wp_redirect( $location ); 
    201198 
    202199        break; 
    203200default: