-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
AdminBarRemoval: More thorough checking for admin bar removal and hiding #817
Conversation
…checking the function calls. Adds a `$remove_only` property to toggle whether to disallow admin bar removal or disallow any manipulation of the visibility of the admin bar.
Please can you have a look @sboisvert @david-binda |
* | ||
* {@internal For PHP 5.3+ this is straightforward, just check if $content | ||
* contains the tag. | ||
* PHP 5.2 however, creates a seperate token for `<s` when used in inline HTML, |
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.
Typo: seperate =>
separate`
Why did the tokenizer create a separate token in PHP 5.2?
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.
Why did the tokenizer create a separate token in PHP 5.2?
See https://bugs.php.net/bug.php?id=48446:
It stops at "<s" to avoid a long PHP opening tag (e.g. <script language="php">,
etc.) from being taken as inline HTML.
The good news, however, is that a new scanner is used for PHP 5.3, and as of a few weeks ago (5.3.0 RC2), it now works as you'd expect.
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.
P.S.: Fixed the typo and added the link to the documentation.
This functionality is needed by several of the Theme sniffs, so makes sense to refactor this to a utility function.
42502ed
to
6c7b05a
Compare
I haven't read the code in detail but just the goal of what this is achieving is good from VIP's point of view, thanks! |
@sboisvert Thanks for looking through it. |
This sniff has been completely overhauled with the additional wish-list of the Theme Review Team in mind.
Originally the sniff only checked for
show_admin_bar( ... )
andadd_filter( 'show_admin_bar', ... )
.This PR fixes that.
Includes extensive additional unit tests.
Notes:
WordPress_AbstractFunctionParameterSniff
for the PHP function parameter checks.register()
method to register additional tokens.process()
method of that class to only use the functions in the abstract class when passed aT_STRING
token. For the other token types, the processing is handled within the sniff.$remove_only
which defaults totrue
, to toggle whether to just check that the admin bar is being manipulated or to do a more in-depth check and only throw errors when removing or hiding of the admin bar is detected.<s
, like<style>
.Who should I ping from the VIP team to have a look as well ?