@@ -545,9 +545,19 @@ private function edit_field( $field_key, $post_type ){
545545 <?php
546546 $ custom_fields = dt_get_option ( 'dt_field_customizations ' );
547547 $ custom_field = $ custom_fields [ $ post_type ][ $ field_key ] ?? [];
548- $ accepted_file_types = $ custom_field ['accepted_file_types ' ] ?? [ 'image/* ' , 'application/pdf ' ];
548+ $ accepted_file_types = $ custom_field ['accepted_file_types ' ] ?? [
549+ 'image/* ' ,
550+ 'application/pdf ' ,
551+ 'audio/* ' ,
552+ 'video/* ' ,
553+ 'application/msword ' ,
554+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document ' ,
555+ 'application/vnd.ms-excel ' ,
556+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ' ,
557+ 'text/plain ' ,
558+ 'text/markdown ' ,
559+ ];
549560 $ max_file_size = $ custom_field ['max_file_size ' ] ?? '' ;
550- $ file_type_icon = $ custom_field ['file_type_icon ' ] ?? '' ;
551561 $ delete_enabled = isset ( $ custom_field ['delete_enabled ' ] ) ? $ custom_field ['delete_enabled ' ] : true ;
552562 $ display_layout = $ custom_field ['display_layout ' ] ?? 'grid ' ;
553563 $ auto_upload = isset ( $ custom_field ['auto_upload ' ] ) ? $ custom_field ['auto_upload ' ] : true ;
@@ -564,10 +574,13 @@ private function edit_field( $field_key, $post_type ){
564574 <td>
565575 <input type="text" name="accepted_file_types" id="accepted_file_types"
566576 value="<?php echo esc_attr ( implode ( ', ' , $ accepted_file_types ) ) ?> "
567- placeholder="e.g., image/*, application/pdf, .doc , .docx"
577+ placeholder="e.g., image/*, audio/*, video/*, application/pdf , .docx"
568578 style="width: 100%;" />
569579 <p style="font-size: 11px; color: #666; margin-top: 5px;">
570- <?php esc_html_e ( 'Comma-separated list of MIME types or file extensions (e.g., image/*, application/pdf, .doc) ' , 'disciple_tools ' ) ?>
580+ <?php esc_html_e ( 'Optional. Comma-separated list of MIME types or file extensions to override the default set (images, PDFs, audio, video, common documents). Leave empty to use the default types. ' , 'disciple_tools ' ); ?>
581+ <a href="<?php echo esc_url ( 'https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types ' ); ?> " target="_blank" rel="noopener noreferrer">
582+ <?php esc_html_e ( 'View common MIME types. ' , 'disciple_tools ' ); ?>
583+ </a>
571584 </p>
572585 </td>
573586 </tr>
@@ -582,41 +595,6 @@ private function edit_field( $field_key, $post_type ){
582595 placeholder="<?php esc_attr_e ( 'Leave empty for no limit ' , 'disciple_tools ' ) ?> " />
583596 </td>
584597 </tr>
585- <tr>
586- <td style="vertical-align: middle">
587- <label for="file_type_icon"><b><?php esc_html_e ( 'File Type Icon ' , 'disciple_tools ' ) ?> </b></label>
588- </td>
589- <td>
590- <table>
591- <tbody>
592- <tr>
593- <td>
594- <?php if ( !empty ( $ file_type_icon ) ) : ?>
595- <?php if ( strpos ( $ file_type_icon , 'mdi ' ) === 0 || strpos ( $ file_type_icon , 'mdi mdi- ' ) === 0 ) : ?>
596- <i class="<?php echo esc_attr ( $ file_type_icon ); ?> " style="font-size: 20px; vertical-align: middle;"></i>
597- <?php else : ?>
598- <img src="<?php echo esc_attr ( $ file_type_icon ); ?> " style="width: 20px; vertical-align: middle;">
599- <?php endif ; ?>
600- <?php endif ; ?>
601- </td>
602- <td>
603- <input type="text" name="file_type_icon" id="file_type_icon"
604- placeholder="<?php esc_attr_e ( 'Icon url ' , 'disciple_tools ' ); ?> "
605- value="<?php echo esc_attr ( $ file_type_icon ); ?> ">
606- </td>
607- <td>
608- <button class="button change-icon-button"
609- data-form="<?php echo esc_html ( $ form_name ) ?> "
610- data-icon-input="file_type_icon"><?php esc_html_e ( 'Change Icon ' , 'disciple_tools ' ); ?> </button>
611- </td>
612- </tr>
613- </tbody>
614- </table>
615- <p style="font-size: 11px; color: #666; margin-top: 5px;">
616- <?php esc_html_e ( 'Icon to display for non-image files (e.g., PDFs, documents) ' , 'disciple_tools ' ) ?>
617- </p>
618- </td>
619- </tr>
620598 <tr>
621599 <td style="vertical-align: middle">
622600 <b><?php esc_html_e ( 'Delete Enabled ' , 'disciple_tools ' ) ?> </b>
@@ -1069,9 +1047,15 @@ private function process_edit_field( $post_submission ){
10691047 // file_upload field options
10701048 if ( $ field ['type ' ] === 'file_upload ' ) {
10711049 // Accepted file types
1072- if ( isset ( $ post_submission ['accepted_file_types ' ] ) && !empty ( $ post_submission ['accepted_file_types ' ] ) ) {
1073- $ types = array_map ( 'sanitize_text_field ' , array_map ( 'trim ' , explode ( ', ' , $ post_submission ['accepted_file_types ' ] ) ) );
1074- $ custom_field ['accepted_file_types ' ] = $ types ;
1050+ if ( isset ( $ post_submission ['accepted_file_types ' ] ) ) {
1051+ $ raw_accepted = trim ( $ post_submission ['accepted_file_types ' ] );
1052+ if ( $ raw_accepted === '' ) {
1053+ // Clear any previously saved override so defaults are used
1054+ unset( $ custom_field ['accepted_file_types ' ] );
1055+ } else {
1056+ $ types = array_map ( 'sanitize_text_field ' , array_map ( 'trim ' , explode ( ', ' , $ raw_accepted ) ) );
1057+ $ custom_field ['accepted_file_types ' ] = $ types ;
1058+ }
10751059 }
10761060
10771061 // Max file size
@@ -1081,16 +1065,6 @@ private function process_edit_field( $post_submission ){
10811065 unset( $ custom_field ['max_file_size ' ] );
10821066 }
10831067
1084- // File type icon
1085- if ( isset ( $ post_submission ['file_type_icon ' ] ) ) {
1086- $ file_type_icon = sanitize_text_field ( wp_unslash ( $ post_submission ['file_type_icon ' ] ) );
1087- if ( !empty ( $ file_type_icon ) ) {
1088- $ custom_field ['file_type_icon ' ] = $ file_type_icon ;
1089- } else {
1090- unset( $ custom_field ['file_type_icon ' ] );
1091- }
1092- }
1093-
10941068 // Delete enabled
10951069 if ( isset ( $ post_submission ['delete_enabled ' ] ) ) {
10961070 $ custom_field ['delete_enabled ' ] = true ;
0 commit comments