add filter
-
Thank you for this great plugin. It works fine.
I have two problems.
1. I would love to modify the selected text a bit. When the User highlights “Here is an example text” from the website and tries to share it, it would be great if there are quotation marks or guillemets in the tweet.2. I would like to modify the URL of the posting. I have two domains, one is a short URL which redirects to the original post. It is simply a mirror. So what I did (for other sharing plugins) to modify the URL is to change the
wp_get_shortlink function
in
link-template.php
like this:
(…)
add_filter( ‘get_shortlink’, ‘my_short_domain_function’ );
return apply_filters( ‘get_shortlink’, $shortlink, $id, $context, $allow_slugs );function my_short_domain_function( $shortlink ) {
return str_replace( ‘MUglyOldWayToLongDomainName.de’, ‘short.de’, $shortlink );
}which works good. But the Highlight and Share plugin does not use this modified shortlink, it uses the long form anyway. I don’t know why. So I noticed the “Modify the Content URL” filter provided here: https://mediaron.com/highlight-and-share/
which is writter like this:add_filter( ‘has_content_url’, function( $url, $post_id ) {
return ‘https://www.ads-software.com’;
}, 10, 2 );but I do not know where to insert it. Also, I do not understand the “10,2” part. I know a little bit php, but I have no clue about the WordPress architecture. Can somebody tell me how to change the MUglyOldWayToLongDomainName.de/?p=123 to short.de/?p=123
I guess the first problem – changing the quoted text to the text with quotation marks – also works with a filter. But I have no idea how to implemtent this.
- The topic ‘add filter’ is closed to new replies.