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: blog
Related Posts: