Support » Plugin: WP Meta SEO » Wrong usage of output buffering

  • Resolved Nextendweb

    (@nextendweb)


    Hi @joomunited,
    I’m the developer of Smart Slider 3 plugin and I found a conflict in your code. The problem is that you are closing an output buffer in wp-meta-seo.php which is not opened by your plugin which means that you are closing someones else’s output buffer. (In this case Smart Slider 3, but you probably have conflicts with other plugins too.)

    Issue lies here:

    add_action('plugins_loaded', 'wpmsFrontendInit', 15);
    function wpmsFrontendInit()
    {
        if (is_plugin_active('divi_layout_injector/divi_layout_injector.php')) {
            add_action('get_header', 'bufferStart');
        } else {
            add_action('template_redirect', 'bufferStart', 999);
        }
    }
    
    add_action('wp_head', 'bufferEnd');
    require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-front_end.php');
    $GLOBALS['metaseo_front'] = new MetaSeoFront;
    function bufferStart()
    {
        ob_start("wpmsCallback");
    }
    
    function bufferEnd()
    {
        ob_end_flush();
    }

    I’m not sure what is your intention with add_action('wp_head', 'bufferEnd');, but probably you are trying to close the output buffer you opened, so you might need to change your code to this as it will result that you only close the buffer if you really opened it:

    add_action('plugins_loaded', 'wpmsFrontendInit', 15);
    function wpmsFrontendInit()
    {
        if (is_plugin_active('divi_layout_injector/divi_layout_injector.php')) {
            add_action('get_header', 'bufferStart');
        } else {
            add_action('template_redirect', 'bufferStart', 999);
        }
    }
    
    require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-front_end.php');
    $GLOBALS['metaseo_front'] = new MetaSeoFront;
    function bufferStart()
    {
        ob_start("wpmsCallback");
    
        add_action('wp_head', 'bufferEnd');
    }
    
    function bufferEnd()
    {
        ob_end_flush();
    }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Wrong usage of output buffering’ is closed to new replies.