site_admin_notice

函式
site_admin_notice ( No parameters )
返回值
  • (void|false) Void on success. False if the current user is not a super admin.
定義位置
相關方法
is_site_adminwpmu_new_site_admin_notificationnew_user_email_admin_noticewp_print_admin_notice_templatesprint_admin_styles
引入
3.0.0
棄用
-

site_admin_notice:這個鉤子允許你在WordPress的管理儀表盤上新增一個自定義的資訊。你可以使用這個鉤子來顯示重要的通知、警告或任何其他你想傳達給你網站管理使用者的資訊。

顯示一個管理員通知,在核心升級後升級所有站點。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function site_admin_notice() {
global $wp_db_version, $pagenow;
if ( ! current_user_can( 'upgrade_network' ) ) {
return false;
}
if ( 'upgrade.php' === $pagenow ) {
return;
}
if ( (int) get_site_option( 'wpmu_upgrade_site' ) !== $wp_db_version ) {
echo "<div class='update-nag notice notice-warning inline'>" . sprintf(
/* translators: %s: URL to Upgrade Network screen. */
__( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ),
esc_url( network_admin_url( 'upgrade.php' ) )
) . '</div>';
}
}
function site_admin_notice() { global $wp_db_version, $pagenow; if ( ! current_user_can( 'upgrade_network' ) ) { return false; } if ( 'upgrade.php' === $pagenow ) { return; } if ( (int) get_site_option( 'wpmu_upgrade_site' ) !== $wp_db_version ) { echo "<div class='update-nag notice notice-warning inline'>" . sprintf( /* translators: %s: URL to Upgrade Network screen. */ __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . '</div>'; } }
function site_admin_notice() {
	global $wp_db_version, $pagenow;

	if ( ! current_user_can( 'upgrade_network' ) ) {
		return false;
	}

	if ( 'upgrade.php' === $pagenow ) {
		return;
	}

	if ( (int) get_site_option( 'wpmu_upgrade_site' ) !== $wp_db_version ) {
		echo "<div class='update-nag notice notice-warning inline'>" . sprintf(
			/* translators: %s: URL to Upgrade Network screen. */
			__( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ),
			esc_url( network_admin_url( 'upgrade.php' ) )
		) . '</div>';
	}
}

常見問題

FAQs
檢視更多 >