• 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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Saad

    (@protibimbok)

    Great Job! The problem with this issue is – it occurs to very few people and we could not reproduce it on our ends.
    Since you can, and you are familiar with coding, instead of doing all of these changes could you please try opening: /wp-content/plugins/wp-table-builder/v2/inc/WPTableBuilder.php (line 102) and replace

    Assets::print();

    with

    add_action('admin_footer', function () {
    Assets::print();
    });

    And see if the issue is resolved?
    And make sure you check the post edit/add page too.

    Thread Starter BlogLogistics

    (@ac2a)

    Thanks Saad @protibimbok

    I restored the original plugin files then completed the suggested single edit.

    Then the log get’s populated with:

    [23-May-2025 15:07:48 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

    I observed this error gets repeatedly logged only when duplicating, editing, etc. tables in wp-admin. It does not log when viewing front-end content.

    I hope this information helps out! 🙂

    Plugin Contributor Saad

    (@protibimbok)

    Thank you for your feedback.
    We are looking into it.

    Plugin Contributor Saad

    (@protibimbok)

    Hello @ac2a,
    A new version has been released with the fix.
    Please check and confirm if the issue is resolved.
    Thank you

    Thread Starter BlogLogistics

    (@ac2a)

    Thanks Saad @protibimbok

    Sorry, still getting the issue.

    [26-May-2025 15:49:28 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:82) in /home/xxxxxxxxxx/public_html/wp-admin/admin-header.php on line 14

    This only happens when in the backend, duplicating tables and then editing them. I see no such log entries when surfing front-end pages containing tables.

    Based on the log entry, it suggests a redirect or setting cookies occured, but it was too late, output had already been sent to the browser. It could be a space, newline, or echo that’s the cause? – Since PHP sends HTTP headers before any actual content (like HTML or echo output).

    Update…

    At line 82 of /wp-content/plugins/wp-table-builder/v2/inc/Utils/Assets.php, we see this:

    echo '<script type="text/javascript">var WPTB_CFG = ' . json_encode($data) . ';</script>';

    The echo sends output to the browser. Once that happens, PHP can no longer send HTTP headers, which are needed for things like redirects, setting cookies, or any call to header().

    So later, when admin-header.php (called by WordPress core) tries to send headers, which it always does – PHP throws a warning because it’s too late.

    • This reply was modified 11 months, 3 weeks ago by BlogLogistics.
    • This reply was modified 11 months, 3 weeks ago by BlogLogistics. Reason: Typo
    Plugin Contributor Saad

    (@protibimbok)

    That’s unfortunate to know.
    Can you please replace the content of the file: /wp-content/plugins/wp-table-builder/v2/inc/Utils/Assets.php with WP Table builder v2.0.7 headers already sent fix – Pastebin.com
    and report back to us?
    Thank you

    Thread Starter BlogLogistics

    (@ac2a)

    Okay Saad @protibimbok

    That worked.
    Terrific!

    I’m not seeing new errors posted to the log.

    Thank you 🙂

    Plugin Contributor Saad

    (@protibimbok)

    Thank you for your cooperation.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Assets.php causes headers already sent error’ is closed to new replies.