Networks and Sites: Introduce `populate_site_meta` filter.

The `populate_site_meta` filter can be used to modify the site meta added during the creation of a new site. This filter mirrors the approach used for networks in `populate_network_meta`.

Props spacedmonkey, davidbaumwald.
Fixes #46437.

git-svn-id: https://develop.svn.wordpress.org/trunk@44912 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2019-03-15 19:42:40 +00:00
parent d5820a5324
commit 02d3de004c
1 changed files with 11 additions and 1 deletions

View File

@ -1316,8 +1316,18 @@ function populate_site_meta( $site_id, array $meta = array() ) {
return;
}
/**
* Filters meta for a site on creation.
*
* @since 5.2.0
*
* @param array $meta Associative array of site meta keys and values to be inserted.
* @param int $site_id ID of site to populate.
*/
$site_meta = apply_filters( 'populate_site_meta', $meta, $site_id );
$insert = '';
foreach ( $meta as $meta_key => $meta_value ) {
foreach ( $site_meta as $meta_key => $meta_value ) {
if ( is_array( $meta_value ) ) {
$meta_value = serialize( $meta_value );
}