From 058da3f101c80120962f8b12e803367e2c9441dd Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 30 Dec 2020 16:42:49 +1300 Subject: [PATCH] Prepend anchor IDs with a string to prevent them from starting with a number --- src/class-wpdtrt-anchorlinks-plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class-wpdtrt-anchorlinks-plugin.php b/src/class-wpdtrt-anchorlinks-plugin.php index cea4bdd..0cbbf72 100644 --- a/src/class-wpdtrt-anchorlinks-plugin.php +++ b/src/class-wpdtrt-anchorlinks-plugin.php @@ -157,7 +157,7 @@ public function render_headings_as_anchors( string $content ) : string { // class is also used by $this->render_headings_in_sections(). $heading->setAttribute( 'class', 'wpdtrt-anchorlinks__anchor' ); - $heading_id = sanitize_title( $heading->nodeValue ); // phpcs:ignore + $heading_id = 'section-' . sanitize_title( $heading->nodeValue ); // phpcs:ignore $heading->setAttribute( 'id', $heading_id ); $heading->setAttribute( 'tabindex', '-1' );