-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow showing admin bar on frontend #4546
Conversation
This comment has been minimized.
This comment has been minimized.
e56381f
to
b502c90
Compare
eefc2c8
to
3cecb71
Compare
cdb6b26
to
da5c804
Compare
3cecb71
to
8707684
Compare
8707684
to
48ad518
Compare
@westonruter @schlessera @spacedmonkey While we're at it... I figured it might be nice to allow displaying the admin bar on the frontend. |
If we have unit tests this, I am happy with this change |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
OK, that's fixed now with 2dffaeb: See corresponding logic in the AMP plugin: https://github.com/ampproject/amp-wp/blob/806794efd3a04ce43e8f41357cf8f8692495218d/includes/amp-helper-functions.php#L129-L138 |
Nevertheless, I don't think what I added is sufficient because it's only accounting for a one-off case for the AMP plugin. What about other plugins that add admin bar menu items? For example, Yoast is broken: I assume Site Kit would also be broken. I think it needs to do all enqueued stylesheets coming from Something else that is needed is the admin bar needs to continue to be omitted when the story is shown in an |
81ad82f
to
748bde8
Compare
This comment has been minimized.
This comment has been minimized.
Unfortunately just doing add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_assets' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); It would work automatically if it instead did: add_action( 'admin_bar_init', [ $this, 'enqueue_assets' ] ); Nevertheless, Site Kit is doing the same as Yoast: add_action( 'admin_enqueue_scripts', $admin_bar_callback, 40 );
add_action( 'wp_enqueue_scripts', $admin_bar_callback, 40 ); Since both Site Kit and Yoast are doing the same thing, I'm not sure what alternative we have to just going ahead and doing Something else to keep in mind is that there are scripts that the admin bar depends on, especially plugins. Site Kit and Jetpack both will enqueue scripts that are needed or else some functionality in the admin bar that they add in PHP will either be broken or limited in functionality. See also the AMP plugin logic for marking admin bar scripts for dev mode: https://github.com/ampproject/amp-wp/blob/806794efd3a04ce43e8f41357cf8f8692495218d/includes/class-amp-theme-support.php#L1481-L1499 You may want to refer to how the admin bar is added to the legacy AMP Reader mode template. It actually goes ahead and calls |
Thanks a lot for digging into this @westonruter! I‘m gonna try the printing scripts option |
Site Kit's admin bar CSS doesn't have |
That seems like an improvement to be made with Site Kit then. Nevertheless, there's going to be many plugins that don't do this either. It seems the scripts and styles just need to be printed in their entirety? In Jetpack we've had to manually add the The concern is stylesheets coming from the theme and plugins which aren't related to the admin bar. |
Yup, looks like it. Unrelated CSS might of course mess with the story content, so I suppose we have to make a tradeoff here. |
Could we make this simpler and not support plugins that add options to the admin bar? Deregister all menus items in the admin bar that are not core. Than have a filter to white list what we want. So maybe, yoast, jetpack and amp plugin can be support. I feel like enqueueing scripts and styles that any old plugin put on the page is going complete mess. I might be wrong here. |
That'd could be a way to work around the plugin, but also requires some work (remove all menu items), and might confuse users ("where's my AMP plugin menu item?!?!") Not sure loading all these scripts or styles is really going to be messy. |
Summary
If users prefer to display the toolbar on the frontend, they should be able to see it also when viewing stories.
Relevant Technical Choices
To-do
User-facing changes
If enabled in the user profile, the admin toolbar will be displayed on the frontend.
Testing Instructions
Depends on #4513