How to allow a standalone page to access WordPress features without including / needing wp_load or wp_config ?
I am developing a plugin and should allow access to the WP database on a separate php page. This page is just a curl request that returns the full HTML page to display. For context, the plugin is a list of tasks from the API, which then must refer to the full job announcement (full HTML page).
The code I currently have is this (on the jobad.php page):
$root = dirname(dirname(dirname(dirname(dirname(__FILE__))))); if (file_exists($root.'/wp-load.php')) { require_once($root.'/wp-load.php'); }
This is the code I extracted from each answer I found on how to do this. Including in own wordpress.org forums. From this stackoverflow answer, for example: Using WPDB in a standalone script?
It works fine, but when I tried to send the plugin to the WP directory, the plugin was rejected to enable wp_load.php this way. It makes sense, why not, but I can't find another way to get the file to work in WordPress.
The result I need
From the list generated by the short code, each element has a link that will return the full HTML page. This HTML page is returned as a cURL response, not a URL (or I can simply specify that each channel bind an iframe). For context, I create a link this way
$job_ad_link = plugins_url( 'includes/jobad.php' , dirname(__FILE__) ); $job_id = //id from database; <a href="'.$job_ad_link.'?sgjobid='.$job_id.'">link</a>
So calling jobad.php will run the cURL function for the correct job_id and display the cURL response. I can run cURL as AJAX and avoid this problem, but since it is a full HTML page, I cannot just return cURL to a div. The iframe is awkward and uncomfortable, and I would prefer not to use it (and not succeed in trying).
For clarification, the answer is from WordPress:
Including WP-config.php, WP-blog-header.php, including-load.php, or almost any other WordPress> main file that you must call directly through the included is not a good idea, and we don’t can> approve a plugin that does this if it does not have a good reason to download the file (s). This> crash tendency, because not all WordPress installations have the same file structure.