Assets.php causes headers already sent error
-
I think I found an issue that needs attention.
I see ongoing entries that are stacking up in the PHP error log:
[22-May-2025 19:19:43 UTC] PHP Warning: Cannot modify header information – headers already sent by (output started at /home/xxxxxxxxxx/public_html/wp-content/plugins/wp-table-builder/v2/inc/Utils/Assets.php:79) in /home/xxxxxxxxxx/public_html/wp-admin/admin-header.php on line 14
WP Table Builder seems to accidentally send output (text, spaces, or something else) too early. This confuses PHP and causes that warning. It’s kind of like trying to seal a letter after it’s already dropped it in the mailbox — it’s too late!
I was able to fix the issue and test that everything’s working, by doing the following below.
Open file: /wp-content/plugins/wp-table-builder/v2/inc/Utils/Assets.php
Caveat: Make a backup of this file first! 😉Find this:
echo AssetLoader::get_scripts();and replace with this:
add_action('admin_footer', function () {
echo AssetLoader::get_scripts();
});Also, find this:
echo '<script type="text/javascript">var WPTB_CFG = ' . json_encode($data) . ';</script>';and replace with this:
add_action('admin_footer', function () use ($data) {
echo '<script type="text/javascript">var WPTB_CFG = ' . json_encode($data) . ';</script>';
});Then test that things are working.
In my case this fixed the issue, log does not get filled with repeated entries and WP Table Builder continues to work great.
I hope this helps others out.
The topic ‘Assets.php causes headers already sent error’ is closed to new replies.