Skip to content

Critical error when removing fonts added using old naming convention in theme.json #599

@nicholasingham

Description

@nicholasingham

When using the Save Changes option with Save Fonts ticked, we are getting the following error

PHP Fatal error:  Uncaught TypeError: basename(): Argument #1 ($path) must be of type string, array given in ... wp-content\plugins\create-block-theme\admin\create-theme\theme-fonts.php:117

We think this error occurs when create block theme is trying to remove fonts that were created in theme.json with the old naming convention and where the src is stored in theme.json as an array e.g.

	"fontFace": [
		{
			"fontFamily": "Ysabeau Office",
			"fontStyle": "normal",
			"fontWeight": "400",
			"src": [
				"file:./assets/fonts/ysabeau-office_normal_400.ttf"
			]
		},

We do not get the problem, when trying to remove fonts with the new naming convention where the src is stored as a string e.g.

"src": "file:./assets/fonts/S6uyw4BMUTPHvxw6XweuBCY.woff2"

We have managed to work around this by temporarily changing the line of code

$font_filename = basename( $font_face['src']);

to

$font_filename = basename( $font_face['src'][0]);

and removing fonts created the old way and reinstalling them the new way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions