Yes, the way you’ve changed the location of the button is perfectly valid ??
For my_function( $link, $topic_id, $last_read_id )
– the arguments supplied are as follows.
$link
– the default link, as a string. If you simply want to change a little bit of the default link – eg. the text in it – you could take $link
, do a str_replace()
on it, and return the result. If you want to change a lot, then your best bet is to use regular expressions to get the URL part out of this string, and then use it in your own HTML and return that.
$topic_id
is just the same topic ID that was passed to gtf_get_unread_post_link()
– it’s provided again in case you want to use it, but you definitely don’t have to.
$last_read_id
is the post that was calculated as the last post that the user read in that topic. Again, you don’t need to use it – it’s provided just in case you want to.
In hindsight, a more useful thing to return would have been the post id of the first unread post – so that it’s easy for you to construct a whole new link using that ID. I’ll look into changing that for a future update.
No matter what you do here, the link will only show up on topics with unread posts – because gtf_get_unread_post_link()
will not call your function if there are no new posts in the topic.