I'm developing a wordpress wordpress plugin and today I wish to make an ajax call. For the time being I follow this process.

  1. I produce a page through wordpress dashboard
  2. Produce a new Template file
  3. Put my PHP function for the reason that template file
  4. Assign that template to my new page.

So My ajax url is much like that http://mywordpresssite/custom_ajax (This essentially is really a wordpress page consider it features a custom template selected then when I send an ajax request for this I works best for me)

Now My question

I'm really fed up with creating wordpress page and using templates. Furthermore my plug ins aren't plugnplay since I have to create template in theme folder. And when accidently someone remove that custom_ajax page in the dashboard or trash then my functionality breaks.

It is possible to way to produce a page (or link) through my wordpress plugin after which I put my custom function inside it therefore if somene visit that link it really being able to access my custom function(like Code Igniter get it done). My real question is not particularly about ajax, I understand wordpress has a different way to cope with ajax however i simply want to know that's it possible to produce a page or link via a wordpress plugin and point it to some custom purpose of wordpress plugin.

Possibly I'm missing something, but this appears just like a really strange method of doing things. Why you cannot just add your function to some file inside your wordpress plugin directory and refer to it as when you wish for doing things? Use plugin_basename without notice to refer to it as.

http://codex.wordpress.org/Function_Reference/plugin_basename

So send your ajax call to plugin_basename(__FILE__)

UPDATE I want to supply more details by what exactly around the page you have to modify, but you should use wordpress hooks to include or modify content on the page. So for instance you are able to place code in to the mind of the page (css or js links, etc) with the addition of the next line for your wordpress plugin.

add_action('wp_head', 'your_function');

You will find a lot of these defined within the Wordpress Codex

You may also make your own shortcodes that may reference personal files inside your wordpress plugin directory.

http://codex.wordpress.org/Shortcode_API

You can then range from the code inside your pages by such as the shortcode.