Skip to content

Instantly share code, notes, and snippets.

@amdrew
Created October 30, 2013 22:28
Show Gist options
  • Save amdrew/7241455 to your computer and use it in GitHub Desktop.
Save amdrew/7241455 to your computer and use it in GitHub Desktop.
To block the .mp3 file type in Easy Digital Downloads, we modify the edd_protected_directory_htaccess_rules filter and remove mp3 from the FilesMatch line
<?php
function edd_custom_modify_htaccess_rules( $rules, $method ) {
switch( $method ) :
case 'redirect' :
// Prevent directory browsing
$rules = "Options -Indexes";
break;
case 'direct' :
default :
// Prevent directory browsing and direct access to all files, except images (they must be allowed for featured images / thumbnails)
$rules = "Options -Indexes\n";
$rules .= "deny from all\n";
$rules .= "<FilesMatch '\.(jpg|png|gif|ogg)$'>\n";
$rules .= "Order Allow,Deny\n";
$rules .= "Allow from all\n";
$rules .= "</FilesMatch>\n";
break;
endswitch;
return $rules;
}
add_filter( 'edd_protected_directory_htaccess_rules', 'edd_custom_modify_htaccess_rules', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment