JIG Smart Deeplinking works by adding certain meta tags to the head of your page, but only in very specific circumstances, when it's actually needed. SEO plugins such as SEO by SQUIRRLY have a task to add good meta tags to every page. Some of them do it in a way that JIG can't overcome them, usually when they do output buffering with a search and replace to remove what's there already. You'll notice that when you disable such plugin, the JIG Smart Deeplinking feature starts to work. Instead of fighting with these plugins and changing their or JIG's source files (so you can't update), there is a better solution that is guaranteed to work.
A small must-use plugin (mu plugin) is necessary to disable the conflicting plugin but only when it's absolutely necessary and when JIG should be the one adding said meta tags. It'll leave all plugins untouched, updateable and as future-proof as it can be. It needs to be a must-use plugin before it loads sooner than regular plugins, allowing us to disable a plugin in time.
- Create a folder called mu-plugins in your wp-content directory on your server (if it doesn't exist already).
- Add the snippet below as selective-loader.php or whatever name you like.
- Change squirrly-seo/squirrly.php to the pluginfolder/mainfile.php of your conflicting plugin. You can figure out the "main file" of a plugin by going to its folder and looking for a file with a similar name as the plugin itself. It'll contain a comment block at the top stating the plugin's name among other info.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?php add_filter('option_active_plugins', 'enable_plugins_selectively'); function enable_plugins_selectively($plugins){ if(!empty($_GET['_escaped_fragment_']) && preg_match('%^([\w\-[\]]+?/(?:(\d+)(?=/))?(https?://[^&]*)?([A-Z]{2}/[_\w]*)?)%im', $_GET['_escaped_fragment_'])) { if (!(!in_array($_SERVER['HTTP_USER_AGENT'], array( 'facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)', 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)')) && stripos($_SERVER['HTTP_USER_AGENT'], 'Google (+https://developers.google.com/+/web/snippet/') === false && stripos($_SERVER['HTTP_USER_AGENT'], '+http://www.google.com/webmasters/tools/richsnippets') === false )) { // This is JIG Smart Deeplinking, the other plugin must be disabled $plugin_index = array_search('squirrly-seo/squirrly.php', $plugins); if($plugin_index !== false){ unset($plugins[$plugin_index]); echo '<!-- Removed squirrly-seo/squirrly.php via mu-plugins, to let JIG add og meta tags. -->'; } } } return $plugins; } |