Skip to content

Commit

Permalink
fix: add message for special chars on file uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
astagi authored Feb 27, 2023
1 parent af41e37 commit e948402
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions inc/vendor/CMB2/includes/types/CMB2_Type_File_Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ public function img_status_output( $args ) {
* @return string File wrap output
*/
public function file_status_output( $args ) {
return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span>&nbsp;&nbsp; (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>',
return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong>&nbsp<span style="color: red">%9$s</span></span>&nbsp;&nbsp; (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>',
$args['tag'],
esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ),
esc_html( CMB2_Utils::get_file_name_from_path( $args['value'] ) ),
esc_url( $args['value'] ),
esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ),
isset( $args['cached_id'] ) ? ' rel="' . esc_attr( $args['cached_id'] ) . '"' : '',
esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ),
isset( $args['id_input'] ) ? $args['id_input'] : ''
isset( $args['id_input'] ) ? $args['id_input'] : '',
esc_url( $args['value'] ) != $args['value'] ? "(⚠️ Il file caricato contiene caratteri non ammessi, rimuovere il file e caricarlo con un altro nome)" : ""
);
}

Expand Down
3 changes: 1 addition & 2 deletions template-parts/documento/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

$attach = get_post($idfile);
$filetocheck = get_attached_file($idfile);

$filesize = filesize($filetocheck);
$fulltype = mime_content_type($filetocheck);
$arrtype = explode("/", $fulltype);
Expand All @@ -37,7 +36,7 @@
<div class="card-body">
<svg class="icon <?php echo $icon; ?>" role="img"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#<?php echo $icon; ?>"></use></svg>
<div class="card-icon-content">
<p><strong><a target="_blank" href="<?php echo $attach->guid; ?>" ><?php echo $ptitle; ?></a></strong></p>
<p><strong><a target="_blank" href="<?php echo $nomefile; ?>" ><?php echo $ptitle; ?></a></strong></p>
<small><?php echo $type; ?> - <?php echo intval($filesize/1024); ?> kb</small>
</div><!-- /card-icon-content -->
</div><!-- /card-body -->
Expand Down

0 comments on commit e948402

Please sign in to comment.