wp_normalize_site_data( array $data ): array
- Since
- 5.1.0
- Source
wp-includes/ms-site.php:524
Compatibility
- WordPress
- since 5.1.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
$dataarray- Associative array of site data passed to the respective function.
See wp_insert_site() for the possibly included data.
Return value
array- Normalized site data.
Performance profile
How much work a call to wp_normalize_site_data() 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
- Light
- Scaling
- Scales with input
- Instructions
- 12–31
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 47.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
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_normalize_site_data() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$data | 12–23 | none |
$data | 20–31 | trailingslashit() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 47 | 12–31 | 11 | |
| 8.5 | 47 | 12–31 | 11 | |
| 8.4 | 47 | 12–31 | 11 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 53 | 12–37 | 11 | |
| 8.2 | 53 | 12–37 | 11 | |
| 8.1 | 53 | 12–37 | 11 | |
| 7.4 | 53 | 12–37 | 11 |
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.
Uses · 1
- trailingslashit()Appends a trailing slash.
Source code
function wp_normalize_site_data( $data ) { // Sanitize domain if passed. if ( array_key_exists( 'domain', $data ) ) { $data['domain'] = preg_replace( '/[^a-z0-9\-.:]+/i', '', $data['domain'] ); } // Sanitize path if passed. if ( array_key_exists( 'path', $data ) ) { $data['path'] = trailingslashit( '/' . trim( $data['path'], '/' ) ); } // Sanitize network ID if passed. if ( array_key_exists( 'network_id', $data ) ) { $data['network_id'] = (int) $data['network_id']; } // Sanitize status fields if passed. $status_fields = array( 'public', 'archived', 'mature', 'spam', 'deleted' ); foreach ( $status_fields as $status_field ) { if ( array_key_exists( $status_field, $data ) ) { $data[ $status_field ] = (int) $data[ $status_field ]; } } // Strip date fields if empty. $date_fields = array( 'registered', 'last_updated' ); foreach ( $date_fields as $date_field ) { if ( ! array_key_exists( $date_field, $data ) ) { continue; } if ( empty( $data[ $date_field ] ) || '0000-00-00 00:00:00' === $data[ $date_field ] ) { unset( $data[ $date_field ] ); } } return $data;}Changelog
Introduced in 5.1.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-site.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.