Wordpress, is there a hook to insert / edit links on the page?

I am trying to add http: // to the dialog after the link, if it is not already added. I tried with a filter

add_filter('pre_link_url', 'add_http_link_url'); 

This did not work. Does anyone know how to do this?

+4
source share
1 answer

Doesn't Wordpress automatically add the default "http: //"?

Perhaps this plugin will help? wordpress.org/extend/plugins/auto-hyperlink-urls/

EDIT

found this at http://betterwp.net/wordpress-tips/make-links-clickable/

a function called make_clickable (), which can be found in wp-includes / formatting.php.

make_clickable () filters the hook_ comment_text with this:

 add_filter( 'comment_text', 'make_clickable', 9 ); 

Since it’s so simple, try adding the same filter to our message and see if it works.

 add_filter( 'the_content', 'make_clickable', 12 ); 

Priority 12, as used above, simply says WordPress to make the links clickable for post post after analyzing shortcodes (which corresponds to priority 11). If you don't like this behavior, just change 12 to whatever number you want. You should take a look at wp-includes / default-filters.php to choose the appropriate priority for make_clickable ().

However, make_clickable () has a limitation that you can clearly see in this interactive link: http://codex.wordpress.org/Function_Reference/make_clic ... _clickable.

See the full stop punctuation mark also included in the link, what makes it broken? To avoid this behavior, you should always have one space plus another character after a simple link, or, in other words, never put an equal link at the end of a paragraph. If you need to, just make the link clickable in the usual way.

Of course, if you do not want your visitors to be able to post links this way, you can easily remove the filter using:

 remove_filter('comment_text', 'make_clickable', 9); 

hope this helps, sorry, I had to delete the first link, since I can only send 2 links until I get my comment :)

0
source

Source: https://habr.com/ru/post/1393697/


All Articles