Make WordPress Core


Ignore:
Timestamp:
01/14/2024 10:59:48 AM (4 months ago)
Author:
audrasjb
Message:

Administration: Introduce new_admin_email_subject filter.

This changeset introduces the new_admin_email_subject hook which allow developers to filter the subject of the email sent when a change of site admin email address is attempted.

Props MadtownLems, johnbillion, alexanderkoledov, shooper, Marc_J, nikmeyer, xlthlx, devmuhib, nuhel, audrasjb.
Fixes #59250.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesMisc.php

    r51994 r57283  
    2828        }
    2929    }
     30
     31    /**
     32     * @ticket 59520
     33     */
     34    public function test_new_admin_email_subject_filter() {
     35        // Default value
     36        $mailer = tests_retrieve_phpmailer_instance();
     37        update_option_new_admin_email( 'old@example.com', 'new@example.com' );
     38        $this->assertEquals( '[Test Blog] New Admin Email Address', $mailer->get_sent()->subject );
     39
     40        // Filtered value
     41        add_filter(
     42            'new_admin_email_subject',
     43            function () {
     44                return 'Filtered Admin Email Address';
     45            },
     46            10,
     47            1
     48        );
     49
     50        $mailer->mock_sent = array();
     51
     52        $mailer = tests_retrieve_phpmailer_instance();
     53        update_option_new_admin_email( 'old@example.com', 'new@example.com' );
     54        $this->assertEquals( 'Filtered Admin Email Address', $mailer->get_sent()->subject );
     55    }
    3056}
Note: See TracChangeset for help on using the changeset viewer.