-
Notifications
You must be signed in to change notification settings - Fork 30
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
default/fallback grid not in allowed_grids #16
Comments
You could work around this, but I feel it is cleaner if this is handled internally, anyway;
|
I'm thinking a filter hook on the default is the best route. |
Okay I thought this through some more and I think I need to explain this in more detail. The current behaviour just sticks with the last valid grid if an invalid one is found until a new valid one is used. Let's look at an example:
This actually results in two If this is intended behaviour (or even if not, because changing this would probably cause issues with existing sites) we can not do something like this at L182
Actually we only need to check on the very first usage of the shortcode because from then on So I'd just add a filter in init():
But the problem is that we already have a filter So we probably need to use this hook in init, something like this:
This still has the slight problem that people can now manually set a default grid that is incompatible with I'll keep looking for a backward compatible and clean solution to this. Maybe you have an idea too. |
Okay another idea. What if we add this:
right after the line that sets the grid No need for a new filter and this only kicks in when we end up with and invalid grid. I think that is it. What do you think? Ready for a PR? |
As I am hitting this again on a current project - any thoughts? |
@kraftner what's your real world use case for this happening? People entering random grid values, not knowing the restrictions, or? |
Well by default you can choose between 2, 3, 4, 5 or 12 columns. As this doesn't always make sense, say my theme only works and therefore accepts 2 and 3 column layouts. If I filter |
Ah right, you've already upvoted #7 :) No further comments needed then. |
In case you filter
gc_allowed_grids
does not contain4
the code still falls back to4
anyway if the selected grid is not allowed, for example when using4
I see two ways to solve this:
$this->allowed_grids
but instead use$defaults['grid']
gc_fallback_grid
or alike.I can create a PR, I just wanted to ask beforehand what you're preferred approach would be on this.
The text was updated successfully, but these errors were encountered: