-
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
0c1a9c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 0c1a9c6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5533773848
📝 Reported issues:
/test/e2e/specs/editor/blocks/image.spec.js
/test/e2e/specs/editor/blocks/image.spec.js
specs/editor/plugins/block-variations.test.js
/test/e2e/specs/editor/blocks/image.spec.js
/test/e2e/specs/editor/blocks/image.spec.js
/test/e2e/specs/editor/blocks/image.spec.js