update_option_new_admin_email( string $old_value, string $value )
- Since
- 3.0.0, 4.9.0
- Source
wp-admin/includes/misc.php:1470
Description
The new site 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 site admin email address.
$valuestring- The proposed new site admin email address.
Performance profile
How much work a call to update_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–116
- 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 124.
Third-party callbacks on 'new_admin_email_content', 'new_admin_email_subject' 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
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - mailsends mail
wp_mail()called directly - cacheobject cache
wp_cache_get()one call below update_option_new_admin_email() - serializeserialisation
maybe_unserialize()one call below update_option_new_admin_email() - transienttransient
get_transient()one call below update_option_new_admin_email()
Further down the call graph this can also reach query. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost update_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_option() |
$value !== false && !is_email() | 12 | get_option(), is_email() |
$value !== false && is_email() | 112 | get_option(), is_email(), time(), wp_rand(), md5(), update_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), self_admin_url(), esc_url(), get_option(), wp_specialchars_decode(), home_url(), get_option(), home_url(), parse_url(), __(), sprintf(), apply_filters(), wp_mail() |
$value !== false && is_email() | 114 | get_option(), is_email(), time(), wp_rand(), md5(), update_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), self_admin_url(), esc_url(), get_option(), wp_specialchars_decode(), home_url(), get_option(), get_option(), wp_specialchars_decode(), __(), sprintf(), apply_filters(), wp_mail() |
$value !== false && is_email() | 114 | get_option(), is_email(), time(), wp_rand(), md5(), update_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), self_admin_url(), esc_url(), get_option(), wp_specialchars_decode(), home_url(), get_option(), home_url(), parse_url(), __(), sprintf(), apply_filters(), wp_mail(), restore_previous_locale() |
$value !== false && is_email() | 116 | get_option(), is_email(), time(), wp_rand(), md5(), update_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), self_admin_url(), esc_url(), get_option(), wp_specialchars_decode(), home_url(), get_option(), get_option(), wp_specialchars_decode(), __(), sprintf(), apply_filters(), wp_mail(), restore_previous_locale() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 124 | 8–116 | 4 | |
| 8.5 | 124 | 8–116 | 4 | |
| 8.4 | 124 | 8–116 | 4 | 15 fewer instructions than PHP 8.3 |
| 8.3 | 139 | 8–131 | 4 | |
| 8.2 | 139 | 8–131 | 4 | |
| 8.1 | 139 | 8–131 | 4 | |
| 7.4 | 139 | 8–131 | 4 |
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 update_option_new_admin_email() runs, in this order:
- apply_filters( new_admin_email_content )filterline 1526 (+56 into the body)
Filters the text of the email sent when a change of site admin email address is attempted.
- apply_filters( new_admin_email_subject )filterline 1554 (+84 into the body)
Filters the subject of the email sent when a change of site admin email address is attempted.
Uses · 15
- get_option()Retrieves an option value based on an option name.
- is_email()Verifies that an email is valid.
- wp_rand()Generates a random non-negative number.
- update_option()Updates the value of an option that was already added.
- 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.
- self_admin_url()Retrieves the URL to the admin area for either the current site or the network depending on context.
- wp_specialchars_decode()Converts a number of HTML entities into their special characters.
Show all 15
- 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.
- restore_previous_locale()Restores the translations according to the previous locale.
Source code
function update_option_new_admin_email( $old_value, $value ) { if ( get_option( 'admin_email' ) === $value || ! is_email( $value ) ) { return; } $hash = md5( $value . time() . wp_rand() ); $new_admin_email = array( 'hash' => $hash, 'newemail' => $value, ); update_option( 'adminhash', $new_admin_email, false ); $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###, Someone with administrator capabilities recently requested to have theadministration email address changed on this site:###SITEURL### To confirm this change, please click on the following link:###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 site 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 site admin email address. * - ###SITENAME### The name of the site. * - ###SITEURL### The URL to the site. * * @since MU (3.0.0) * @since 4.9.0 This filter is no longer Multisite specific. * * @param string $email_text Text in the email. * @param array $new_admin_email { * Data relating to the new site admin email address. * * @type string $hash The secure hash used in the confirmation link URL. * @type string $newemail The proposed new site admin email address. * } */ $content = apply_filters( 'new_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( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content ); $content = str_replace( '###EMAIL###', $value, $content ); $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content ); $content = str_replace( '###SITEURL###', home_url(), $content ); if ( '' !== get_option( 'blogname' ) ) { $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); } else { $site_title = parse_url( home_url(), PHP_URL_HOST ); } $subject = sprintf( /* translators: New admin email address notification email subject. %s: Site title. */ __( '[%s] New Admin Email Address' ), $site_title ); /** * Filters the subject of the email sent when a change of site admin email address is attempted. *Changelog
Introduced in 3.0.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-admin/includes/misc.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.