mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Editor: trim footnote anchors from post excerpts.
Adds the `excerpt_remove_footnotes` function to trim footnote anchors from post excerpts. Props: ramonopoly, costdev, mukesh27, mcsf, azaozz. Fixes #58805. git-svn-id: https://develop.svn.wordpress.org/trunk@56244 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1009,6 +1009,27 @@ function excerpt_remove_blocks( $content ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses footnotes markup out of a content string,
|
||||
* and renders those appropriate for the excerpt.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param string $content The content to parse.
|
||||
* @return string The parsed and filtered content.
|
||||
*/
|
||||
function excerpt_remove_footnotes( $content ) {
|
||||
if ( ! str_contains( $content, 'data-fn=' ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
return preg_replace(
|
||||
'_<sup data-fn="[^"]+" class="[^"]+">\s*<a href="[^"]+" id="[^"]+">\d+</a>\s*</sup>_',
|
||||
'',
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders inner blocks from the allowed wrapper blocks
|
||||
* for generating an excerpt.
|
||||
|
||||
Reference in New Issue
Block a user