wp_network_admin_email_change_notification( string $option_name, string $new_email, string $old_email, int $network_id )
- Since
- 4.9.0
- Source
wp-includes/ms-functions.php:2812
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
$option_namestring- The relevant database option name.
$new_emailstring- The new network admin email address.
$old_emailstring- The old network admin email address.
$network_idint- ID of the network.
Performance profile
How much work a call to wp_network_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
- Scaling
- Constant
- Instructions
- 17–85
- Plugin surface
- 2 hooks
- Called by
- 0
Sends mail via wp_mail().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 86.
Third-party callbacks on 'send_network_admin_email_change_email', 'network_admin_email_change_email' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionnetwork option
get_site_option()called directly - mailsends mail
wp_mail()called directly
Further down the call graph this can also reach cache, serialize, 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_network_admin_email_change_notification() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 17–18 | apply_filters() |
| always | 84–85 | apply_filters(), __(), __(), get_site_option(), wp_specialchars_decode(), apply_filters(), home_url(), sprintf(), wp_mail() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 86 | 17–85 | 2 | |
| 8.5 | 86 | 17–85 | 2 | |
| 8.4 | 86 | 17–85 | 2 | 12 fewer instructions than PHP 8.3 |
| 8.3 | 98 | 17–97 | 2 | |
| 8.2 | 98 | 17–97 | 2 | |
| 8.1 | 98 | 17–97 | 2 | |
| 7.4 | 98 | 17–97 | 2 |
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_network_admin_email_change_notification() runs, in this order:
- apply_filters( send_network_admin_email_change_email )filterline 2830 (+18 into the body)
Filters whether to send the network admin email change notification email.
- apply_filters( network_admin_email_change_email )filterline 2883 (+71 into the body)
Filters the contents of the email notification sent when the network 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_site_option()Retrieve an option value for the current network based on name of option.
- 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_network_admin_email_change_notification( $option_name, $new_email, $old_email, $network_id ) { $send = true; // Don't send the notification to the default 'admin_email' value. if ( '[email protected]' === $old_email ) { $send = false; } /** * Filters whether to send the network admin email change notification email. * * @since 4.9.0 * * @param bool $send Whether to send the email notification. * @param string $old_email The old network admin email address. * @param string $new_email The new network admin email address. * @param int $network_id ID of the network. */ $send = apply_filters( 'send_network_admin_email_change_email', $send, $old_email, $new_email, $network_id ); 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 network admin email address was changed on ###SITENAME###. The new network 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: Network admin email change notification email subject. %s: Network title. */ 'subject' => __( '[%s] Network Admin Email Changed' ), 'message' => $email_change_text, 'headers' => '', ); // Get network name. $network_name = wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ); /** * Filters the contents of the email notification sent when the network 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 network admin email address. * - ###NEW_EMAIL### The new network admin email address. * - ###SITENAME### The name of the network. * - ###SITEURL### The URL to the site. * @type string $headers Headers. * } * @param string $old_email The old network admin email address. * @param string $new_email The new network admin email address. * @param int $network_id ID of the network. */ $email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id ); $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###', $network_name, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); wp_mail( $email_change_email['to'],Changelog
Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/ms-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.