-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trim footnote anchors from excerpts (#52518)
* Trim footnote anchors from excerpts * Add comments, fix spacing, appease linter
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* Compatiblity filters for improved footnotes support. | ||
* | ||
* In core, this could be fixed directly in key functions. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Trims footnote anchors from content. | ||
* | ||
* @param string $content HTML content. | ||
* @return string Filtered content. | ||
*/ | ||
function gutenberg_trim_footnotes( $content ) { | ||
if ( ! doing_filter( 'get_the_excerpt' ) ) { | ||
return $content; | ||
} | ||
|
||
static $footnote_pattern = '_<sup data-fn="[^"]+" class="[^"]+">\s*<a href="[^"]+" id="[^"]+">\d+</a>\s*</sup>_'; | ||
return preg_replace( $footnote_pattern, '', $content ); | ||
} | ||
|
||
add_filter( 'the_content', 'gutenberg_trim_footnotes' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters