-
Notifications
You must be signed in to change notification settings - Fork 11
🎨 Add wp-link attribute to all links #81
🎨 Add wp-link attribute to all links #81
Conversation
So far, I just added a single filter, but I encountered two problems:
<p>First Link: <a wp-link="true" href="/">First Link</a>. Second Link: <a href="/sample-page">Second Link</a>.</p>
I haven't triaged it yet, but any ideas why this is happening or how to solve it are welcome 🙂 |
Oh, sorry. The HTML Tag Processor needs to be called recursively: $w = new WP_HTML_Walker( $html );
while ( $w->next_tag("a") ) {
// ...
} By the way, I've just noticed that in one of the examples of the Make Core post, they are using |
That makes sense 😄 I've just changed it.
Yes, it seems implemented! 🙂 I added a check for the hostname and another one to exit the loop if I will try to take a look now at why this isn't working in the navigation block using directives. |
We can add more later if we need to 🙂 |
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.
Looks good to me, Mario!
Thanks for the review! Changes addressed 🙂 |
I'm opening this Pull Request to "Add the wp-link to all the relative links on the page", one of the tasks of the Tracking issue: WordPress Directives Plugin. This PR aims to just add that attribute in PHP, while all the logic will be handled within the directives in JS.
The first idea is to handle that in the
render_block
filter using the WP_HTML_Tag_Processor.