Created
October 30, 2013 22:28
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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