In the past we have shown you how to add the shortlink menu, draft posts, and other things to the WordPress admin bar. In this article, we will show you how to add the Theme Editor in WordPress Admin Bar.
过去,我们向您展示了如何将短链接菜单 , 草稿帖子和其他内容添加到WordPress管理栏中。 在本文中,我们将向您展示如何在WordPress管理栏中添加主题编辑器。
All you need to do is either open your site-specific plugin or your theme’s functions.php file and paste the following code:
您需要做的就是打开您特定于站点的插件或主题的functions.php文件,然后粘贴以下代码:
// Add Theme Editor to Admin Bar (to save time!)
function admin_bar_theme_editor_option() {
global $wp_admin_bar;
if ( !is_super_admin() || !is_admin_bar_showing() )
return;
$wp_admin_bar->add_menu(
array( 'id' => 'edit-theme',
'title' => __('Edit Theme'),
'href' => admin_url( 'theme-editor.php')
)
);
}
add_action( 'admin_bar_menu', 'admin_bar_theme_editor_option', 100 );
That is it. We found this code floating around on the WordCamp Nashville Hashtag. We tried it on WordPress 3.3.2 and it works. The code should work for other versions as well.
这就对了。 我们发现此代码在WordCamp Nashville Hashtag上浮动。 我们在WordPress 3.3.2上进行了尝试,并且可以正常工作。 该代码也应适用于其他版本。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-the-theme-editor-in-wordpress-admin-bar/