After some deeper check, the above file may not be the problem after all, however your plugin causes “wp-load.php” to output bytes, and this is how to replicate it….
REPLICATION EXAMPLE
say you have a file testpdf.php
define('WP_USE_THEMES', false);
require_once('../wp-load.php');
header("Content-type: application/pdf");
readfile(get_site_url().'/wp-content/uploads/publications/test.pdf');
The above will serve the specified pdf normally without your plugin installed.
If you install your plugin the the above code does not return the pdf, because it adds bytes to the pdf, aka corrupting it…
so with your plugin installed, the only way to make it work is to ob_end_clean() whatever after the “required wp-load.php”.
That is your plugin adds some output to the wp-load.php….
So the only way for the above code to work while your plugin is installed is to do the following….
ob_start();
define('WP_USE_THEMES', false);
require_once('../wp-load.php');
ob_end_clean();
header("Content-type: application/pdf");
readfile(get_site_url().'/wp-content/uploads/publications/test.pdf');
CONCLUSION:
Without your plugin, including the wp-load.php doesn’t add any bytes to the output, with your plugin it does….