-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix issues with field, hasfield, isfield post ID parsing #68
Conversation
Checks for numeric, get_the_ID, $post->ID, or get_queried_object_id()
I have added an attempt at identifying wp post ID retrieval methods which might be used with |
@erip2 It was. I may have slowed this down, not wanting to introduce bugs and hoping that it could be tested by others who had issues I've mentioned above. Log1x was open to merge It sounds like you may have confirmed it worked with composer-patches perhaps? |
@EHLOVader I didn't use composer-patches. I've only created my own directives with the changes you've made here and I've used those but I would like better to use the package ones instead of creating custom ones. |
Wondering if this looks good to merge? If it does can you merge it and add #hacktoberfest-accepted label to it? Thanks! |
This PR fails when you pass a variable to the @field directive. Take the following use-case:
It should be noted that if you are passing variables as your $id you are limited to the following only:
i.e.. works:
|
That is correct. It also accepts an explicit number as noted in the documentation.
I think that It would be good to add these notes to the docs, or maybe it needs rewritten to work differently. Not sure what can reliably be done since it isn't running the php just parsing the string and generating php from the blade input so you have no clue what output of a function will be, or the type of the variable. I think this presented issues with string manipulations and arrays before too. |
Superseded by #82 |
Switching to
is_numeric
to identify ID values from strings, since the blade template is always parsed as a string andis_string
wasn't catching IDs.This may however need more to really fix it. This will handle any cases when someone passes in a number directly, but does not handle variables or function calls, which might happen.
Fixes #44
Fixes #63