Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Last active November 7, 2019 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plugin-republic/69f13f942a95cba8042c835762903745 to your computer and use it in GitHub Desktop.
Save plugin-republic/69f13f942a95cba8042c835762903745 to your computer and use it in GitHub Desktop.
Allow the user to upload PDFs with the upload field
<?php
// Add PDFs to list of permitted mime types
function my_prefix_pewc_get_permitted_mimes( $permitted_mimes ) {
// Add PDF to the list of permitted mime types
$permitted_mimes['pdf'] = "application/pdf";
// Remove a mime type - uncomment the line below if you wish to prevent JPGs from being uploaded
// unset( $permitted_mimes['jpg|jpeg|jpe'] );
return $permitted_mimes;
}
add_filter( 'pewc_permitted_mimes', 'my_prefix_pewc_get_permitted_mimes' );
// Add PDF to the list of restricted filetypes
function my_prefix_pewc_protected_directory_allowed_filetypes( $restricted_filetypes ) {
$restricted_filetypes[] = 'pdf';
return $restricted_filetypes;
}
add_filter( 'pewc_protected_directory_allowed_filetypes', 'my_prefix_pewc_protected_directory_allowed_filetypes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment