facetwp search attachments

<?php
/**
 * make sure both publish and inherit (for attachments) are searched on the search page
 * Relevanssi has an option to index attachments but the query facet detects does not include attachments
 * because it does not include post_status inherit
 */
add_action( 'pre_get_posts', function( $query ) {
	if ( $query->is_search() ) {
		$statuses = $query->get( 'post_status' );
		$query->set( 'post_status', array_merge( (array)$statuses, array( 'publish', 'inherit' ) ) );
	}
});