On this page
get_network( WP_Network|int|null $network = null ): WP_Network|null
Retrieves network data given a network ID or network object.
Description
Network data will be cached and returned after being passed through a filter.
If the provided network is empty, the current network global will be used.
Parameters
$networkWP_Network|int|null Optional-
Network to retrieve. Default is the current network.
Default:
null
Return
WP_Network|null The network object or null if not found.
Source
File: wp-includes/ms-network.php. View all references
function get_network( $network = null ) {
global $current_site;
if ( empty( $network ) && isset( $current_site ) ) {
$network = $current_site;
}
if ( $network instanceof WP_Network ) {
$_network = $network;
} elseif ( is_object( $network ) ) {
$_network = new WP_Network( $network );
} else {
$_network = WP_Network::get_instance( $network );
}
if ( ! $_network ) {
return null;
}
/**
* Fires after a network is retrieved.
*
* @since 4.6.0
*
* @param WP_Network $_network Network data.
*/
$_network = apply_filters( 'get_network', $_network );
return $_network;
}
Hooks
- apply_filters( 'get_network',
WP_Network $_network ) -
Fires after a network is retrieved.
Related
Uses
| Uses | Description |
|---|---|
| WP_Network::__construct() wp-includes/class-wp-network.php | Creates a new WP_Network object. |
| WP_Network::get_instance() wp-includes/class-wp-network.php | Retrieves a network from the database by its ID. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| wpmu_new_site_admin_notification() wp-includes/ms-functions.php | Notifies the Multisite network administrator that a new site was created. |
| wp_initialize_site() wp-includes/ms-site.php | Runs the initialization routine for a given site. |
| get_oembed_response_data_for_url() wp-includes/embed.php | Retrieves the oEmbed response data for a given URL. |
| get_main_site_id() wp-includes/functions.php | Gets the main site ID. |
| get_current_network_id() wp-includes/load.php | Retrieves the current network ID. |
| WP_Network_Query::get_networks() wp-includes/class-wp-network-query.php | Gets a list of networks matching the query vars. |
| get_main_network_id() wp-includes/functions.php | Gets the main network ID. |
| WP_MS_Sites_List_Table::handle_row_actions() wp-admin/includes/class-wp-ms-sites-list-table.php | Generates and displays row action links. |
| WP_MS_Users_List_Table::column_blogs() wp-admin/includes/class-wp-ms-users-list-table.php | Handles the sites column output. |
| retrieve_password() wp-includes/user.php | Handles sending a password retrieval email to a user. |
| signup_another_blog() wp-signup.php | Shows a form for returning users to sign up for another site. |
| signup_user() wp-signup.php | Shows a form for a visitor to sign up for a new user account. |
| show_blog_form() wp-signup.php | Generates and displays the Sign-up and Create Site forms. |
| wpmu_delete_blog() wp-admin/includes/ms.php | Delete a site. |
| populate_network() wp-admin/includes/schema.php | Populate network settings. |
| wp_install_defaults() wp-admin/includes/upgrade.php | Creates the initial content for a newly-installed site. |
| network_site_url() wp-includes/link-template.php | Retrieves the site URL for the current network. |
| network_home_url() wp-includes/link-template.php | Retrieves the home URL for the current network. |
| ms_allowed_http_request_hosts() wp-includes/http.php | Adds any domain in a multisite installation for safe HTTP requests to the allowed list. |
| wp_admin_bar_site_menu() wp-includes/admin-bar.php | Adds the “Site Name” menu. |
| add_new_user_to_blog() wp-includes/ms-functions.php | Adds a newly created user to the appropriate blog |
| fix_phpmailer_messageid() wp-includes/ms-functions.php | Corrects From host on outgoing mail to match the site domain |
| wpmu_welcome_user_notification() wp-includes/ms-functions.php | Notifies a user that their account activation has been successful. |
| redirect_this_site() wp-includes/ms-functions.php | Ensures that the current site’s domain is listed in the allowed redirect host list. |
| install_blog() wp-includes/ms-deprecated.php | Install an empty blog. |
| wpmu_welcome_notification() wp-includes/ms-functions.php | Notifies the site administrator that their site activation was successful. |
| wpmu_validate_blog_signup() wp-includes/ms-functions.php | Processes new site registrations. |
| wp_get_network() wp-includes/ms-load.php | Retrieves an object containing information about the requested network. |
| ms_site_check() wp-includes/ms-load.php | Checks status of current blog. |
| get_dashboard_blog() wp-includes/ms-deprecated.php | Get the “dashboard blog”, the blog where users without a blog edit their profile data. |
| get_id_from_blogname() wp-includes/ms-blogs.php | Retrieves a site’s ID given its (subdomain or directory) slug. |
| ms_cookie_constants() wp-includes/ms-default-constants.php | Defines Multisite cookie constants. |
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_network