wp_admin_bar_updates_menu

函数
wp_admin_bar_updates_menu ( $wp_admin_bar )
参数
  • (WP_Admin_Bar) $wp_admin_bar The WP_Admin_Bar instance.
    Required:
定义位置
相关方法
wp_admin_bar_site_menuwp_admin_bar_wp_menuwp_admin_bar_my_sites_menuwp_admin_bar_edit_menuwp_admin_bar_edit_site_menu
引入
3.1.0
弃用
-

wp_admin_bar_updates_menu: 这个函数用来在WordPress管理栏的”更新”菜单中添加一个自定义菜单: 该函数接受一个参数数组,包括菜单的ID、标签和项目。

如果有主题/插件/核心的更新,提供一个更新链接。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_admin_bar_updates_menu( $wp_admin_bar ) {
$update_data = wp_get_update_data();
if ( ! $update_data['counts']['total'] ) {
return;
}
$updates_text = sprintf(
/* translators: %s: Total number of updates available. */
_n( '%s update available', '%s updates available', $update_data['counts']['total'] ),
number_format_i18n( $update_data['counts']['total'] )
);
$icon = '<span class="ab-icon" aria-hidden="true"></span>';
$title = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
$title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>';
$wp_admin_bar->add_node(
array(
'id' => 'updates',
'title' => $icon . $title,
'href' => network_admin_url( 'update-core.php' ),
)
);
}
function wp_admin_bar_updates_menu( $wp_admin_bar ) { $update_data = wp_get_update_data(); if ( ! $update_data['counts']['total'] ) { return; } $updates_text = sprintf( /* translators: %s: Total number of updates available. */ _n( '%s update available', '%s updates available', $update_data['counts']['total'] ), number_format_i18n( $update_data['counts']['total'] ) ); $icon = '<span class="ab-icon" aria-hidden="true"></span>'; $title = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; $title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>'; $wp_admin_bar->add_node( array( 'id' => 'updates', 'title' => $icon . $title, 'href' => network_admin_url( 'update-core.php' ), ) ); }
function wp_admin_bar_updates_menu( $wp_admin_bar ) {

	$update_data = wp_get_update_data();

	if ( ! $update_data['counts']['total'] ) {
		return;
	}

	$updates_text = sprintf(
		/* translators: %s: Total number of updates available. */
		_n( '%s update available', '%s updates available', $update_data['counts']['total'] ),
		number_format_i18n( $update_data['counts']['total'] )
	);

	$icon   = '<span class="ab-icon" aria-hidden="true"></span>';
	$title  = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
	$title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>';

	$wp_admin_bar->add_node(
		array(
			'id'    => 'updates',
			'title' => $icon . $title,
			'href'  => network_admin_url( 'update-core.php' ),
		)
	);
}

常见问题

FAQs
查看更多 >