0

Possible Duplicate:
How to Rewrite Wordpress URL for a Plugin

I'm creating a plugin for Wordpress. Is there any way or API to make plugin receive a path or URL so that it can trigger or output something. I mean something like this

add_filter('THE_FILTER_NAME', 'myPluginFunc');
function myPluginFunc($url)
{
    if($url != 'mydesiredurl')
        return;

    echo "this URL path is handled by myplugin";
}

or

register_urlpath('mydesiredpath', 'mycallbackfunction');

and also, if applicable, this url path is registered to my plugin so users cannot assign any page using that url anymore, unless myplugin is deactivated.

EDIT: additional info

i'm creating plugin which need a path to be called as something like webservice, when the site is calling is a way, thedomain.com/myplugin, then what i want is the wordpress system understand that the URL requested is for myplugin, and therefore will execute a function myplugin supplied, which in my case, is simply send email to site admin.

Thanks in advance.

5
  • 1
    I am not clear about what you are trying to accomplish or what the path/URL is for, can you explain?
    – Jared
    Commented Feb 20, 2012 at 9:33
  • the URL i want achieve is something like url-rewriting, but instead rewriting url /the-path to /wp-contents/plugin/myplugin/thefile.php, is there any way wordpress will now, that when user request /the-path, call a function spesified by myplugin.
    – Lee
    Commented Feb 20, 2012 at 9:45
  • You could use wordpress built in way to rewrite.
    – kaiser
    Commented Feb 20, 2012 at 18:14
  • Why don't you simply create a page with that url/permalink ? And then use a custom template that just call the plugin function (or even place the code in to template). You'll be sure that this url cannot be used by any other page.
    – Simon
    Commented Feb 21, 2012 at 20:41
  • can that be done simply by activating my plugin?
    – Lee
    Commented Feb 22, 2012 at 8:30

0