├── README.md ├── readme.txt ├── wp-toolbar-experiments.css ├── wp-toolbar-experiments.js └── wp-toolbar-experiments.php /README.md: -------------------------------------------------------------------------------- 1 | # WP Toolbar Experiments 2 | 3 | This is a plugin to facilitate testing of various potential UX changes to the WordPress toolbar. It is not meant to be a plugin that is distributed and in use unless specifically being tested. 4 | 5 | Some ideas include: 6 | 7 | * Auditing the current contents to ensure we are including what is most useful for the majority. 8 | * Including the complete admin menu as a dropdown. 9 | * Adding [jQuery Menu Aim](https://github.com/kamens/jQuery-menu-aim) for better interaction with flyouts. 10 | * Investigating better touch interaction. 11 | * A closer look at the HTML/CSS. 12 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === WP Toolbar Experiments === 2 | Contributors: helen, celloexpressions, wordpressdotorg 3 | Tags: toolbar, admin bar, experiments 4 | Requires at least: 4.3 5 | Tested up to: 4.3 6 | Stable tag: 0.1 7 | Description: Experiments with the toolbar. 8 | License: GPLv2 9 | 10 | == Description == 11 | This plugin is a WordPress core feature-plugin to test and iterate on proposed changes to the toolbar. Expanding on initial work done on core trac: https://core.trac.wordpress.org/ticket/32678. 12 | 13 | Development is happening on GitHub: https://github.com/helenhousandi/wp-toolbar-experiments 14 | 15 | If you're interested in contributing to this project, jump in on GitHub or join the #design channel in WordPress core Slack. 16 | 17 | == Installation == 18 | 1. Install through the WordPress plugin installer OR 19 | 1. Download the .zip file and upload the unzipped folder to the `/wp-content/plugins/` directory 20 | 1. Activate the plugin through the 'Plugins' menu in WordPress 21 | 1. The revisions to the toolbar will be visible in the admin and the front-end. 22 | 1. Leave feedback on the proposed changes on GitHub: https://github.com/helenhousandi/wp-toolbar-experiments. 23 | 24 | == Changelog == 25 | = 0.1 = 26 | * Initial port from https://core.trac.wordpress.org/attachment/ticket/32678/32678.5.diff. 27 | * Needs some CSS tweaking, then should be ready for iterations and testing. 28 | 29 | == Upgrade Notice == 30 | = 0.1 = 31 | * Initial import from core patch. 32 | -------------------------------------------------------------------------------- /wp-toolbar-experiments.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Toolbar Experiments 3 | * 4 | * Ported from https://core.trac.wordpress.org/attachment/ticket/32678/32678.5.diff 5 | */ 6 | 7 | #wpadminbar #wp-admin-bar-menu-toggle a { 8 | margin-left: 0; 9 | } 10 | 11 | #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { 12 | content: '\f120'; 13 | font: normal 20px/46px 'Dashicons'; 14 | } 15 | 16 | #wpadminbar > #wp-toolbar li.hover > a span.ab-label, 17 | #wpadminbar > #wp-toolbar li:hover > a span.ab-label, 18 | #wpadminbar > #wp-toolbar a:focus > span.ab-label { 19 | color: #00b9eb; 20 | } 21 | 22 | #wpadminbar li:hover > a .ab-icon:before, 23 | #wpadminbar li:hover > .ab-item:before, 24 | #wpadminbar li a:focus > .ab-icon:before { 25 | color: #00b9eb; 26 | } 27 | 28 | #wpadminbar #wp-admin-bar-menu-toggle a:hover, 29 | #wpadminbar #wp-admin-bar-menu-toggle a:focus { 30 | background: #32373c; 31 | } 32 | 33 | #wpadminbar #wp-admin-bar-my-sites > .ab-item:before, 34 | #wpadminbar #wp-admin-bar-site-name > .ab-item:before, 35 | #wpadminbar #wp-admin-bar-appearance { 36 | margin-top: 0; 37 | } 38 | 39 | #wpadminbar #wp-admin-bar-site-name-default { 40 | padding: 11px 0; 41 | } 42 | 43 | #wpadminbar #wp-admin-bar-themes { 44 | margin-top: 11px; 45 | } 46 | 47 | #wpadminbar #wp-admin-bar-my-sites > .ab-item:before { 48 | content: '\f112'; 49 | top: 2px; 50 | } 51 | 52 | #wpadminbar #wp-admin-bar-view > .ab-item:before { 53 | content: '\f177'; 54 | top: 2px; 55 | } 56 | 57 | #wpadminbar #wp-admin-bar-site-name > .ab-item:before { 58 | content: "\f120"; 59 | top: 2px; 60 | } 61 | 62 | #wpadminbar #wp-admin-bar-visit-site > .ab-item:before { 63 | content: "\f102"; 64 | left: 1px; 65 | top: 1px; 66 | margin-right: 8px; 67 | } 68 | 69 | #wpadminbar #wp-admin-bar-dashboard .ab-icon:before { 70 | top: -4px; 71 | } 72 | 73 | #wpadminbar #wp-admin-bar-dashboard-toggle { 74 | display: none; 75 | } 76 | 77 | /** 78 | * Admin Menu 79 | */ 80 | #wpadminbar #wp-admin-bar-admin.ab-submenu { 81 | padding: 0; 82 | } 83 | 84 | #wp-admin-bar-site-name .ab-sub-wrapper { 85 | width: 160px; 86 | } 87 | 88 | #wp-admin-bar-site-name ul .ab-item { 89 | font-size: 18px; 90 | } 91 | 92 | #wpadminbar #wp-admin-bar-site-name ul > li > .ab-item { 93 | font-size: 14px; 94 | line-height: 18px; 95 | padding: 0; 96 | min-height: 34px; 97 | } 98 | 99 | #wpadminbar #wp-admin-bar-site-name ul > li> .ab-item .ab-label { 100 | height: auto; 101 | display: inline-block; 102 | font-size: 14px; 103 | line-height: 14px; 104 | padding: 10px 0; 105 | } 106 | 107 | #wpadminbar > #wp-toolbar #wp-admin-bar-site-name ul > li > .ab-item .ab-icon { 108 | padding: 0; 109 | width: 34px; 110 | text-align: center; 111 | margin-right: 0; 112 | } 113 | 114 | #wpadminbar > #wp-toolbar #wp-admin-bar-site-name ul > li > .ab-item .ab-icon:before { 115 | line-height: 40px; 116 | display: inline-block; 117 | } 118 | 119 | 120 | /** 121 | * Comments 122 | */ 123 | #wp-admin-bar-site-name.notification-pending:before { 124 | content: ""; 125 | width: 6px; 126 | height: 6px; 127 | background: #d54e21; 128 | position: absolute; 129 | top: 6px; 130 | left: 23px; 131 | border-radius: 100%; 132 | z-index: 1; 133 | } 134 | 135 | #wpadminbar .awaiting-mod, 136 | #wpadminbar .update-plugins { 137 | display: inline-block; 138 | background-color: #d54e21; 139 | color: #fff; 140 | font-size: 9px; 141 | line-height: 17px; 142 | font-weight: 600; 143 | margin: -2px 0 0 2px; 144 | vertical-align: top; 145 | -webkit-border-radius: 10px; 146 | border-radius: 10px; 147 | z-index: 26; 148 | } 149 | 150 | #wpadminbar li .awaiting-mod span, 151 | #wpadminbar li span.update-plugins span { 152 | display: block; 153 | padding: 0 6px; 154 | font-size: 9px; 155 | line-height: 17px; 156 | } 157 | 158 | #wpadminbar li span.count-0 { 159 | display: none; 160 | } 161 | 162 | @media screen and ( max-width: 782px ) { 163 | 164 | #wpadminbar .ab-icon { 165 | font: 20px/40px dashicons !important; 166 | } 167 | 168 | #wpadminbar li#wp-admin-bar-menu-toggle { 169 | width: 52px; 170 | } 171 | 172 | #wpadminbar #wp-admin-bar-site-name > .ab-item, 173 | #wpadminbar #wp-admin-bar-visit-site > .ab-item, 174 | #wpadminbar #wp-admin-bar-view > .ab-item { 175 | text-indent: 100%; 176 | white-space: nowrap; 177 | overflow: hidden; 178 | width: 52px; 179 | padding: 0; 180 | color: #999; 181 | position: relative; 182 | } 183 | 184 | #wpadminbar #wp-admin-bar-visit-site > .ab-item:before, 185 | #wpadminbar #wp-admin-bar-view > .ab-item:before, 186 | #wpadminbar #wp-admin-bar-customize > .ab-item:before { 187 | font: normal 20px/40px 'dashicons'; 188 | top: 3px; 189 | text-indent: 0; 190 | } 191 | 192 | #wpadminbar #wp-admin-bar-dashboard-toggle .ab-icon:before { 193 | top: 4px; 194 | } 195 | 196 | #wpadminbar li#wp-admin-bar-site-name, 197 | #wpadminbar li#wp-admin-bar-visit-site, 198 | #wpadminbar li#wp-admin-bar-dashboard-toggle, 199 | #wpadminbar li#wp-admin-bar-view, 200 | #wpadminbar li#wp-admin-bar-customize { 201 | display: block; 202 | } 203 | 204 | #wpadminbar #wp-admin-bar-edit > .ab-item:before, 205 | #wpadminbar #wp-admin-bar-my-sites > .ab-item:before, 206 | #wpadminbar #wp-admin-bar-site-name > .ab-item:before, 207 | #wpadminbar #wp-admin-bar-my-account > .ab-item:before { 208 | font-size: 20px; 209 | line-height: 32px; 210 | } 211 | 212 | #wpadminbar #wp-admin-bar-site-name > .ab-item:before { 213 | top: 7px; 214 | } 215 | 216 | #wpadminbar #wp-admin-bar-comments .ab-icon:before.ab-icon, 217 | #wpadminbar #wp-admin-bar-customize > .ab-item:before { 218 | font-size: 20px; 219 | height: 40px; 220 | line-height: 40px; 221 | } 222 | } 223 | 224 | -------------------------------------------------------------------------------- /wp-toolbar-experiments.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helen/wp-toolbar-experiments/baac5d4e388b8025aead91d67749c4f6b702f8ca/wp-toolbar-experiments.js -------------------------------------------------------------------------------- /wp-toolbar-experiments.php: -------------------------------------------------------------------------------- 1 | add_menu( array( 74 | 'id' => 'customize', 75 | 'title' => __( 'Customize' ), 76 | 'href' => $customize_url, 77 | 'meta' => array( 78 | 'class' => 'hide-if-no-customize', 79 | ), 80 | ) ); 81 | add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); 82 | } 83 | 84 | /** 85 | * Add the "Site Name" menu. 86 | * 87 | * @since 4.4.0 88 | * 89 | * @param WP_Admin_Bar $wp_admin_bar 90 | */ 91 | function wp_toolbar_experiments_site_menu( $wp_admin_bar ) { 92 | // Don't show for logged out users. 93 | if ( ! is_user_logged_in() ) { 94 | return; 95 | } 96 | 97 | // Show only when the user is a member of this site, or they're a super admin. 98 | if ( ! is_user_member_of_blog() && ! is_super_admin() ) { 99 | return; 100 | } 101 | 102 | $blogname = get_bloginfo( 'name' ); 103 | 104 | if ( ! $blogname ) { 105 | $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); 106 | } 107 | 108 | if ( is_network_admin() ) { 109 | $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) ); 110 | } elseif ( is_user_admin() ) { 111 | $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_current_site()->site_name ) ); 112 | } 113 | 114 | $title = wp_html_excerpt( $blogname, 40, '…' ); 115 | 116 | $notification = false; 117 | $awaiting_mod = wp_count_comments(); 118 | if ( current_user_can( 'edit_posts' ) && $awaiting_mod->moderated > 0 ) { 119 | $notification = true; 120 | } elseif ( ! is_multisite() && current_user_can( 'update_plugins' ) ) { 121 | $update_data = wp_get_update_data(); 122 | if ( $update_data['counts']['plugins'] > 0 ) { 123 | $notification = true; 124 | } 125 | } 126 | 127 | // Add front/admin cross-links. 128 | 129 | if ( is_admin() ) { 130 | // Add an option to visit the site. 131 | $wp_admin_bar->add_menu( array( 132 | 'id' => 'visit-site', 133 | 'title' => $title, 134 | 'href' => home_url( '/' ), 135 | ) ); 136 | } else { 137 | // We're on the front end, link to the Dashboard. 138 | $wp_admin_bar->add_menu( array( 139 | 'id' => 'site-name', 140 | 'title' => $title, 141 | 'href' => admin_url(), 142 | 'meta' => array( 143 | 'class' => ( ! is_admin() && $notification ) ? 'notification-pending' : '', 144 | ), 145 | ) ); 146 | 147 | // Add a Dashboard link to the site name submenu. 148 | $icon = ''; 149 | $wp_admin_bar->add_menu( array( 150 | 'parent' => 'site-name', 151 | 'id' => 'dashboard', 152 | 'title' => $icon . '' . __( 'Dashboard' ) . '', 153 | 'href' => admin_url(), 154 | ) ); 155 | 156 | // Add the admin submenu items. 157 | wp_toolbar_experiments_ab_admin_menu( $wp_admin_bar ); 158 | 159 | // Pair the dashboard icon on the toolbar with the visit site icon (for mobile). 160 | $wp_admin_bar->add_menu( array( 161 | 'id' => 'dashboard-toggle', 162 | 'title' => $icon . '' . __( 'Dashboard' ) . '', 163 | 'href' => admin_url(), 164 | ) ); 165 | } 166 | } 167 | 168 | /** 169 | * Add admin submenu items to the "Site Name" menu. 170 | * 171 | * @since 4.4.0 172 | * 173 | * @param WP_Admin_Bar $wp_admin_bar 174 | */ 175 | function wp_toolbar_experiments_ab_admin_menu( $wp_admin_bar ) { 176 | $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'admin' ) ); 177 | 178 | // Post types. 179 | $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); 180 | if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) { 181 | $menu_icon = ''; 182 | $actions[ 'edit.php' ] = array( $cpts['post']->labels->name, 'edit-posts', $menu_icon ); 183 | } 184 | if ( isset( $cpts['attachment'] ) && current_user_can( 'edit_posts' ) ) { 185 | $menu_icon = ''; 186 | $actions[ 'upload.php' ] = array( $cpts['attachment']->labels->name, 'edit-media', $menu_icon ); 187 | } 188 | if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { 189 | $menu_icon = ''; 190 | $actions[ 'edit.php?post_type=page' ] = array( $cpts['page']->labels->name, 'edit-pages', $menu_icon ); 191 | } 192 | unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); 193 | 194 | // Add any additional custom post types. 195 | foreach ( $cpts as $cpt ) { 196 | if ( ! current_user_can( $cpt->cap->edit_posts ) ) { 197 | continue; 198 | } 199 | if ( is_string( $cpt->menu_icon ) ) { 200 | // Special handling for data:image/svg+xml and Dashicons. 201 | if ( 0 === strpos( $cpt->menu_icon, 'dashicons-' ) ) { 202 | $menu_icon = ''; 203 | } elseif ( 0 === strpos( $cpt->menu_icon, 'data:image/svg+xml;base64,' ) ) { 204 | $menu_icon = ''; 205 | } else { 206 | $menu_icon = ''; 207 | } 208 | } else { 209 | $menu_icon = ''; 210 | } 211 | $key = 'edit.php?post_type=' . $cpt->name; 212 | $actions[ $key ] = array( $cpt->labels->menu_name, 'edit-' . $cpt->name, $menu_icon ); 213 | } 214 | 215 | if ( $actions ) { 216 | foreach ( $actions as $link => $action ) { 217 | list( $title, $id, $menu_icon ) = $action; 218 | $wp_admin_bar->add_menu( array( 219 | 'parent' => 'admin', 220 | 'id' => $id, 221 | 'title' => $menu_icon . '' . $title . '', 222 | 'href' => admin_url( $link ) 223 | ) ); 224 | } 225 | } 226 | 227 | // Comments 228 | if ( current_user_can( 'edit_posts' ) ) { 229 | $awaiting_mod = wp_count_comments(); 230 | $awaiting_mod = $awaiting_mod->moderated; 231 | $icon = ''; 232 | $wp_admin_bar->add_menu( array( 233 | 'parent' => 'admin', 234 | 'id' => 'comments', 235 | 'title' => $icon . '' . sprintf( __( 'Comments %s' ), "" . number_format_i18n( $awaiting_mod ) . "" ) . '', 236 | 'href' => admin_url( 'edit-comments.php' ), 237 | ) ); 238 | } 239 | 240 | // Appearance. 241 | if ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { 242 | $icon = ''; 243 | $wp_admin_bar->add_menu( array( 244 | 'parent' => 'admin', 245 | 'id' => 'themes', 246 | 'title' => $icon . '' . __( 'Appearance' ) . '', // @todo should we just say themes here since there isn't a submenu? 247 | 'href' => admin_url( 'themes.php' ) 248 | ) ); 249 | } 250 | 251 | // Plugins. 252 | if ( current_user_can( 'activate_plugins' ) ) { 253 | if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) { 254 | $update_data = wp_get_update_data(); 255 | $count = "" . number_format_i18n($update_data['counts']['plugins']) . ""; 256 | } else { 257 | $count = ''; 258 | } 259 | $icon = ''; 260 | $wp_admin_bar->add_menu( array( 261 | 'parent' => 'admin', 262 | 'id' => 'plugins', 263 | 'title' => $icon . '' . sprintf( __( 'Plugins %s' ), $count ) . '', 264 | 'href' => admin_url( 'plugins.php' ), 265 | ) ); 266 | } 267 | 268 | // Users. 269 | if ( current_user_can( 'list_users' ) ) { 270 | $icon = ''; 271 | $wp_admin_bar->add_menu( array( 272 | 'parent' => 'admin', 273 | 'id' => 'edit-users', 274 | 'title' => $icon . '' . __( 'Users' ) . '', 275 | 'href' => admin_url( 'users.php' ), 276 | ) ); 277 | } 278 | 279 | // Tools. 280 | if ( current_user_can( 'edit_posts' ) ) { 281 | $icon = ''; 282 | $wp_admin_bar->add_menu( array( 283 | 'parent' => 'admin', 284 | 'id' => 'tools', 285 | 'title' => $icon . '' . __( 'Tools' ) . '', 286 | 'href' => admin_url( 'tools.php' ) 287 | ) ); 288 | } 289 | 290 | // Settings. 291 | if ( current_user_can( 'manage_options' ) ) { 292 | $icon = ''; 293 | $wp_admin_bar->add_menu( array( 294 | 'parent' => 'admin', 295 | 'id' => 'settings', 296 | 'title' => $icon . '' . __( 'Settings' ) . '', 297 | 'href' => admin_url( 'options.php' ) 298 | ) ); 299 | } 300 | } 301 | 302 | 303 | --------------------------------------------------------------------------------