Dead shortcodes and how to find them

Have you ever looked at your plugin list and wondered whether you actually using it anywhere?  Or perhaps deactivated a plugin or swopped themes without realising that you  now have a dead shortcode on a page or post somewhere telling the world that you really aren’t on  top of things in your websites.

Yes well, it happens.  This little plugin may help.

amr-shortcodes searchs through your published or future posts, pages etc looking for shortcodes.  It then lists the pages and the shortcodes that appear on them, with handly little links to edit the post.  It will also flag with a red cross if wordpress does not know about that shortcode anymore – ie the shortcode is dead and there is no function that will switch out the shortcode text for some wonderful other text.

It does not automatically delete the dead text, because you reallly should look at the page or post and delete any surrounding text as well that may no longer be relevant.

And then, just because it might be interesting, I added a tab so you can see the available shortcodes.

View and Manage shortcodes




Debugging a possible clash between plugins and/or a theme

from one of my favourite comics

Put your site into maintenance mode and then Disable any caching plugins and be aware you may need to clear your browser cache too, to ensure you are  seeing ‘new’ behaviour when you are testing.

Quick and Brutal Approach (gives you info the fastest)

deactivate all plugins except the plugin you trying to get working. This has the advantage of quickly telling you if the plugin does/does not work by itself:

  • Problem gone when just that plugin?  The plugin itself might still be causing the clash, but at least now you have some info to pass on to the developers.  Follow the’ problem gone’ after theme switch below.
  • Problem still there ? Switch to a default theme.  Themes do sometimes mess with wordpress operation.
    • Problem still there ? If you now have just the one plugin active and you are sure you are seeing updated pages, you can advise the plugin author that you are seeing the problem on a default wp theme and with no other plugins active.
    • Problem gone? Ok,  now go back to your theme.
      • If the problem reappears you know it is something clashing between your theme and the plugin.  Advise both authors with as much detail as you can.
    • Problem still gone now that you have your theme back?  Now slowly, checking after each activation, reactivate your plugins, starting with your most essential ones.  At some point the problem will re-occur, then you know the clash is between the most recently activated plugin and your new problem one.
    • Problem stays gone once all is reactivated? Weirdly this can happen.  Sometimes it is the order of activation that causes the problem.  Don’t close your eyes and celebrate – a plugin update could cause the problem to come back.  Now you may have to play around with activation sequences here to find the clash

Slow and Steady also gets there in the end

Another approach is step by step deactivation and  switch theme to default theme until the problem disappears.

At some point the problem may go away, then reactive the last plugin active and check if the problem comes back.   Now you know it is part of the ‘clash’ somehow.

Must use plugins

If you have plugins showing up as ‘must use’ plugins and the problem is still there after deactivating other plugins and using default theme, you may need to use ftp or your control panel file manager to temporarily move the must use plugins in case there is code in there that is causing the clash.

Warning for older themes, or perhaps not so well written themes

Most themes should keep their settings and widgets and all should be fine when you switch back to that theme.  There some that don’t.  Make sure you have a backup that you know how to restore from OR that you know your theme’s settings and what widgets were being used where.

Recently Active Plugins

Your temporarily deactivated plugins will be in ‘recently active’.   This makes it really easy to reactivate them.

If you are one of those folks who keeps a lot of deactivated plugins hanging around and you forget which ones you really need, don’t panic – WordPress very nicely gives you a week in which it remembers which plugins you had active recently.

Call current_user_can after init()

Running buddypress? Are you getting a debug notice like this:

The current user is being initialized without using $wp->init()

and you cannot figure out where it is coming from ?

Most likely one of your plugins is calling a user related wordpress function a bit early (see wordpress action sequence).   You could try deactivating them until the debug message goes away.  The last plugin deactivated will be it.  Let the developer know because his/her code may not be quite working the way it was intended to.

eg: current_user_can()  or possibly  wp_set_current_user()

These need to be used after the init action.  The plugin or theme might have something like

add_action ('plugins_loaded', 'some_function');

The action should be added later, when the current user has been initialised.

add_action ('init', 'some_function');