Title: wp_normalize_site_data
Published: February 22, 2019
Last modified: February 24, 2026

---

# wp_normalize_site_data( array $data ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#wp--skip-link--target)

Normalizes data for a site prior to inserting or updating in the database.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#parameters)󠁿

 `$data`arrayrequired

Associative array of site data passed to the respective function.
 See [wp_insert_site()](https://developer.wordpress.org/reference/functions/wp_insert_site/)
for the possibly included data.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#return)󠁿

 array Normalized site data.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#source)󠁿

    ```php
    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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/ms-site.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/ms-site.php#L524)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/ms-site.php#L524-L561)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#related)󠁿

| Uses | Description | 
| [trailingslashit()](https://developer.wordpress.org/reference/functions/trailingslashit/)`wp-includes/formatting.php` |

Appends a trailing slash.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_normalize_site_data/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_normalize_site_data%2F)
before being able to contribute a note or feedback.