-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Remove ConditonalTagCheck class #1494
Conversation
I'm fine with removing callback support. Anyone can just do something like: $display = $display || my_custom_check(); |
So what's the verdict? Are we dropping it entirely? It was kinda fun refactoring the function, but I won't miss it if it's gone. I don't think anyone else will either. I can't imagine any users being terribly attached to the awkward syntax with the arrays. |
@QWp6t drop it |
d5b14ac
to
c2707bc
Compare
👌 |
c2707bc
to
1aabb05
Compare
I added a couple other changes.
I believe these changes are more consistent with our efforts to declutter and minimize Sage. |
So much simpler and easy to use. I'm all for this one. Thanks @QWp6t 💟 |
I don't think we should drop the static nature of the variable. Some conditionals can vary their return depending on where in the page load process (pre loop, in the loop, post loop) they are, so this could lead to some inconsistencies. |
That's initially why I added the static variable back in #1196, but you could just as easily hook into As I mentioned above, I think the change is consistent with our recent moves toward decluttering and minimizing Sage. By default we don't need it to be static, and I think most users don't need that either. But obviously I'll add the static variable back if everyone agrees it should be there. lol |
Just a note that we're going to require some docs updates after this: https://roots.io/sage/docs/theme-sidebar/ |
I'm still very much against dropping the static variable. The only benefit of removing it is it won't be there. Keeping it improves performance by not unnecessarily repeating a bunch of conditional calls and guarantees the function returns consistently, which is a real issue considering some conditionals vary throughout the load process. Dropping one keyword makes it less performant and less reliable. That's not the kind of decluttering we should be doing. |
1aabb05
to
86f72f7
Compare
@Foxaii 🍉 |
86f72f7
to
6d05c67
Compare
Remove ConditonalTagCheck class
Update
This PR began as a rewrite of
ConditionalTagCheck
as a function instead of class, but we then decided to get rid of callback support, which alleviated the need for a separate function (or class). It now simply uses PHP's nativein_array()
function.If you're viewing this PR because you're looking for guidance on how to control when the sidebar is displayed, you can view the updated docs on roots.io.
Original Post
Note that
config.php
now encourages users to use the following syntax:The old method of using an array of callbacks is still supported if for whatever reason someone still wants to do that, but I don't see the point in using that method.
Honestly I think we could just remove the callback support all together and replace
display_sidebar()
with: