Hi there,
I've simplified the requirements after discussing with my client.
What we'd like to do now is just have PDFs loaded. No other file types.
Here is the custom code already in place, maybe something could be added to this?
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
// Filter view results
add_filter('wpv_filter_query','func_filter_view_by_tax',10,3);
function func_filter_view_by_tax($query_args, $settings, $view_id){
if($view_id == 3284318 and ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )){
$query_args['tax_query'][] = array(
'taxonomy' => 'media_category', // taxonomy name
'field' => 'slug',
'terms' => array( 'ndpba', 'final-report','pdc-fact-sheet'),
'operator' => 'IN'
);
}
return $query_args;
}
// Remove 'ndpba', 'final-report','pdc-fact-sheet' options from view's filter dropdown
function tssupp_restrict_terms( $terms, $taxonomies, $args, $term_query ){
global $post;
// 1. pages where form (or search View) is inserted
$pages = array(3284038);
// 2. which taxonomy (slug)
$taxonomy = 'media_category';
// 3. add terms to blacklist *OR* whitelist, not both
$blacklist = array('ndpba', 'final-report','pdc-fact-sheet');
$whitelist = array();
if ( is_page( $pages ) && $taxonomies[0] == $taxonomy ) {
if ( !empty( $blacklist ) ) {
foreach( $terms as $key => $term ){
if ( in_array( $term->slug, $blacklist ) ) {
unset($terms[$key]);
}
}
} elseif ( !empty( $whitelist ) ) {
foreach( $terms as $key => $term ){
if ( !in_array( $term->slug, $whitelist ) ) {
unset($terms[$key]);
}
}
}
}
return $terms;
}
add_filter( 'get_terms', 'tssupp_restrict_terms', 10, 4 );