• Resolved alx359

    (@alx359)


    Have a plugin that’s inserting some misplaced markup before DOCTYPE in the checkout page, so the browser switches into quirks mode (FF/W10). Have tried to filter it out with something like this:

    add_action('wp_head', 'header_fix', 0);
    function header_fix() {
        $html = ob_get_clean();
        #error_log( var_export( $html, true ) );
        echo strstr( $html, '<!DOCTYPE' );
    }

    It appears to work. However, it also affects PhastPress. The checkout page displays with a broken layout and the phastpress_disable filter doesn’t work to exclude it. Only deactivating PP completely fixes the issue. Please advise.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Albert Peschar

    (@kiboit)

    Using ob_get_clean affects PhastPress’ output buffer apparently. The disabling might not work because it’s done too late (after PhastPress has already started).

    Anyway, instead of using ob_get_clean to end the existing output buffer, use ob_start as a filter itself:

    <?php
    
    ob_start(function (string $output): string {
      return preg_replace('~^.*(?=<!doctype)~is', '', $output);
    });

    This code should run before the problematic plugin. You can ensure this by placing it in a file in wp-content/mu-plugins (you may need to create this folder). Eg wp-content/mu-plugins/kill-output-before-doctype.php.

    Thread Starter alx359

    (@alx359)

    Thank you, Albert, that did the job.

    In functions.php it didn’t work, but in mu-plugins it did.

    I contacted the plugin developer suggesting your solution.

    (BTW, interesting way of writing ob_start() I’m not familiar with. Learning something new everyday ?? )

    Plugin Author Albert Peschar

    (@kiboit)

    Thanks for your follow up.

    The real solution is probably to fix the root cause that is outputting stuff before the <!doctype. There’s probably some mistake in the plugin code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘phastpress_disable not working’ is closed to new replies.