Fixing NextGEN Gallery and wp-typography compatibility

I figured out what broke the images on this site a while back.

I run several plugins on this wordpress site, among which are NextGEN Gallery (an image gallery plugin) and wp-typography (which cleans up typography and styles certain parts of the text).

However, a patch of NextGEN gallery a while back broke the compatibility of these two, meaning that when wp-typography was active, NextGEN wasn’t able to find its own images.

Digging into the code a bit, I located the problem: wp-typography was running before NextGEN, causing the shortcodes for images to be styled using html and css tags. This in turn meant that NextGEN couldn’t interpret them properly, and thus could not find the images.

Looking deeper, it turned out that the priority of the plugin-hooks for wp-typography was set to 99, which was late enough for most things. However, NextGEN went for a more absolute value of PHP_INT_MAX.

Unfortunately, wp-typography is no longer actively updated by the author, so I had to fix it myself. To do this, which meant lowering the priority with which wp-typography was run.

To do this, I opened the file /wp-content/plugins/wp-typography/class-wpTypography.php, and located these lines:

add_filter('comment_author', array(&$this, 'process'), 99);
add_filter('comment_text', array(&$this, 'process'), 99);
add_filter('the_title', array(&$this, 'processTitle'), 99);
add_filter('the_content', array(&$this, 'process'), 99);
add_filter('the_excerpt', array(&$this, 'process'), 99);
add_filter('widget_text', array(&$this, 'process'), 99);
add_filter('widget_title', array(&$this, 'processTitle'), 99);

I then changed them to:

add_filter('comment_author', array(&$this, 'process'), PHP_INT_MAX);
add_filter('comment_text', array(&$this, 'process'), PHP_INT_MAX);
add_filter('the_title', array(&$this, 'processTitle'), PHP_INT_MAX);
add_filter('the_content', array(&$this, 'process'), PHP_INT_MAX);
add_filter('the_excerpt', array(&$this, 'process'), PHP_INT_MAX);
add_filter('widget_text', array(&$this, 'process'), PHP_INT_MAX);
add_filter('widget_title', array(&$this, 'processTitle'), PHP_INT_MAX);

One caveat: This gives wp-typography the same priority as NextGEN, so in theory, things could still fail. In my case, it works, either because the plugins are run alphabetically, or because NextGEN was installed earlier and thus is located higher up in the database.

The end result was that the shortcodes for NextGEN started working again. I’ve updated most of the posts (again), so the pictures show up as popups as they’re supposed to, instead of replacing the current page like they did after my hotfix a while back.

2 Comments

Leave a Reply

Your email is never shared.Required fields are marked *