| | #1 |
| PHP Geek :) War Room Member Join Date: 2010 Location: Montreux, Switzerland
Posts: 89
Thanks: 41
Thanked 14 Times in 14 Posts
|
I am coding a wp plugin and when I am trying to use a library it is saying that some other plugin has declared that library and so I cannot redeclare that thing.. ![]() So i was jus wondering what needs to be done to overcome this problem....I can manage to play with this plugins but was just wondering how to approach this problem if I am gonna sell this plugin...I cannot ask my clients to uninstall some other plugin to get my plugin working so... ![]() Any help would be really appreciated |
| |
| | #2 |
| Active Warrior Join Date: 2007 Location: Sweden
Posts: 84
Thanks: 7
Thanked 11 Times in 11 Posts
|
I had this exact same problem when I started developing my auto-blogging plugin Roboblogger . Here's how I solved it: Code: if (!class_exists('Smarty')) //Template Engine
{
require_once(dirname(__FILE__) . '/vendor/plugins/Smarty-3.0.7/libs/Smarty.class.php');
} |
| |
| | #3 | |
| Banned War Room Member Join Date: 2006 Location: The Hague,Netherlands.
Posts: 1,077
Thanks: 384
Thanked 220 Times in 136 Posts
Blog Entries: 1 |
Or you can rely on the class/functins already loaded and if it's a very common thing then that would be probibly best but if it's not it holds the risk that it's modified by the other developer and will not do what you expect it to do. I always have the names of my classes and functions started with the name of my plugin to make sure it won't clash with others and to overcome issues like these HtH Edwin | |
| |
| | #4 |
| Software Engineer War Room Member Join Date: 2008 Location: Asheville, NC USA
Posts: 693
Thanks: 37
Thanked 112 Times in 100 Posts
|
Renaming it could turn out to be a pain in the butt if there's a huge number of classes and/or functions. This is because the functions could use each other internally. If you rename it an it breaks, I would just use the class_exists() or function_exists() method.
|
| I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs | |
| |
|
| Bookmarks |
| Tags |
| php |
| |