Closed strarsis closed 4 years ago
Oh well. They really should use the_title_attribute()
or strip the tags themselves if they use the rendered
version from REST API on the JS side. Do you mind creating a trac ticket since this is a WP Core bug? I'll see if I can find a workaround other than disabling everything for REST API calls (which I'm not sure I can easily do).
@mundschenk-at: Thanks for looking into this! Is there a quick, temporary fix I could apply to the gallery block/theme so the link markup is right?
Sorry, not off the cuff, no.
@mundschenk-at: OK, the other plugin calls get_the_title
and gets a title with unescaped markup in it: https://plugins.trac.wordpress.org/browser/gallery-custom-links/trunk/mgcl_linker.php#L13
Is it allowed/expected for the title returned by get_the_title
to contain markup?
Yes. get_the_title()
is the underlying filtering function, both the_title()
and the_title_attribute()
call it. Note that the_title_attribute()
can both echo or return the stripped title string (it's a pretty old WordPress function, so it does both things depending on the parameters).
(BTW: I didn't realize from your description that a plugin was involved - so it's not a Core issue after all.)
@mundschenk-at: Is there a way to call get_the_title
or related title
methods to get the title as plain text? Or is this something that isn't a given anyway in WordPress, hence one should use a strip tags method for getting plain text?
Sure, that function is called the_title_attribute(['echo' => false])
and it has been around since WordPress 2.3.0.
@mundschenk-at: Awesome, thank you!
Don't forget to include the 'echo' => false
inside the parameter array, otherwise the function will echo the value instead of returning it as a string (the default is true
unfortunately).
I've left a comment in the bug report at the other plugin. I'll close this issue since it's not a problem with wp-Typography itself.
Issue Overview
When latest version of
wp-typography
(which is an awesome plugin btw., thank you!) is enabled, the markup of gallery items with a hyperlinked caption of a Gutenberg gallery (core/gallery
) is broken and leaks as text.Steps to Reproduce (for bugs)
wp-typography
plugin is enabled.Notice the misplaced HTML like
<span class=" caps"="">
.PHP Version: 7.4.5-fpm WordPress Version: 5.4 Gutenberg Plugin Version: 7.9.1 wp-typography Version: 5.6.1 The
Easy FancyBox
plugin doesn't seem to affect the bug.Expected Behavior
The markup of the gallery item should not become broken.
Current Behavior
The markup of the gallery item is broken.
Possible Solution
From the broken gallery item markup it appears that some injected typographic markup is not expected and not properly escaped/sanitized by Gutenberg.