Advertisement
Aurangajeb

Allow custom extension with WPUF

Nov 20th, 2020
1,581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. /* This one is for allowing WP for these particular file types*/
  2.  
  3. add_filter( 'upload_mimes', function ( $mime_types ) {
  4.     $mime_types[ 'vcf' ] = 'image/svg+xml';
  5.  
  6.     return $mime_types;
  7. } );
  8.  
  9. /* This is for the WPUF file upload field to accept the custom file type*/
  10.  
  11. add_filter( 'wpuf_allowed_extensions', 'wpufe_custom_upload_extensions', 100 );
  12.  
  13. function wpufe_custom_upload_extensions( $extensions ) {
  14. $extensions = array(
  15.             'images' => array(
  16.             'ext' => '',
  17.             'label' => __( 'Images', 'wpuf-pro' )
  18.         ),
  19.         'audio'  => array(
  20.             'ext' => '',
  21.             'label' => __( 'Audio', 'wpuf-pro' )
  22.         ),
  23.         'video'  => array(
  24.             'ext' => '',
  25.             'label' => __( 'Videos', 'wpuf-pro' )
  26.         ),
  27.         'pdf'    => array(
  28.             'ext' => '',
  29.             'label' => __( 'PDF', 'wpuf-pro' )
  30.         ),
  31.         'office' => array(
  32.             'ext' => '',
  33.             'label' => __( 'Office Documents', 'wpuf-pro' )
  34.         ),
  35.         'zip'    => array(
  36.             'ext' => '',
  37.             'label' => __( 'Zip Archives', 'wpuf-pro' )
  38.         ),
  39.         'exe'    => array(
  40.             'ext' => '',
  41.             'label' => __( 'Executable Files', 'wpuf-pro' )
  42.         ),
  43.         'csv'    => array(
  44.             'ext' => '',
  45.             'label' => __( 'CSV', 'wpuf-pro' )
  46.         ),
  47.        'custom' => array(
  48.                 'label' => __( 'Custom Extensions', 'wpuf-pro' ),
  49.             'ext' => 'eps,svg,ai'
  50.     )
  51. );
  52.  
  53. return $extensions;
  54. }
  55.  
  56. /**
  57. Then visit WP-content/plugins/wpuf-pro/includes/fields/class-field-file.php, line number 139:
  58.  
  59. then insert the line below:
  60.  
  61. 'custom'    => __('custom', 'wpuf-pro')
  62. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement