populate_network_meta() – Creates WordPress network meta and sets the default values.

You appear to be a bot. Output may be restricted

Description

Creates WordPress network meta and sets the default values.

Usage

populate_network_meta( $network_id, $meta );

Parameters

$network_id
( int ) required – Network ID to populate meta for.
$meta
( array ) optional – Optional. Custom meta $key => $value pairs to use. Default empty array.

Returns

void

Source

File name: wordpress/wp-admin/includes/schema.php


Lines:

1 to 100 of 171
function populate_network_meta( $network_id, array $meta = array() ) {
  global $wpdb, $wp_db_version;

  $network_id = (int) $network_id;

  $email             = ! empty( $meta['admin_email'] ) ? $meta['admin_email'] : '';
  $subdomain_install = isset( $meta['subdomain_install'] ) ? (int) $meta['subdomain_install'] : 0;

  // If a user with the provided email does not exist, default to the current user as the new network admin.
  $site_user = ! empty( $email ) ? get_user_by( 'email', $email ) : false;
  if ( false === $site_user ) {
    $site_user = wp_get_current_user();
  }

  if ( empty( $email ) ) {
    $email = $site_user->user_email;
  }

  $template       = get_option( 'template' );
  $stylesheet     = get_option( 'stylesheet' );
  $allowed_themes = array( $stylesheet => true );

  if ( $template != $stylesheet ) {
    $allowed_themes[ $template ] = true;
  }

  if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) {
    $allowed_themes[ WP_DEFAULT_THEME ] = true;
  }

  // If WP_DEFAULT_THEME doesn't exist, also include the latest core default theme.
  if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) {
    $core_default = WP_Theme::WP_Theme::get_core_default_theme();
    if ( $core_default ) {
      $allowed_themes[ $core_default->get_stylesheet() ] = true;
    }
  }

  if ( function_exists( 'clean_network_cache' ) ) {
    clean_network_cache( $network_id );
  } else {
    wp_cache_delete( $network_id, 'networks' );
  }

  if ( ! is_multisite() ) {
    $site_admins = array( $site_user->user_login );
    $users       = get_users(
      array(
        'fields' => array( 'user_login' ),
        'role'   => 'administrator',
      )
    );
    if ( $users ) {
      foreach ( $users as $user ) {
        $site_admins[] = $user->user_login;
      }

      $site_admins = array_unique( $site_admins );
    }
  } else {
    $site_admins = get_site_option( 'site_admins' );
  }

  /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
  $welcome_email = __(
    'Howdy USERNAME,

Your new SITE_NAME site has been successfully set up at:
BLOG_URL

You can log in to the administrator account with the following information:

Username: USERNAME
Password: PASSWORD
Log in here: BLOG_URLwp-login.php

We hope you enjoy your new site. Thanks!

--The Team @ SITE_NAME'
  );

  $misc_exts        = array(
    // Images.
    'jpg',
    'jpeg',
    'png',
    'gif',
    'webp',
    // Video.
    'mov',
    'avi',
    'mpg',
    '3gp',
    '3g2',
    // "audio".
    'midi',
    'mid',
    // Miscellaneous.
    'pdf',
    'doc',

 View on GitHub View on Trac