Triggers actions on site status updates.
Parameters
Source
function wp_maybe_transition_site_statuses_on_update( $new_site, $old_site = null ) {
$site_id = $new_site->id;
// Use the default values for a site if no previous state is given.
if ( ! $old_site ) {
$old_site = new WP_Site( new stdClass() );
}
if ( $new_site->spam !== $old_site->spam ) {
if ( '1' === $new_site->spam ) {
/**
* Fires when the 'spam' status is added to a site.
*
* @since MU (3.0.0)
*
* @param int $site_id Site ID.
*/
do_action( 'make_spam_blog', $site_id );
} else {
/**
* Fires when the 'spam' status is removed from a site.
*
* @since MU (3.0.0)
*
* @param int $site_id Site ID.
*/
do_action( 'make_ham_blog', $site_id );
}
}
if ( $new_site->mature !== $old_site->mature ) {
if ( '1' === $new_site->mature ) {
/**
* Fires when the 'mature' status is added to a site.
*
* @since 3.1.0
*
* @param int $site_id Site ID.
*/
do_action( 'mature_blog', $site_id );
} else {
/**
* Fires when the 'mature' status is removed from a site.
*
* @since 3.1.0
*
* @param int $site_id Site ID.
*/
do_action( 'unmature_blog', $site_id );
}
}
if ( $new_site->archived !== $old_site->archived ) {
if ( '1' === $new_site->archived ) {
/**
* Fires when the 'archived' status is added to a site.
*
* @since MU (3.0.0)
*
* @param int $site_id Site ID.
*/
do_action( 'archive_blog', $site_id );
} else {
/**
* Fires when the 'archived' status is removed from a site.
*
* @since MU (3.0.0)
*
* @param int $site_id Site ID.
*/
do_action( 'unarchive_blog', $site_id );
}
}
if ( $new_site->deleted !== $old_site->deleted ) {
if ( '1' === $new_site->deleted ) {
/**
* Fires when the 'deleted' status is added to a site.
*
* @since 3.5.0
*
* @param int $site_id Site ID.
*/
do_action( 'make_delete_blog', $site_id );
} else {
/**
* Fires when the 'deleted' status is removed from a site.
*
* @since 3.5.0
*
* @param int $site_id Site ID.
*/
do_action( 'make_undelete_blog', $site_id );
}
}
if ( $new_site->public !== $old_site->public ) {
/**
* Fires after the current blog's 'public' setting is updated.
*
* @since MU (3.0.0)
*
* @param int $site_id Site ID.
* @param string $is_public Whether the site is public. A numeric string,
* for compatibility reasons. Accepts '1' or '0'.
*/
do_action( 'update_blog_public', $site_id, $new_site->public );
}
}
Hooks
- do_action( ‘archive_blog’,
int $site_id ) Fires when the ‘archived’ status is added to a site.
- do_action( ‘make_delete_blog’,
int $site_id ) Fires when the ‘deleted’ status is added to a site.
- do_action( ‘make_ham_blog’,
int $site_id ) Fires when the ‘spam’ status is removed from a site.
- do_action( ‘make_spam_blog’,
int $site_id ) Fires when the ‘spam’ status is added to a site.
- do_action( ‘make_undelete_blog’,
int $site_id ) Fires when the ‘deleted’ status is removed from a site.
- do_action( ‘mature_blog’,
int $site_id ) Fires when the ‘mature’ status is added to a site.
- do_action( ‘unarchive_blog’,
int $site_id ) Fires when the ‘archived’ status is removed from a site.
- do_action( ‘unmature_blog’,
int $site_id ) Fires when the ‘mature’ status is removed from a site.
- do_action( ‘update_blog_public’,
int $site_id ,string $is_public ) Fires after the current blog’s ‘public’ setting is updated.
Changelog
Version | Description |
---|---|
5.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.