wp_admin_bar_edit_site_menu

函式
wp_admin_bar_edit_site_menu ( $wp_admin_bar )
引數
  • (WP_Admin_Bar) $wp_admin_bar The WP_Admin_Bar instance.
    Required:
定義位置
相關方法
wp_admin_bar_site_menuwp_admin_bar_edit_menuwp_admin_bar_my_sites_menuwp_admin_bar_updates_menuwp_admin_bar_comments_menu
引入
5.9.0
棄用
-

wp_admin_bar_edit_site_menu: 這個函式用來在WordPress管理欄中新增一個”編輯網站”選單: 該函式需要一個引數:$wp_admin_bar。$wp_admin_bar是WordPress管理欄的例項,該選單應該被新增到其中。

將"編輯網站"連結新增到工具欄。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
// Don't show if a block theme is not activated.
if ( ! wp_is_block_theme() ) {
return;
}
// Don't show for users who can't edit theme options or when in the admin.
if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) {
return;
}
$wp_admin_bar->add_node(
array(
'id' => 'site-editor',
'title' => __( 'Edit site' ),
'href' => admin_url( 'site-editor.php' ),
)
);
}
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) { // Don't show if a block theme is not activated. if ( ! wp_is_block_theme() ) { return; } // Don't show for users who can't edit theme options or when in the admin. if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) { return; } $wp_admin_bar->add_node( array( 'id' => 'site-editor', 'title' => __( 'Edit site' ), 'href' => admin_url( 'site-editor.php' ), ) ); }
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
	// Don't show if a block theme is not activated.
	if ( ! wp_is_block_theme() ) {
		return;
	}

	// Don't show for users who can't edit theme options or when in the admin.
	if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) {
		return;
	}

	$wp_admin_bar->add_node(
		array(
			'id'    => 'site-editor',
			'title' => __( 'Edit site' ),
			'href'  => admin_url( 'site-editor.php' ),
		)
	);
}

常見問題

FAQs
檢視更多 >