@@ 1166-1175 (lines=10) @@ | ||
1163 | $file_hash = md5( $file_url ); |
|
1164 | ||
1165 | // Validate the file extension |
|
1166 | if ( in_array( $file_is, array( 'absolute', 'relative' ) ) ) { |
|
1167 | $file_type = wp_check_filetype( strtok( $file_url, '?' ), $allowed_file_types ); |
|
1168 | $parsed_url = parse_url( $file_url, PHP_URL_PATH ); |
|
1169 | $extension = pathinfo( $parsed_url, PATHINFO_EXTENSION ); |
|
1170 | ||
1171 | if ( ! empty( $extension ) && ! in_array( $file_type['type'], $allowed_file_types ) ) { |
|
1172 | WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The downloadable file %s cannot be used as it does not have an allowed file type. Allowed types include: %s', 'woocommerce' ), '<code>' . basename( $file_url ) . '</code>', '<code>' . implode( ', ', array_keys( $allowed_file_types ) ) . '</code>' ) ); |
|
1173 | continue; |
|
1174 | } |
|
1175 | } |
|
1176 | ||
1177 | // Validate the file exists |
|
1178 | if ( 'relative' === $file_is ) { |
|
@@ 1463-1472 (lines=10) @@ | ||
1460 | $file_hash = md5( $file_url ); |
|
1461 | ||
1462 | // Validate the file extension |
|
1463 | if ( in_array( $file_is, array( 'absolute', 'relative' ) ) ) { |
|
1464 | $file_type = wp_check_filetype( strtok( $file_url, '?' ), $allowed_file_types ); |
|
1465 | $parsed_url = parse_url( $file_url, PHP_URL_PATH ); |
|
1466 | $extension = pathinfo( $parsed_url, PATHINFO_EXTENSION ); |
|
1467 | ||
1468 | if ( ! empty( $extension ) && ! in_array( $file_type['type'], $allowed_file_types ) ) { |
|
1469 | WC_Admin_Meta_Boxes::add_error( sprintf( __( '#%s – The downloadable file %s cannot be used as it does not have an allowed file type. Allowed types include: %s', 'woocommerce' ), $variation_id, '<code>' . basename( $file_url ) . '</code>', '<code>' . implode( ', ', array_keys( $allowed_file_types ) ) . '</code>' ) ); |
|
1470 | continue; |
|
1471 | } |
|
1472 | } |
|
1473 | ||
1474 | // Validate the file exists |
|
1475 | if ( 'relative' === $file_is && ! apply_filters( 'woocommerce_downloadable_file_exists', file_exists( $file_url ), $file_url ) ) { |