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

Make all outputs filterable #13

Merged
merged 1 commit into from Dec 12, 2016

Conversation

Projects
None yet
2 participants
@joshuadavidnelson
Contributor

joshuadavidnelson commented Dec 11, 2016

It would be nice to be able to modify the outputs of this plugin. This PR creates the following filters to provide that extendability:

  • gridlist_toggle_button_output - Filters the button output with variables for the translated 'Grid View' and 'List View' strings. See example below.
  • gridlist_button_wrap_start - which defaults to: <div class="gridlist-buttonwrap">
  • gridlist_button_wrap_end - which defaults to: </div>
  • gridlist_hr - which defaults to: <hr />
  • gridlist_cat_desc_wrap_start - which defaults to: <div itemprop="description">
  • gridlist_cat_desc_wrap_end - which defaults to: </div>

These can be used, for instance, to replace the buttons with Font Awesome icons and switch their order:

// Filter Gridlist button output
add_filter( 'gridlist_toggle_button_output', 'jdn_filter_gridlist_button_output', 10, 3 );

/**
 * Filter the Gridlist button output, use Font Awesome Icons instead.
 *
 * @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
 */
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 );
}
@jameskoster

This comment has been minimized.

Owner

jameskoster commented Dec 12, 2016

Thanks. :)

@jameskoster jameskoster merged commit 5f2def7 into jameskoster:master Dec 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment