Plugin Deactivation Issues Solved With Actions and Filters

Posted by admin in WordPress, Wordpress... | 06.07.2008 - 5:45 pm

When Jeff wrote about plugin deactivation breaking your blog, Aaron and I wrote in the comments of a few solutions to prevent plugin issues with themes.
Within this post I will present several techniques plugin and theme authors can take in order to prevent deactivation issues.
Method 1: function_exists
In this example, let’s assume we have a function named related_posts.
When in a theme, we could use this code to call the function if only it exists.

<?php if (function_exists("related_posts")) { related_posts(); } ?>

The PHP function_exists checks for the existence of the function, and if it does exist, it calls the function.
Method 2: function_exists and Actions
Using the same function name, the theme author could add some code into their functions.php file and use an action and function_exists combination.

if (function_exists('related_posts')) {
add_action('my_related_posts', 'related_posts');
}

In the above example, we create a new action called my_related_posts.
The end user would use the do_action function where he wants the […]

Original post by Ronald Huereca

    Technorati Tags:

    Related Posts:
  1. Akismet Updated, Connectivity Issues Solved
  2. ...
  3. Akismet Updated, Connectivity Reporting Issues Solved
  4. ...
  5. Actions and Filters and Classes, Oh My!
  6. ...
  7. If Plugin Deactivation Breaks Your Blog
  8. ...
  9. WordPress Favorite Actions and Custom Write Panels
  10. ...
  11. Plugin Review: WordPress Filter
  12. ...
  13. Notify Unconfirmed Subscribers Updated
  14. ...
  15. WordPress Plugin Releases for 03/02
  16. ...
  17. WordPress Plugin Development Beginner’s Guide
  18. ...
  19. WordPress Plugin Releases for 04/17
  20. ...
  21. Tackle Plugin Compatibility Issues While Using Popular Libraries
  22. ...
  23. WordPress Theme Releases for 04/09
  24. ...
  25. Comment Remix - Video Plugin Review
  26. ...
  27. Uninstalling Conundrum Part 2
  28. ...
  29. WordPress Version 2.8.3 Security Release
  30. ...

  31. No Comments on "Plugin Deactivation Issues Solved With Actions and Filters" »

    No comments yet.

    Leave a comment