update_network_option_new_admin_email( string $old_value, string $value )
- Since
- 4.9.0
- Source
wp-includes/ms-functions.php:2781
Description
The new network admin address will not become active until confirmed.
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_valuestring- The old network admin email address.
$valuestring- The proposed new network admin email address.
Performance profile
How much work a call to update_network_option_new_admin_email() 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
- 8–102
- Plugin surface
- 1 hook
- 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 103.
Third-party callbacks on 'new_network_admin_email_content' 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
- optionnetwork option
get_site_option()called directly - hookthird-party callbacks
apply_filters()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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost update_network_option_new_admin_email() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$value === false | 8 | get_site_option() |
$value !== false && !is_email() | 12 | get_site_option(), is_email() |
$value !== false && is_email() | 100 | get_site_option(), is_email(), time(), mt_rand(), md5(), update_site_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), network_admin_url(), esc_url(), get_site_option(), wp_specialchars_decode(), network_home_url(), __(), get_site_option(), wp_specialchars_decode(), sprintf(), wp_mail() |
$value !== false && is_email() | 102 | get_site_option(), is_email(), time(), mt_rand(), md5(), update_site_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), network_admin_url(), esc_url(), get_site_option(), wp_specialchars_decode(), network_home_url(), __(), get_site_option(), wp_specialchars_decode(), sprintf(), wp_mail(), restore_previous_locale() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 103 | 8–102 | 3 | |
| 8.5 | 103 | 8–102 | 3 | |
| 8.4 | 103 | 8–102 | 3 | 15 fewer instructions than PHP 8.3 |
| 8.3 | 118 | 8–117 | 3 | |
| 8.2 | 118 | 8–117 | 3 | |
| 8.1 | 118 | 8–117 | 3 | |
| 7.4 | 118 | 8–117 | 3 |
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 · 1
One hook fires while update_network_option_new_admin_email() runs, in this order:
- apply_filters( new_network_admin_email_content )filterline 2835 (+54 into the body)
Filters the text of the email sent when a change of network admin email address is attempted.
Uses · 14
- get_site_option()Retrieve an option value for the current network based on name of option.
- is_email()Verifies that an email is valid.
- update_site_option()Updates the value of an option that was already added for the current network.
- switch_to_user_locale()Switches the translations according to the given user's locale.
- get_current_user_id()Gets the current user's ID.
- __()Retrieves the translation of $text.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_get_current_user()Retrieves the current user object.
- esc_url()Checks and cleans a URL.
- network_admin_url()Retrieves the URL to the admin area for the network.
- wp_specialchars_decode()Converts a number of HTML entities into their special characters.
- network_home_url()Retrieves the home URL for the current network.
Show all 14
- wp_mail()Sends an email, similar to PHP's mail function.
- restore_previous_locale()Restores the translations according to the previous locale.
Source code
function update_network_option_new_admin_email( $old_value, $value ) { if ( get_site_option( 'admin_email' ) === $value || ! is_email( $value ) ) { return; } $hash = md5( $value . time() . mt_rand() ); $new_admin_email = array( 'hash' => $hash, 'newemail' => $value, ); update_site_option( 'network_admin_hash', $new_admin_email ); $switched_locale = switch_to_user_locale( get_current_user_id() ); /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ $email_text = __( 'Howdy ###USERNAME###, You recently requested to have the network admin email address onyour network changed. If this is correct, please click on the following link to change it:###ADMIN_URL### You can safely ignore and delete this email if you do not want totake this action. This email has been sent to ###EMAIL### Regards,All at ###SITENAME######SITEURL###' ); /** * Filters the text of the email sent when a change of network admin email address is attempted. * * The following strings have a special meaning and will get replaced dynamically: * ###USERNAME### The current user's username. * ###ADMIN_URL### The link to click on to confirm the email change. * ###EMAIL### The proposed new network admin email address. * ###SITENAME### The name of the network. * ###SITEURL### The URL to the network. * * @since 4.9.0 * * @param string $email_text Text in the email. * @param array $new_admin_email { * Data relating to the new network admin email address. * * @type string $hash The secure hash used in the confirmation link URL. * @type string $newemail The proposed new network admin email address. * } */ $content = apply_filters( 'new_network_admin_email_content', $email_text, $new_admin_email ); $current_user = wp_get_current_user(); $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); $content = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content ); $content = str_replace( '###EMAIL###', $value, $content ); $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content ); $content = str_replace( '###SITEURL###', network_home_url(), $content ); wp_mail( $value, sprintf( /* translators: Email change notification email subject. %s: Network title. */ __( '[%s] Network Admin Email Change Request' ), wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ) ), $content ); if ( $switched_locale ) { restore_previous_locale(); }}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.8.8 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.