[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

Site/blog functions that work with the blogs table and related data.

File Size: 924 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 wp-includes/ms-site.php
 wp-includes/ms-network.php

Defines 26 functions

  wpmu_update_blogs_date()
  get_blogaddress_by_id()
  get_blogaddress_by_name()
  get_id_from_blogname()
  get_blog_details()
  refresh_blog_details()
  update_blog_details()
  clean_site_details_cache()
  get_blog_option()
  add_blog_option()
  delete_blog_option()
  update_blog_option()
  switch_to_blog()
  restore_current_blog()
  wp_switch_roles_and_user()
  ms_is_switched()
  is_archived()
  update_archived()
  update_blog_status()
  get_blog_status()
  get_last_updated()
  _update_blog_date_on_post_publish()
  _update_blog_date_on_post_delete()
  _update_posts_count_on_delete()
  _update_posts_count_on_transition_post_status()
  wp_count_sites()

Functions
Functions that are not part of a class:

wpmu_update_blogs_date()   X-Ref
Update the last_updated field for the current site.

since: MU (3.0.0)

get_blogaddress_by_id( $blog_id )   X-Ref
Get a full blog URL, given a blog ID.

return: string Full URL of the blog if found. Empty string if not.
param: int $blog_id Blog ID.
since: MU (3.0.0)

get_blogaddress_by_name( $blogname )   X-Ref
Get a full blog URL, given a blog name.

return: string
param: string $blogname The (subdomain or directory) name
since: MU (3.0.0)

get_id_from_blogname( $slug )   X-Ref
Retrieves a sites ID given its (subdomain or directory) slug.

return: int|null The site ID, or null if no site is found for the given slug.
param: string $slug A site's slug.
since: MU (3.0.0)
since: 4.7.0 Converted to use `get_sites()`.

get_blog_details( $fields = null, $get_all = true )   X-Ref
Retrieve the details for a blog from the blogs table and blog options.

return: WP_Site|false Blog details on success. False on failure.
param: int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
param: bool             $get_all Whether to retrieve all details or only the details in the blogs table.
since: MU (3.0.0)

refresh_blog_details( $blog_id = 0 )   X-Ref
Clear the blog details cache.

param: int $blog_id Optional. Blog ID. Defaults to current blog.
since: MU (3.0.0)

update_blog_details( $blog_id, $details = array()   X-Ref
Update the details for a blog. Updates the blogs table for a given blog ID.

return: bool True if update succeeds, false otherwise.
param: int   $blog_id Blog ID.
param: array $details Array of details keyed by blogs table field names.
since: MU (3.0.0)

clean_site_details_cache( $site_id = 0 )   X-Ref
Cleans the site details cache for a site.

param: int $site_id Optional. Site ID. Default is the current site ID.
since: 4.7.4

get_blog_option( $id, $option, $default = false )   X-Ref
Retrieve option value for a given blog id based on name of option.

If the option does not exist or does not have a value, then the return value
will be false. This is useful to check whether you need to install an option
and is commonly used during installation of plugin options and to test
whether upgrading is required.

If the option was serialized then it will be unserialized when it is returned.

return: mixed Value set for the option.
param: int    $id      A blog ID. Can be null to refer to the current blog.
param: string $option  Name of option to retrieve. Expected to not be SQL-escaped.
param: mixed  $default Optional. Default value to return if the option does not exist.
since: MU (3.0.0)

add_blog_option( $id, $option, $value )   X-Ref
Add a new option for a given blog ID.

You do not need to serialize values. If the value needs to be serialized, then
it will be serialized before it is inserted into the database. Remember,
resources can not be serialized or added as an option.

You can create options without values and then update the values later.
Existing options will not be updated and checks are performed to ensure that you
aren't adding a protected WordPress option. Care should be taken to not name
options the same as the ones which are protected.

return: bool True if the option was added, false otherwise.
param: int    $id     A blog ID. Can be null to refer to the current blog.
param: string $option Name of option to add. Expected to not be SQL-escaped.
param: mixed  $value  Optional. Option value, can be anything. Expected to not be SQL-escaped.
since: MU (3.0.0)

delete_blog_option( $id, $option )   X-Ref
Removes option by name for a given blog ID. Prevents removal of protected WordPress options.

return: bool True if the option was deleted, false otherwise.
param: int    $id     A blog ID. Can be null to refer to the current blog.
param: string $option Name of option to remove. Expected to not be SQL-escaped.
since: MU (3.0.0)

update_blog_option( $id, $option, $value, $deprecated = null )   X-Ref
Update an option for a particular blog.

return: bool True if the value was updated, false otherwise.
param: int    $id         The blog ID.
param: string $option     The option key.
param: mixed  $value      The option value.
param: mixed  $deprecated Not used.
since: MU (3.0.0)

switch_to_blog( $new_blog_id, $deprecated = null )   X-Ref
Switch the current blog.

This function is useful if you need to pull posts, or other information,
from other blogs. You can switch back afterwards using restore_current_blog().

Things that aren't switched:
- plugins. See #14941

return: true Always returns true.
param: int  $new_blog_id The ID of the blog to switch to. Default: current blog.
param: bool $deprecated  Not used.
since: MU (3.0.0)

restore_current_blog()   X-Ref
Restore the current blog, after calling switch_to_blog().

return: bool True on success, false if we're already on the current blog.
since: MU (3.0.0)

wp_switch_roles_and_user( $new_site_id, $old_site_id )   X-Ref
Switches the initialized roles and current user capabilities to another site.

param: int $new_site_id New site ID.
param: int $old_site_id Old site ID.
since: 4.9.0

ms_is_switched()   X-Ref
Determines if switch_to_blog() is in effect

return: bool True if switched, false otherwise.
since: 3.5.0

is_archived( $id )   X-Ref
Check if a particular blog is archived.

return: string Whether the blog is archived or not.
param: int $id Blog ID.
since: MU (3.0.0)

update_archived( $id, $archived )   X-Ref
Update the 'archived' status of a particular blog.

return: string $archived
param: int    $id       Blog ID.
param: string $archived The new status.
since: MU (3.0.0)

update_blog_status( $blog_id, $pref, $value, $deprecated = null )   X-Ref
Update a blog details field.

return: string|false $value
param: int    $blog_id    Blog ID.
param: string $pref       Field name.
param: string $value      Field value.
param: null   $deprecated Not used.
since: MU (3.0.0)
since: 5.1.0 Use wp_update_site() internally.

get_blog_status( $id, $pref )   X-Ref
Get a blog details field.

return: bool|string|null $value
param: int    $id   Blog ID.
param: string $pref Field name.
since: MU (3.0.0)

get_last_updated( $deprecated = '', $start = 0, $quantity = 40 )   X-Ref
Get a list of most recently updated blogs.

return: array The list of blogs.
param: mixed $deprecated Not used.
param: int   $start      Optional. Number of blogs to offset the query. Used to build LIMIT clause.
param: int   $quantity   Optional. The maximum number of blogs to retrieve. Default 40.
since: MU (3.0.0)

_update_blog_date_on_post_publish( $new_status, $old_status, $post )   X-Ref
Handler for updating the site's last updated date when a post is published or
an already published post is changed.

param: string  $new_status The new post status.
param: string  $old_status The old post status.
param: WP_Post $post       Post object.
since: 3.3.0

_update_blog_date_on_post_delete( $post_id )   X-Ref
Handler for updating the current site's last updated date when a published
post is deleted.

param: int $post_id Post ID
since: 3.4.0

_update_posts_count_on_delete( $post_id )   X-Ref
Handler for updating the current site's posts count when a post is deleted.

param: int $post_id Post ID.
since: 4.0.0

_update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null )   X-Ref
Handler for updating the current site's posts count when a post status changes.

param: string  $new_status The status the post is changing to.
param: string  $old_status The status the post is changing from.
param: WP_Post $post       Post object
since: 4.0.0
since: 4.9.0 Added the `$post` parameter.

wp_count_sites( $network_id = null )   X-Ref
Count number of sites grouped by site status.

return: int[] {
param: int $network_id Optional. The network to get counts for. Default is the current network ID.
since: 5.3.0



Generated: Sat Apr 27 01:00:02 2024 Cross-referenced by PHPXref 0.7.1