Jump to content

Need help writing a wordpress plugin


cashbagg

Recommended Posts

Hi, I needed a plugin for Wordpress that will automatically add 'http://hornyoyster.com/test/out.php?l=' before any URL I create. This is to track outclicks. It's a pain to enter that manually everytime.

Anyway, asked around and was given this answer:

[i][b]Well, if you want to roll your own plugin, you need to understand filters.

A filter receives some text, modifies it, and returns it. So something like this would do the job:

function adjust_links($content)
{
// use regular expressions to modify $content here
return $content;
}
add_filter('the_content','adjust_links');

Your function would then be called every time a post is displayed, and it would contain the content of the post. So you could add code to find and modify your links accordingly. [/b][/i]

I interpreted this as:
[i][b]
function adjust_links($content)
{
// http://hornyoyster.com/test/out.php?l=
return $content;
}
add_filter('the_content','adjust_links');

?>[/b][/i]

I uploaded plugin to wordpress and activated it. Did a test post with a link, and my tag did not show. Can anyone steer me right?
Link to comment
https://forums.phpfreaks.com/topic/26354-need-help-writing-a-wordpress-plugin/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.