I have made a Wordpress Plugin that is a kind of Download Manager. I have a external file download.php that is responsible for making downloads. This file is away of environment Wordpress, for this reason I must called:
$wp_root = dirname(dirname(dirname(dirname(__FILE__)))); require_once $wp_root.'/wp-load.php';
and I can use $wpdb for my sql query.
Note: This file must be external because I use functions "headers()" for force the download.
header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: ".$ctype); header("Content-Length: ".$size); header("Content-Disposition: attachment; filename=".$info->url_file); header("Content-Transfer-Encoding: binary");
My plugin works great!, But when I want to publish it on the Wordpress repository, they answered me that it is forbidden to directly call wp-load.php or wp-config.php
Including wp-config.php and / or wp-load.php is not a good idea and we cannot approve a plugin that does so unless it has a very good reason to load the file(s). It is prone to failure since not all WordPress installs have the exact same file structure.
I don't know that use for I can use $wpbd
This is my plugin -> http://demo.gopymes.pe/social-godownload/