Filters
-
Thanks again for the awesome plugin.
Could you please tell me, what filters I should use to override the Gridable classes?
I have Bootstrap in my theme and hence would like to change classes to col-md-4 for example.
I would also highly appreciate if you could tell me how to properly dequeue the Gridable stylesheet.
Thanks!
-
Hello and thanks for the sweet words.
Almost perfect timing; we are working on an update which adds a lot of flexibility to the row/column templates.
I’m already testing the new version, and I hope tomorrow we push it on ww.wp.xz.cn
Also, in the new version, there is a filter which allows you to skip the Gridable style https://github.com/pixelgrade/gridable/tree/dev#remove-gridable-style
Thanks again for your support and I promise I will get back after we update the plugin.
Thanks for the update! I managed to dequeue the standard Gridable stylesheet and change the row class.
However, changing the column class seems a little bit more complicated.
I would like to change
gridable--col hand-span-3to simplycol-md-3.I tried the
gridable_sh_col_classesfilter, but the available$sizeseems to contain not the integer, but an array.So this won’t work:
add_filter( 'gridable_sh_col_classes', 'custom_gridable_classes' ); function custom_gridable_classes( $size ) { $classes = array( 'col-md-', $size ); return $classes; }Instead this will work:
add_filter( 'gridable_sh_col_classes', 'custom_gridable_classes' ); function custom_gridable_classes( $sizes ) { // Implode array. $size = implode( '', $sizes ); // Remove all non-numeric characters, so that we get the size of the column as integer. $size = preg_replace( '/[^0-9]/', '', $size ); // Save the only class as array. $classes = array( 'col-md-' . $size ); // Return the array. return $classes; }Looks dirty π
I wish we could change the class names of columns with a simple string (or an array, like in my first example).
Thanks anyway!
-
This reply was modified 9 years, 4 months ago by
ninetienne.
-
This reply was modified 9 years, 4 months ago by
ninetienne.
Yep, you are totally right! There should be a consistency between row and column filters.
In the next update we will take the WordPress core approach like the “body_class” filter https://codex.ww.wp.xz.cn/Plugin_API/Filter_Reference/body_class
Thank you for your feedback, it helps a lot!
-
This reply was modified 9 years, 4 months ago by
Andrei Lupu.
Sounds great, but the
body_classfilter doesn’t pass a parameter and we need the integer of the column size, otherwise we won’t be able to changegridable--col hand-span-3to simplycol-3.Well, I’m not a good coder anyway π
Don’t worry, you will have access to the column size as well in parameters. We just want to follow the WordPress standards on this.
Sounds great!
Thanks a lot π
Hey,
The new version is live, and there has been made some changes to the filters we discussed above.
Now the filters names are simply
gridable_row_classandgridable_column_class.The best part is that it supports four parameters, here is an example
function mycustom_gridable_column_class( $classes, $size, $atts, $content ) { $classes[] = 'column col-' . $size; return $classes; } add_filter( 'gridable_column_class', 'mycustom_gridable_column_class', 10, 4 );Now the column attributes and the content are available with these filters.
This way, we could add an
empty_columnclass when a column is empty. This way we can hide it on mobile devices.Thanks
This is great. You’re awesome. I’ll give it a shot, when I have some free time and post back. Thank you very much!
-
This reply was modified 9 years, 4 months ago by
The topic ‘Filters’ is closed to new replies.