<?php
/** index a url or file path value as the extension to create a file type facet
** facet datasource needs to be a value that contains a url or file path for the file that includes the file extension
**/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'my_facet_name' == $params['facet_name'] ) {
$raw_value = $params['facet_value'];
$extension = end( explode ( '.', $raw_value) );
if ( !$extension )
return false; // don't index if this is empty
$params['facet_value'] = $extension;
$params['facet_display_value'] = $extension;
}
return $params;
}, 10, 2 );