blog_id ); self::set_up_site(); restore_current_blog(); } /** * Sets the current site up: the tables, the reason list, the schema version. * * @return void */ private static function set_up_site() { $fresh = false === get_option( 'careback_db_version' ); Database::create_tables(); Reasons::install( new Settings() ); if ( $fresh ) { self::seed_new_site(); } update_option( 'careback_db_version', CAREBACK_DB_VERSION ); } /** * The choices a new install starts with where an update keeps the shop's * own (design of step 6): the details of each item under its name (N-16), * and WooCommerce's returns policy page when it is published (N-13). A key * the site already stores is left as it is. * * @return void */ public static function seed_new_site() { $stored = get_option( CAREBACK_OPTION, array() ); $stored = is_array( $stored ) ? $stored : array(); $seed = array( 'variation_display' => 1, 'returns_policy_page' => Returns_Policy::new_install_page(), ); $missing = array_diff_key( $seed, $stored ); if ( $missing ) { update_option( CAREBACK_OPTION, array_merge( $stored, $missing ) ); } } /** * The sites a network activation sets up: the current one, then the * network's others in the order they were created, NETWORK_SITES in all. * Sites that serve no pages (archived, deleted, spam) are left out. * * @return int[] */ private static function network_sites() { $others = get_sites( array( 'fields' => 'ids', 'network_id' => get_current_network_id(), 'number' => self::NETWORK_SITES, 'orderby' => 'id', 'order' => 'ASC', 'archived' => 0, 'deleted' => 0, 'spam' => 0, ) ); $sites = array_unique( array_map( 'intval', array_merge( array( get_current_blog_id() ), (array) $others ) ) ); return array_slice( array_values( $sites ), 0, self::NETWORK_SITES ); } }