I am currently writing a chatbox plugin for WordPress.
This plugin uses a jQuery.post() method to send data to a php file in order to write the output to an html file, which in turn will be loaded to the chat window using jQuery.
Inside the php file I use to write the chat log to an html file I need to use WordPress API functions, but this php file is not included by WordPress, and therefore has no access to the WordPress API.
Is there a way to send this chat data to a php file that is included by WordPress so I can use the WordPress API? What would be the best way to tackle this problem?
You can use
wp_localize_scriptfor sending ajax url in a JavaScript object to the pages:Then you can add an action and handle the request.
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_%28action%29
And for getting the url using JavaScript you can code: