Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filter the WooCommerce Grid/List Outputs
<?php
/**
* Filter the Gridlist Button Wrap End tag.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
*
* @return string $output The filtered output value
*/
add_filter( 'gridlist_button_wrap_end', 'jdn_filter_gridlist_button_wrap_end', 10, 1 );
function jdn_filter_gridlist_button_wrap_end( $output ) {
return '</div>'; // this is the default output
}
<?php
/**
* Filter the Gridlist Button Wrap Start Tag.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
*
* @return string $output The filtered output value
*/
add_filter( 'gridlist_button_wrap_start', 'jdn_filter_gridlist_button_wrap_start', 10, 1 );
function jdn_filter_gridlist_button_wrap_start( $output ) {
return '<div class="gridlist-buttonwrap">'; // this is the default output
}
<?php
/**
* Filter the Gridlist Category Description Wrap End Tag.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
*
* @return string $output The filtered output value
*/
add_filter( 'gridlist_cat_desc_wrap_end', 'jdn_filter_gridlist_cat_desc_wrap_end', 10, 1 );
function jdn_filter_gridlist_cat_desc_wrap_end( $output ) {
return '</div>'; // this is the default output
}
<?php
/**
* Filter the Gridlist Category Description Wrap starting tag.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
*
* @return string $output The filtered output value
*/
add_filter( 'gridlist_cat_desc_wrap_start', 'jdn_filter_gridlist_cat_desc_wrap_start', 10, 1 );
function jdn_filter_gridlist_cat_desc_wrap_start( $output ) {
return '<div itemprop="description">'; // this is the default output
}
<?php
/**
* Filter the Gridlist horizontal reference (hr) tag.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
*
* @return string $output The filtered output value
*/
add_filter( 'gridlist_hr', 'jdn_filter_gridlist_hr', 10, 1 );
function jdn_filter_gridlist_hr( $output ) {
return '<hr />'; // this is the default output
}
<?php
/**
* Filter the Gridlist button output, use Font Awesome Icons instead.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
* @param string $grid_view The translated 'Grid View' string
* @param string $list_view The Translated 'List View' string
*
* @return string $output The filtered output value
*/
add_filter( 'gridlist_toggle_button_output', 'jdn_filter_gridlist_button_output', 10, 3 );
function jdn_filter_gridlist_button_output( $output, $grid_view, $list_view ) {
return sprintf( '<nav class="gridlist-toggle"><a href="#" id="list" title="%2$s"><i class="fa fa-list"></i> <em>%2$s</em></a><a href="#" id="grid" title="%1$s"><i class="fa fa-th"></i> <em>%1$s</em></a></nav>', $grid_view, $list_view );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment