I'm developing a wordpress wordpress plugin and today I wish to make an ajax call. For the time being I follow this process.
- I produce a page through wordpress dashboard
- Produce a new Template file
- Put my PHP function for the reason that template file
- 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.
So send your ajax call to
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.
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.
You can then range from the code inside your pages by such as the shortcode.