-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
is_admin() being ignored when inside the block editor #51090
Comments
The block editor uses REST API to retrieve and save data. Therefore, you'll need to update the condition to check for REST requests. See https://core.trac.wordpress.org/ticket/47394 and #11138. |
@Mamaduka So, you're saying that you've broken a core WP Function and still haven't fixed it?? Why?? The Block Editor is part of the WordPress Admin, and therefore checking |
Adding in this (suggested) simple check
inside my above filter function, doesn't work. And I can't use the The only check that does seem to work is if I add the following, taken from this comment:
It's not acceptable that |
The The |
It's totally irrelevant whether this has been an issue since before the Block Editor or not. |
Sadly, I believe this issue can not be fixed. This behaviour has existed in core for a long time. Changing it would be seen as a breaking change. I agree with @Mamaduka that REST API is not the admin. With a different context, that the |
@spacedmonkey That's extremely disappointing. Yes, the REST API can be used in the back-end and the front-end, but the Block Editor is NOT a front-end editor, regardless of whether you're trying to style it to look more like the front-end. You're still in the back-end/WP Admin, so saying that just because Gutenberg uses the REST API, that it's not not in WP Admin, is just plainly incorrect. As you can obviously see in my sample editor page url in my previous comment, it literally has 'wp-admin' in the URL for editing any block editor page. The technology used to render the Block Editor pages is totally irrelevant, and if you're in the WP Admin editing pages in the Block Editor, then |
You could do something like this.
That should work. |
@spacedmonkey Thanks for that. That's close to what I ended up using. I just didn't have the test for |
Checking the context is needed there. The edit context is only done for authenticated requests in the admin. |
Description
I have a function that is using the
the_title
filter to insert<span></span>
tags around any braces()
within the page title. This is used simply so any text in braces can be styled a little different (i.e. reduce the font size).This is the function:
If you're in the Dashboard (i.e.
is_admin()
), this function should just return the proper page title. If there's no opening brace(
in the title it assumes there's no braces and just returns the proper page title.i.e. This function should only return the page title with a span tag, on the front-end.
When you're in the Block Editor, the Parent Page dropdown is returning the title with a span which would indicate that the
the_title
filter is being used, butis_admin()
is being completely ignored (since it's returning span tags in the title).Step-by-step reproduction instructions
functions.php
fileScreenshots, screen recording, code snippet
No response
Environment info
WP 6.2.2
Core (no Plugin)
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: