wppaste
WordPress

wp_site_admin_email_change_notification( string $old_email, string $new_email, string $option_name )

Since
4.9.0
Source
wp-includes/functions.php:8285
Sends an email to the old site admin email address when the site admin email address changes.

Compatibility

WordPress
since 4.9.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$old_emailstring
The old site admin email address.
$new_emailstring
The new site admin email address.
$option_namestring
The relevant database option name.

Performance profile

How much work a call to wp_site_admin_email_change_notification() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Expensive

Sends mail via wp_mail().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
16–84

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 85.

Plugin surface
2 hooks

Third-party callbacks on 'send_site_admin_email_change_email', 'site_admin_email_change_email' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()called directly
  • mailsends mailwp_mail()called directly
  • cacheobject cachewp_cache_get()one call below wp_site_admin_email_change_notification()
  • serializeserialisationmaybe_unserialize()one call below wp_site_admin_email_change_notification()

Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_site_admin_email_change_notification() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always16–18apply_filters()
always82–84apply_filters(), __(), __(), get_option(), wp_specialchars_decode(), apply_filters(), home_url(), sprintf(), wp_mail()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev8516–843
8.58516–843
8.48516–84312 fewer instructions than PHP 8.3
8.39716–963
8.29716–963
8.19716–963
7.49716–963

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 2

2 hooks fire while wp_site_admin_email_change_notification() runs, in this order:

  1. apply_filters( send_site_admin_email_change_email )filterline 8302 (+17 into the body)

    Filters whether to send the site admin email change notification email.

  2. apply_filters( site_admin_email_change_email )filterline 8355 (+70 into the body)

    Filters the contents of the email notification sent when the site admin email address is changed.

Uses · 6

  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • __()Retrieves the translation of $text.
  • wp_specialchars_decode()Converts a number of HTML entities into their special characters.
  • get_option()Retrieves an option value based on an option name.
  • home_url()Retrieves the URL for the current site where the front end is accessible.
  • wp_mail()Sends an email, similar to PHP's mail function.

Source code

function wp_site_admin_email_change_notification( $old_email, $new_email, $option_name ) {	$send = true; 	// Don't send the notification for an empty email address or the default 'admin_email' value.	if ( empty( $old_email ) || '[email protected]' === $old_email ) {		$send = false;	} 	/**	 * Filters whether to send the site admin email change notification email.	 *	 * @since 4.9.0	 *	 * @param bool   $send      Whether to send the email notification.	 * @param string $old_email The old site admin email address.	 * @param string $new_email The new site admin email address.	 */	$send = apply_filters( 'send_site_admin_email_change_email', $send, $old_email, $new_email ); 	if ( ! $send ) {		return;	} 	/* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */	$email_change_text = __(		'Hi, This notice confirms that the admin email address was changed on ###SITENAME###. The new admin email address is ###NEW_EMAIL###. This email has been sent to ###OLD_EMAIL### Regards,All at ###SITENAME######SITEURL###'	); 	$email_change_email = array(		'to'      => $old_email,		/* translators: Site admin email change notification email subject. %s: Site title. */		'subject' => __( '[%s] Admin Email Changed' ),		'message' => $email_change_text,		'headers' => '',	); 	// Get site name.	$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 	/**	 * Filters the contents of the email notification sent when the site admin email address is changed.	 *	 * @since 4.9.0	 *	 * @param array $email_change_email {	 *     Used to build wp_mail().	 *	 *     @type string $to      The intended recipient.	 *     @type string $subject The subject of the email.	 *     @type string $message The content of the email.	 *         The following strings have a special meaning and will get replaced dynamically:	 *          - `###OLD_EMAIL###` The old site admin email address.	 *          - `###NEW_EMAIL###` The new site admin email address.	 *          - `###SITENAME###`  The name of the site.	 *          - `###SITEURL###`   The URL to the site.	 *     @type string $headers Headers.	 * }	 * @param string $old_email The old site admin email address.	 * @param string $new_email The new site admin email address.	 */	$email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email, $old_email, $new_email ); 	$email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] );	$email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] );	$email_change_email['message'] = str_replace( '###SITENAME###', $site_name, $email_change_email['message'] );	$email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); 	wp_mail(		$email_change_email['to'],		sprintf(

Changelog

Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.