wp_maybe_transition_site_statuses_on_update

函式
wp_maybe_transition_site_statuses_on_update ( $new_site, $old_site = null )
引數
  • (WP_Site) $new_site The site object after the update.
    Required:
  • (WP_Site|null) $old_site Optional. If $new_site has been updated, this must be the previous state of that site. Default null.
    Required:
    Default: null
定義位置
相關方法
wp_maybe_clean_new_site_cache_on_updatewp_transition_post_statuswp_maybe_update_network_site_counts_on_update_transition_post_statuswp_transition_comment_status
引入
5.1.0
棄用
-

wp_maybe_transition_site_statuses_on_update: 當一個網站的狀態被更新時,這個動作被觸發。它檢查狀態是否從私有變為公共,反之亦然,然後相應地更新網站。

觸發對網站狀態更新的動作。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 $value The value of the site status.
*/
do_action( 'update_blog_public', $site_id, $new_site->public );
}
}
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 $value The value of the site status. */ do_action( 'update_blog_public', $site_id, $new_site->public ); } }
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 $value   The value of the site status.
		 */
		do_action( 'update_blog_public', $site_id, $new_site->public );
	}
}

常見問題

FAQs
檢視更多 >