Skip to content

Instantly share code, notes, and snippets.

@djrmom djrmom/custom-hooks.php
Last active Aug 18, 2017

Embed
What would you like to do?
facetwp hash for colors
//filter color display to maybe add hash to hex colors
add_filter( 'facetwp_facet_render_args', function( $args ) {
if ( 'colors' == $args['facet']['name'] ) {
foreach ( $args['values'] AS $key => $value ) {
$args['values'][$key]['facet_display_value'] = ( '' != ( $color = sanitize_hex_color_no_hash( $value['facet_display_value'] ) ) ) ? '#' . $color : $value['facet_display_value'];
}
}
return $args;
});
//filter color index to maybe add hash to hex colors
add_filter( 'facetwp_index_row', function( $params ) {
if ( 'colors' == $params['facet_name'] ) {
$display_value = $params['facet_display_value'];
$params['facet_display_value'] = ( '' != ( $color = sanitize_hex_color_no_hash( $params['facet_display_value'] ) ) ) ? '#' . $color : $params['facet_display_value'];
}
return $params;
}, 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.