Make WordPress Core


Ignore:
Timestamp:
01/27/2020 04:31:48 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Comments: Add In reply to: %s parent comment link to new comment email notifications.

This information was previously available on the Moderate Comment screen in the admin, but was missing from moderation emails.

Props imath, danieltj, andraganescu, galbaras, SergeyBiryukov.
Fixes #43805. See #43429.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment.php

    r46586 r47114  
    77    protected static $user_id;
    88    protected static $post_id;
     9    protected static $notify_message = '';
    910
    1011    public function setUp() {
     
    433434        $sent = wp_new_comment_notify_postauthor( $c );
    434435        $this->assertFalse( $sent );
     436    }
     437
     438    /**
     439     * @ticket 43805
     440     */
     441    public function test_wp_new_comment_notify_postauthor_content_should_include_link_to_parent() {
     442        $c1 = self::factory()->comment->create(
     443            array(
     444                'comment_post_ID' => self::$post_id,
     445            )
     446        );
     447
     448        $c2 = self::factory()->comment->create(
     449            array(
     450                'comment_post_ID' => self::$post_id,
     451                'comment_parent'  => $c1,
     452            )
     453        );
     454
     455        add_filter( 'comment_notification_text', array( $this, 'save_comment_notification_text' ) );
     456        wp_new_comment_notify_postauthor( $c2 );
     457        remove_filter( 'comment_notification_text', array( $this, 'save_comment_notification_text' ) );
     458
     459        $this->assertContains( admin_url( "comment.php?action=editcomment&c={$c1}" ), self::$notify_message );
     460    }
     461
     462    /**
     463     * @ticket 43805
     464     */
     465    public function test_wp_new_comment_notify_moderator_content_should_include_link_to_parent() {
     466        $c1 = self::factory()->comment->create(
     467            array(
     468                'comment_post_ID' => self::$post_id,
     469            )
     470        );
     471
     472        $c2 = self::factory()->comment->create(
     473            array(
     474                'comment_post_ID'  => self::$post_id,
     475                'comment_parent'   => $c1,
     476                'comment_approved' => '0',
     477            )
     478        );
     479
     480        add_filter( 'comment_moderation_text', array( $this, 'save_comment_notification_text' ) );
     481        wp_new_comment_notify_moderator( $c2 );
     482        remove_filter( 'comment_moderation_text', array( $this, 'save_comment_notification_text' ) );
     483
     484        $this->assertContains( admin_url( "comment.php?action=editcomment&c={$c1}" ), self::$notify_message );
     485    }
     486
     487    /**
     488     * Callback for the `comment_notification_text` & `comment_moderation_text` filters.
     489     *
     490     * @param string $notify_message The comment notification or moderation email text.
     491     * @return string
     492     */
     493    public function save_comment_notification_text( $notify_message = '' ) {
     494        self::$notify_message = $notify_message;
     495        return $notify_message;
    435496    }
    436497
Note: See TracChangeset for help on using the changeset viewer.