Support » Plugin: Lightbox with PhotoSwipe » Problem with Yoast SEO

  • Resolved Joris van Montfort

    (@jorisvanmontfort)


    I have been investigating a problem on a website using Yoast SEO combined with your plugin. Somehow the data-width and data-height attributes that your plugin adds to the page markup to make it all work get removed by Yoast SEO. I am not sure if the problem is with Yoast SEO or with your plugin.

    Changing the priority of the template_redirect hook in your plugin code has now worked as a quick fix for me. In lightbox-photoswipe.php line 75 I changed the following:

    add_action('template_redirect', array($this, 'outputFilter'), PHP_INT_MAX);

    to:

    add_action('template_redirect', array($this, 'outputFilter'), 0);

    I will be sending an email to Yoast SEO support asking them to have a look into this also.

    Is there a specific reason to use PHP_INT_MAX to keep the priority of this hook as low as possible?

    Any help on this issue apreceated. I don’t yet fully understand what is going on as I have the same set of plugins working on another website without any problems.

    Kind regards, Joris van Montfort

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi, maybe I should have mentioned: I am using Yoast SEO premium version 12.4.

    Spotted the same issue. Using free Yoast, latest WP, latest Yoast.

    • This reply was modified 3 months, 1 week ago by Rok Balboa.
    Plugin Author Arno Welzel

    (@awelzel)

    According to https://developer.wordpress.org/reference/functions/add_action/ the priority should be the highest possible number to have the filter run as the last one:

    Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

    So a value of 0 means, the filter would run as early as possible and PHP_INT_MAX (higher number) would mean as late as possible (later execution).

    Or maybe I misunderstand the documentation completely.

    Hi Arno,

    Thanks for your reply. I think you are right about the execution order / priority. Still it seems strange that Yoast SEO would somehow override the modifications done to the links most probably very last in the execution chain while changes done first (at priority 0) are kept.

    I am going to investigate a litter further on a staging enviroment and will post a reply if I find anything new worth mentioning.

    I haven’t found the exact solution, but I think the problem is related to some output buffer problem. Maybe some nested ob_start calls or something. Probably in Yoast SEO. I have stripped down my theme to the bare bones and only Yoast SEO and your plugin installed and the problem is still there. Once Yoast SEO is active the page also says:
    Notice: ob_end_flush(): failed to send buffer of zlib output compression

    I will be contacting Yoast SEO support with some more details.

    Plugin Author Arno Welzel

    (@awelzel)

    Thanks for the information. Using ob_end_flush() in a WordPress plugin makes no sense. This function will tell PHP to stop buffering and send the buffer. But this happens anyway – there is usually no need to call this function.

    When compression is enabled on the server, errors like this can happen when a plugin calls ob_end_flush() itself since this conflicts with the wp_ob_end_flush_all() (also see https://developer.wordpress.org/reference/functions/wp_ob_end_flush_all/).

    At least this would be an explanation, why my plugin works with the lowest priority – it will call ob_start() to modify the content of the page before it is send to the browser (or other plugins which use ob_start() as well).

    However – when the Yoast SEO plugin called ob_end_flush() before, there is no output buffer any longer and my plugin will just do nothing at all.

    Thanks for your thoughts Arno. The problem seems rather strange and must be related to Yoast SEO.

    I removed this specific option from the WordPress options table in phpmyadmin:

    DELETE FROMwp_optionsWHEREwp_options.option_name= 'wpseo_titles';

    This solves the issue and might be of some help to others.

    Ok, Yoast SEO investigated the problem and it seems to be related to a setting Force rewrite titles feature (SEO > Search Appearance) within Yoast SEO. Either disable this or add support to your theme for title tags by adding:

    add_theme_support( 'title-tag' );

    to the theme.

    https://kb.yoast.com/kb/the-seo-title-output-for-the-plugin-doesnt-work-as-expected

    Consider it fixed.

    Plugin Author Arno Welzel

    (@awelzel)

    Thank you for this update.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.