-
Notifications
You must be signed in to change notification settings - Fork 446
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
feat: support "Show Toolbar when viewing site" user setting #2763
feat: support "Show Toolbar when viewing site" user setting #2763
Conversation
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.
I agree this data should be exposed in core and the PR itself looks good to me (see feedback on field name).
I do worry that exposing a single user meta field without a greater strategy (e.g. #479) is going to lead to more code debt and schema breaks/deprecations, but I'm not anticipating anything specific, just recommending this be reviewed in the larger context.
Co-authored-by: Joe Fusco <josephfusco@users.noreply.github.com>
Co-authored-by: Dovid Levine <justlevine@gmail.com>
I agree with you here. Is there anything you see in this PR that can address these worries? |
@blakewilson the PR actually looks great to me, my comment was more a suggestion for @jasonbahl to do a basic gut-check before merging than anything else. From memory (beyond skimming #479, I havnt looked through other tickets) the things I know we should keep in mind are:
|
'shouldShowAdminToolbar' => function () { | ||
$toolbar_preference_meta = get_user_meta( $this->data->ID, 'show_admin_bar_front', true ); | ||
|
||
return 'true' === $toolbar_preference_meta ? true : false; |
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.
Avoid too many return
statements within this method.
Code Climate has analyzed commit 9835f7a and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
@justlevine Could you help initiate the other workflows? 🙏 Looks like linting is passing now. |
Ultimately, I'd like this to be resolved more centrally where That's a bigger initiative and since this has a test, we can ensure if we do tackle that initiative in the future, this continues to work as-is. |
What does this implement/fix? Explain your changes.
This PR adds the ability to query for the "Show Toolbar when viewing site" user preference in WPGraphQL. This is particulary helpful if you have created an "admin bar" alternative on your Headless site and want it to be displayed based on this preference.
isToolbarVisible.mov
Does this close any currently open issues?
#2764
Any relevant logs, error output, GraphiQL screenshots, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Any other comments?
…
Where has this been tested?
Operating System: MacOS Ventura 13.1
WordPress Version: 6.1.1
Unit tests have been added.