false, 'domain' => false, 'active' => true, 'primary_domain' => false, 'secure' => false, 'stage' => 'checking-dns', 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), ] ); $domain = new Domain($domain_data); $saved = $domain->save(); if (is_wp_error($saved)) { return $saved; } /* * Add the processing. */ wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $domain->get_id()], 'domain'); return $domain; } /** * Restores the original URL for a mapped URL. * * @since 2.0.0 * * @param string $url URL with mapped domain. * @param int $blog_id The blog ID. * @return string */ function wu_restore_original_url($url, $blog_id) { $site = wu_get_site($blog_id); if ($site) { $original_site_url = $site->get_site_url(); $mapped_domain_url = $site->get_active_site_url(); $original_domain = trim(preg_replace('#^https?://#', '', $original_site_url), '/'); $mapped_domain = wp_parse_url($mapped_domain_url, PHP_URL_HOST); if ($original_domain !== $mapped_domain) { $url = str_replace($mapped_domain, $original_domain, $url); } } return $url; } /** * Adds the sso tags to a given URL. * * @since 2.0.11 * * @param string $url The base url to sso-fy. * @return string */ function wu_with_sso($url) { return \WP_Ultimo\SSO\SSO::with_sso($url); } /** * Compares the current domain to the main network domain. * * @since 2.0.11 * @return bool */ function wu_is_same_domain() { global $current_blog, $current_site; return wp_parse_url(wu_get_current_url(), PHP_URL_HOST) === $current_blog->domain && $current_blog->domain === $current_site->domain; }