I have written a Wordpress plugin in PHP and I want to output JSON without any wordpress theme html and other boilerplate. But I do need to interact with other plugins and the WP-Settings information. What is the best way to do this? I currently have a theme file called JSON outputter that just calls a method of a class that wants to output the JSON, is there a better way?
EDIT: Let me give an example:
I have the following index.php file in my plugin named jsonOutput:
<?php // I need wp-config information here $info = DB_NAME; new otherPlugin(); header('Content-Type: application/json'); echo json_encode(array("test"=>"data"));
if I just access the following file via myserver.com/wp-content/plugins/jsonOutput/index.php then I don't have access to the wp-config info, all the other plugin or the other parts of Wordpress.
What is the best practise to output just JSON and not the header and footer and title and other things that wordpress and/or the theme adds. I want to know that the preferred way to do this is.
My current way works but I don't feel that it is the best way to do this.
P.S. I find the downvotes pretty harsh, I thought that I gave enough context but apparently not. If you need any more information just ask but a downvote only hurts my chances to find people that can actually help me.