Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Tags:** fonts, custom fonts, Google Fonts, performance, full site editing
**Requires at least:** 5.0
**Tested up to:** 6.9
**Stable tag:** 2.1.17
**Stable tag:** 2.1.18
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -151,6 +151,9 @@ Yes, Custom Fonts is completely free to use, without any limitation.


## Changelog ##
### 2.1.18 ###
- Improvement: Enhanced font upload handling to allow .woff and .woff2 files via the Media Library and Custom Fonts, aligning with supported font formats and WordPress restrictions.

### 2.1.17 ###
- Improved codebase for improved security. (Props to Wordfence)

Expand Down
21 changes: 19 additions & 2 deletions admin/dashboard/includes/class-bsf-custom-fonts-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,33 @@ public function sanitize_svg( $original_content ) {
* @return Array File data array containing 'ext', 'type', and
*/
public function update_mime_types( $defaults, $file, $filename ) {
if ( 'ttf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) {
$ext = pathinfo( $filename, PATHINFO_EXTENSION );

if ( 'woff2' === $ext ) {
$defaults['type'] = 'application/x-font-woff2';
$defaults['ext'] = 'woff2';
}

if ( 'woff' === $ext ) {
$defaults['type'] = 'application/x-font-woff';
$defaults['ext'] = 'woff';
}

if ( 'ttf' === $ext ) {
$defaults['type'] = 'application/x-font-ttf';
$defaults['ext'] = 'ttf';
}

if ( 'otf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) {
if ( 'otf' === $ext ) {
$defaults['type'] = 'application/x-font-otf';
$defaults['ext'] = 'otf';
}

if ( 'eot' === $ext ) {
$defaults['type'] = 'application/vnd.ms-fontobject';
$defaults['ext'] = 'eot';
}

if ( 'svg' === pathinfo( $filename, PATHINFO_EXTENSION ) ) {
// Perform SVG sanitization using the sanitize_svg function.
$svg_content = file_get_contents( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
Expand Down
148 changes: 111 additions & 37 deletions admin/dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions custom-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: Brainstorm Force
* Author URI: http://www.brainstormforce.com
* Text Domain: custom-fonts
* Version: 2.1.17
* Version: 2.1.18
*
* @package Bsf_Custom_Fonts
*/
Expand All @@ -25,7 +25,7 @@
define( 'BSF_CUSTOM_FONTS_BASE', plugin_basename( BSF_CUSTOM_FONTS_FILE ) );
define( 'BSF_CUSTOM_FONTS_DIR', plugin_dir_path( BSF_CUSTOM_FONTS_FILE ) );
define( 'BSF_CUSTOM_FONTS_URI', plugins_url( '/', BSF_CUSTOM_FONTS_FILE ) );
define( 'BSF_CUSTOM_FONTS_VER', '2.1.17' );
define( 'BSF_CUSTOM_FONTS_VER', '2.1.18' );
define( 'BSF_CUSTOM_FONTS_POST_TYPE', 'bsf_custom_fonts' );
define( 'BSF_CUSTOM_FONTS_ADMIN_PAGE', 'bsf-custom-fonts' );

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custom-fonts",
"version": "2.1.17",
"version": "2.1.18",
"main": "Gruntfile.js",
"author": "Brainstorm Force",
"workspaces": [
Expand Down
Loading