I have this little php I call from jqGrid url that I use inside an admin's wordpress plugin:

require_once($_SERVER['DOCUMENT_ROOT'] . '/xDl21my20/wp-load.php');
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
add_action( 'shutdown', function() {
   while ( @ob_end_flush() );
} );

global $wpdb;


$results = $wpdb->get_results($sql_select, OBJECT);

return json_encode($results);

but I see I don't receive any results and looking in the log I see this error:

[02-Jan-2022 09:05:32 UTC] PHP Notice:  ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/..../wp-includes/functions.php on line 5107

So since I added that remove_action as I read in other issues, it should have bypassed the ob_end_flush issue but it didn't... Maybe I forgot something or could be that related to PHP version installed PHP Version 7.4.27?... Any direction would be appreciated... cheers!!!

btw, zlib_compression is on in php.ini

  • So the original code was without the action? if thats the case you have a ob_get_clean() after a return, return, well, returns the value (in this case a json string) and stops there, no other code after return is being executed. But in genereal this code is strange, why there is a return? how do you access this code? why is there even ob_start() or any ob_ for that matter? Jan 2 at 12:19
  • Hi Buttered_Toast. - that "SELECT" is just a sample select from a certain table that returns some rows... - before to add ob_start() and ob_get_clean() it was without ob_start() neither ob_get_clean() but I got still the error.... - I added ob_start() and ob_get_clean() because I thought that error could be cause by $wpdb->get_results() which runs thanks to wp-load.php inclusion without success anyway...
    – Luigino
    Jan 2 at 14:45

1 Answer 1


Found the solution at the problem: using "return" wasn't the right way... have to use "echo" in this way because it isn't a function but a simple PHP that gives back an object. Thanks again to all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.