[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> ms-functions.php (summary)

Multisite WordPress API

File Size: 2823 lines (89 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 62 functions

  get_sitestats()
  get_active_blog_for_user()
  get_user_count()
  get_blog_count()
  get_blog_post()
  add_user_to_blog()
  remove_user_from_blog()
  get_blog_permalink()
  get_blog_id_from_url()
  is_email_address_unsafe()
  wpmu_validate_user_signup()
  wpmu_validate_blog_signup()
  wpmu_signup_blog()
  wpmu_signup_user()
  wpmu_signup_blog_notification()
  wpmu_signup_user_notification()
  wpmu_activate_signup()
  wpmu_create_user()
  wpmu_create_blog()
  newblog_notify_siteadmin()
  newuser_notify_siteadmin()
  domain_exists()
  wpmu_welcome_notification()
  wpmu_welcome_user_notification()
  get_current_site()
  get_most_recent_post_of_user()
  get_dirsize()
  recurse_dirsize()
  check_upload_mimes()
  update_posts_count()
  wpmu_log_new_registrations()
  global_terms()
  redirect_this_site()
  upload_is_file_too_big()
  signup_nonce_fields()
  signup_nonce_check()
  maybe_redirect_404()
  maybe_add_existing_user_to_blog()
  add_existing_user_to_blog()
  add_new_user_to_blog()
  fix_phpmailer_messageid()
  is_user_spammy()
  update_blog_public()
  users_can_register_signup_filter()
  welcome_user_msg_filter()
  force_ssl_content()
  filter_SSL()
  wp_schedule_update_network_counts()
  wp_update_network_counts()
  wp_maybe_update_network_site_counts()
  wp_maybe_update_network_user_counts()
  wp_update_network_site_counts()
  wp_update_network_user_counts()
  get_space_used()
  get_space_allowed()
  get_upload_space_available()
  is_upload_space_available()
  upload_size_limit_filter()
  wp_is_large_network()
  get_subdirectory_reserved_names()
  update_network_option_new_admin_email()
  wp_network_admin_email_change_notification()

Functions
Functions that are not part of a class:

get_sitestats()   X-Ref
Gets the network's site and user counts.

return: array Site and user count for the network.

get_active_blog_for_user( $user_id )   X-Ref
Get one of a user's active blogs

Returns the user's primary blog, if they have one and
it is active. If it's inactive, function returns another
active blog of the user. If none are found, the user
is added as a Subscriber to the Dashboard Blog and that blog
is returned.

return: WP_Site|void The blog object
param: int $user_id The unique ID of the user

get_user_count( $network_id = null )   X-Ref
The number of active users in your installation.

The count is cached and updated twice daily. This is not a live count.

return: int Number of active users on the network.
param: int|null $network_id ID of the network. Default is the current network.

get_blog_count( $network_id = null )   X-Ref
The number of active sites on your installation.

The count is cached and updated twice daily. This is not a live count.

return: int Number of active sites on the network.
param: int|null $network_id ID of the network. Default is the current network.

get_blog_post( $blog_id, $post_id )   X-Ref
Get a blog post from any site on the network.

return: WP_Post|null WP_Post on success or null on failure
param: int $blog_id ID of the blog.
param: int $post_id ID of the post you're looking for.

add_user_to_blog( $blog_id, $user_id, $role )   X-Ref
Adds a user to a blog.

Use the {@see 'add_user_to_blog'} action to fire an event when users are added to a blog.

return: true|WP_Error
param: int    $blog_id ID of the blog you're adding the user to.
param: int    $user_id ID of the user you're adding.
param: string $role    The role you want the user to have

remove_user_from_blog( $user_id, $blog_id = '', $reassign = '' )   X-Ref
Remove a user from a blog.

Use the {@see 'remove_user_from_blog'} action to fire an event when
users are removed from a blog.

Accepts an optional `$reassign` parameter, if you want to
reassign the user's blog posts to another user upon removal.

return: true|WP_Error
param: int    $user_id  ID of the user you're removing.
param: int    $blog_id  ID of the blog you're removing the user from.
param: string $reassign Optional. A user to whom to reassign posts.

get_blog_permalink( $blog_id, $post_id )   X-Ref
Get the permalink for a post on another blog.

return: string The post's permalink
param: int $blog_id ID of the source blog.
param: int $post_id ID of the desired post.

get_blog_id_from_url( $domain, $path = '/' )   X-Ref
Get a blog's numeric ID from its URL.

On a subdirectory installation like example.com/blog1/,
$domain will be the root 'example.com' and $path the
subdirectory '/blog1/'. With subdomains like blog1.example.com,
$domain is 'blog1.example.com' and $path is '/'.

return: int 0 if no blog found, otherwise the ID of the matching blog
param: string $domain
param: string $path   Optional. Not required for subdomain installations.

is_email_address_unsafe( $user_email )   X-Ref
Checks an email address against a list of banned domains.

This function checks against the Banned Email Domains list
at wp-admin/network/settings.php. The check is only run on
self-registrations; user creation at wp-admin/network/users.php
bypasses this check.

return: bool Returns true when the email address is banned.
param: string $user_email The email provided by the user at registration.

wpmu_validate_user_signup( $user_name, $user_email )   X-Ref
Sanitize and validate data required for a user sign-up.

Verifies the validity and uniqueness of user names and user email addresses,
and checks email addresses against admin-provided domain whitelists and blacklists.

The {@see 'wpmu_validate_user_signup'} hook provides an easy way to modify the sign-up
process. The value $result, which is passed to the hook, contains both the user-provided
info and the error messages created by the function. {@see 'wpmu_validate_user_signup'}
allows you to process the data in any way you'd like, and unset the relevant errors if
necessary.

return: array Contains username, email, and error messages.
param: string $user_name  The login name provided by the user.
param: string $user_email The email provided by the user.

wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' )   X-Ref
Processes new site registrations.

Checks the data provided by the user during blog signup. Verifies
the validity and uniqueness of blog paths and domains.

This function prevents the current user from registering a new site
with a blogname equivalent to another user's login name. Passing the
$user parameter to the function, where $user is the other user, is
effectively an override of this limitation.

Filter {@see 'wpmu_validate_blog_signup'} if you want to modify
the way that WordPress validates new site signups.

return: array Contains the new site data and error messages.
param: string         $blogname   The blog name provided by the user. Must be unique.
param: string         $blog_title The blog title provided by the user.
param: WP_User|string $user       Optional. The user object to check against the new site name.

wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array()   X-Ref
Record site signup information for future activation.

param: string $domain     The requested domain.
param: string $path       The requested path.
param: string $title      The requested site title.
param: string $user       The user's requested login name.
param: string $user_email The user's email address.
param: array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.

wpmu_signup_user( $user, $user_email, $meta = array()   X-Ref
Record user signup information for future activation.

This function is used when user registration is open but
new site registration is not.

param: string $user       The user's requested login name.
param: string $user_email The user's email address.
param: array  $meta       Optional. Signup meta data. Default empty array.

wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $user_email, $key, $meta = array()   X-Ref
Send a confirmation request email to a user when they sign up for a new site. The new site will not become active
until the confirmation link is clicked.

This is the notification function used when site registration
is enabled.

Filter {@see 'wpmu_signup_blog_notification'} to bypass this function or
replace it with your own notification behavior.

Filter {@see 'wpmu_signup_blog_notification_email'} and
{@see 'wpmu_signup_blog_notification_subject'} to change the content
and subject line of the email sent to newly registered users.

return: bool
param: string $domain     The new blog domain.
param: string $path       The new blog path.
param: string $title      The site title.
param: string $user_login The user's login name.
param: string $user_email The user's email address.
param: string $key        The activation key created in wpmu_signup_blog()
param: array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.

wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array()   X-Ref
Send a confirmation request email to a user when they sign up for a new user account (without signing up for a site
at the same time). The user account will not become active until the confirmation link is clicked.

This is the notification function used when no new site has
been requested.

Filter {@see 'wpmu_signup_user_notification'} to bypass this function or
replace it with your own notification behavior.

Filter {@see 'wpmu_signup_user_notification_email'} and
{@see 'wpmu_signup_user_notification_subject'} to change the content
and subject line of the email sent to newly registered users.

return: bool
param: string $user_login The user's login name.
param: string $user_email The user's email address.
param: string $key        The activation key created in wpmu_signup_user()
param: array  $meta       Optional. Signup meta data. Default empty array.

wpmu_activate_signup( $key )   X-Ref
Activate a signup.

Hook to {@see 'wpmu_activate_user'} or {@see 'wpmu_activate_blog'} for events
that should happen only when users or sites are self-created (since
those actions are not called when users and sites are created
by a Super Admin).

return: array|WP_Error An array containing information about the activated user and/or blog
param: string $key The activation key provided to the user.

wpmu_create_user( $user_name, $password, $email )   X-Ref
Create a user.

This function runs when a user self-registers as well as when
a Super Admin creates a new user. Hook to {@see 'wpmu_new_user'} for events
that should affect all new users, but only on Multisite (otherwise
use {@see'user_register'}).

return: int|false Returns false on failure, or int $user_id on success
param: string $user_name The new user's login name.
param: string $password  The new user's password.
param: string $email     The new user's email address.

wpmu_create_blog( $domain, $path, $title, $user_id, $options = array()   X-Ref
Create a site.

This function runs when a user self-registers a new site as well
as when a Super Admin creates a new site. Hook to {@see 'wpmu_new_blog'}
for events that should affect all new sites.

On subdirectory installations, $domain is the same as the main site's
domain, and the path is the subdirectory name (eg 'example.com'
and '/blog1/'). On subdomain installations, $domain is the new subdomain +
root domain (eg 'blog1.example.com'), and $path is '/'.

return: int|WP_Error Returns WP_Error object on failure, the new site ID on success.
param: string $domain     The new site's domain.
param: string $path       The new site's path.
param: string $title      The new site's title.
param: int    $user_id    The user ID of the new site's admin.
param: array  $options    Optional. Array of key=>value pairs used to set initial site options.
param: int    $network_id Optional. Network ID. Only relevant on multi-network installations.

newblog_notify_siteadmin( $blog_id, $deprecated = '' )   X-Ref
Notifies the network admin that a new site has been activated.

Filter {@see 'newblog_notify_siteadmin'} to change the content of
the notification email.

return: bool
param: WP_Site|int $blog_id    The new site's object or ID.
param: string      $deprecated Not used.

newuser_notify_siteadmin( $user_id )   X-Ref
Notifies the network admin that a new user has been activated.

Filter {@see 'newuser_notify_siteadmin'} to change the content of
the notification email.

return: bool
param: int $user_id The new user's ID.

domain_exists( $domain, $path, $network_id = 1 )   X-Ref
Checks whether a site name is already taken.

The name is the site's subdomain or the site's subdirectory
path depending on the network settings.

Used during the new site registration process to ensure
that each site name is unique.

return: int|null The site ID if the site name exists, null otherwise.
param: string $domain     The domain to be checked.
param: string $path       The path to be checked.
param: int    $network_id Optional. Network ID. Relevant only on multi-network installations.

wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array()   X-Ref
Notify a user that their blog activation has been successful.

Filter {@see 'wpmu_welcome_notification'} to disable or bypass.

Filter {@see 'update_welcome_email'} and {@see 'update_welcome_subject'} to
modify the content and subject line of the notification email.

return: bool
param: int    $blog_id  Blog ID.
param: int    $user_id  User ID.
param: string $password User password.
param: string $title    Site title.
param: array  $meta     Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.

wpmu_welcome_user_notification( $user_id, $password, $meta = array()   X-Ref
Notify a user that their account activation has been successful.

Filter {@see 'wpmu_welcome_user_notification'} to disable or bypass.

Filter {@see 'update_welcome_user_email'} and {@see 'update_welcome_user_subject'} to
modify the content and subject line of the notification email.

return: bool
param: int    $user_id  User ID.
param: string $password User password.
param: array  $meta     Optional. Signup meta data. Default empty array.

get_current_site()   X-Ref
Get the current network.

Returns an object containing the 'id', 'domain', 'path', and 'site_name'
properties of the network being viewed.

return: WP_Network

get_most_recent_post_of_user( $user_id )   X-Ref
Get a user's most recent post.

Walks through each of a user's blogs to find the post with
the most recent post_date_gmt.

return: array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
param: int $user_id

get_dirsize( $directory )   X-Ref
Get the size of a directory.

A helper function that is used primarily to check whether
a blog has exceeded its allowed upload space.

return: int Size of the directory in MB.
param: string $directory Full path of a directory.

recurse_dirsize( $directory, $exclude = null )   X-Ref
Get the size of a directory recursively.

Used by get_dirsize() to get a directory's size when it contains
other directories.

return: int|false Size in MB if a valid directory. False if not.
param: string $directory Full path of a directory.
param: string $exclude   Optional. Full path of a subdirectory to exclude from the total.

check_upload_mimes( $mimes )   X-Ref
Check an array of MIME types against a whitelist.

WordPress ships with a set of allowed upload filetypes,
which is defined in wp-includes/functions.php in
get_allowed_mime_types(). This function is used to filter
that list against the filetype whitelist provided by Multisite
Super Admins at wp-admin/network/settings.php.

return: array
param: array $mimes

update_posts_count( $deprecated = '' )   X-Ref
Update a blog's post count.

WordPress MS stores a blog's post count as an option so as
to avoid extraneous COUNTs when a blog's details are fetched
with get_site(). This function is called when posts are published
or unpublished to make sure the count stays current.

param: string $deprecated Not used.

wpmu_log_new_registrations( $blog_id, $user_id )   X-Ref
Logs the user email, IP, and registration date of a new site.

param: WP_Site|int $blog_id The new site's object or ID.
param: int|array   $user_id User ID, or array of arguments including 'user_id'.

global_terms( $term_id, $deprecated = '' )   X-Ref
Maintains a canonical list of terms by syncing terms created for each blog with the global terms table.

return: int An ID from the global terms table mapped from $term_id.
param: int    $term_id    An ID for a term on the current blog.
param: string $deprecated Not used.

redirect_this_site( $deprecated = '' )   X-Ref
Ensure that the current site's domain is listed in the allowed redirect host list.

return: array The current site's domain
param: array|string $deprecated Not used.

upload_is_file_too_big( $upload )   X-Ref
Check whether an upload is too big.

return: string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
param: array $upload

signup_nonce_fields()   X-Ref
Add a nonce field to the signup page.


signup_nonce_check( $result )   X-Ref
Process the signup nonce created in signup_nonce_fields().

return: array
param: array $result

maybe_redirect_404()   X-Ref
Correct 404 redirects when NOBLOGREDIRECT is defined.


maybe_add_existing_user_to_blog()   X-Ref
Add a new user to a blog by visiting /newbloguser/{key}/.

This will only work when the user's details are saved as an option
keyed as 'new_user_{key}', where '{key}' is a hash generated for the user to be
added, as when a user is invited through the regular WP Add User interface.


add_existing_user_to_blog( $details = false )   X-Ref
Add a user to a blog based on details from maybe_add_existing_user_to_blog().

return: true|WP_Error|void
param: array $details

add_new_user_to_blog( $user_id, $password, $meta )   X-Ref
Adds a newly created user to the appropriate blog

To add a user in general, use add_user_to_blog(). This function
is specifically hooked into the {@see 'wpmu_activate_user'} action.

param: int   $user_id
param: mixed $password Ignored.
param: array $meta

fix_phpmailer_messageid( $phpmailer )   X-Ref
Correct From host on outgoing mail to match the site domain

param: PHPMailer $phpmailer The PHPMailer instance (passed by reference).

is_user_spammy( $user = null )   X-Ref
Check to see whether a user is marked as a spammer, based on user login.

return: bool
param: string|WP_User $user Optional. Defaults to current user. WP_User object,

update_blog_public( $old_value, $value )   X-Ref
Update this blog's 'public' setting in the global blogs table.

Public blogs have a setting of 1, private blogs are 0.

param: int $old_value
param: int $value     The new public value

users_can_register_signup_filter()   X-Ref
Check whether users can self-register, based on Network settings.

return: bool

welcome_user_msg_filter( $text )   X-Ref
Ensure that the welcome message is not empty. Currently unused.

return: string
param: string $text

force_ssl_content( $force = '' )   X-Ref
Whether to force SSL on content.

return: bool True if forced, false if not forced.
param: bool $force

filter_SSL( $url )   X-Ref
Formats a URL to use https.

Useful as a filter.

return: string URL with https as the scheme
param: string $url URL

wp_schedule_update_network_counts()   X-Ref
Schedule update of the network-wide counts for the current network.


wp_update_network_counts( $network_id = null )   X-Ref
Update the network-wide counts for the current network.

param: int|null $network_id ID of the network. Default is the current network.

wp_maybe_update_network_site_counts( $network_id = null )   X-Ref
Update the count of sites for the current network.

If enabled through the {@see 'enable_live_network_counts'} filter, update the sites count
on a network when a site is created or its status is updated.

param: int|null $network_id ID of the network. Default is the current network.

wp_maybe_update_network_user_counts( $network_id = null )   X-Ref
Update the network-wide users count.

If enabled through the {@see 'enable_live_network_counts'} filter, update the users count
on a network when a user is created or its status is updated.

param: int|null $network_id ID of the network. Default is the current network.

wp_update_network_site_counts( $network_id = null )   X-Ref
Update the network-wide site count.

param: int|null $network_id ID of the network. Default is the current network.

wp_update_network_user_counts( $network_id = null )   X-Ref
Update the network-wide user count.

param: int|null $network_id ID of the network. Default is the current network.

get_space_used()   X-Ref
Returns the space used by the current blog.

return: int Used space in megabytes

get_space_allowed()   X-Ref
Returns the upload quota for the current blog.

return: int Quota in megabytes

get_upload_space_available()   X-Ref
Determines if there is any upload space left in the current blog's quota.

return: int of upload space available in bytes

is_upload_space_available()   X-Ref
Determines if there is any upload space left in the current blog's quota.

return: bool True if space is available, false otherwise.

upload_size_limit_filter( $size )   X-Ref
Filters the maximum upload file size allowed, in bytes.

return: int       Upload size limit in bytes.
param: int $size Upload size limit in bytes.

wp_is_large_network( $using = 'sites', $network_id = null )   X-Ref
Whether or not we have a large network.

The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
Plugins can alter this criteria using the {@see 'wp_is_large_network'} filter.

return: bool True if the network meets the criteria for large. False otherwise.
param: string   $using      'sites or 'users'. Default is 'sites'.
param: int|null $network_id ID of the network. Default is the current network.

get_subdirectory_reserved_names()   X-Ref
Retrieves a list of reserved site on a sub-directory Multisite installation.

return: array $names Array of reserved subdirectory names.

update_network_option_new_admin_email( $old_value, $value )   X-Ref
Send a confirmation request email when a change of network admin email address is attempted.

The new network admin address will not become active until confirmed.

param: string $old_value The old network admin email address.
param: string $value     The proposed new network admin email address.

wp_network_admin_email_change_notification( $option_name, $new_email, $old_email, $network_id )   X-Ref
Send an email to the old network admin email address when the network admin email address changes.

param: string $option_name The relevant database option name.
param: string $new_email   The new network admin email address.
param: string $old_email   The old network admin email address.
param: int    $network_id  ID of the network.



Generated: Wed Nov 21 08:20:01 2018 Cross-referenced by PHPXref 0.7