
2020年最新版本WordPress本地环境搭建与安装教程
wp_admin_bar_edit_site_menu ( $wp_admin_bar )
wp_admin_bar_edit_site_menu: 这个函数用来在WordPress管理栏中添加一个”编辑网站”菜单: 该函数需要一个参数:$wp_admin_bar。$wp_admin_bar是WordPress管理栏的实例,该菜单应该被添加到其中。
将"编辑网站"链接添加到工具栏。
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' ), ) ); }