WP e-Commerce breaks intentionally other Plugins or Themescodestyling | 10. June 2011 | 12:29
Since days I got incomming questions about my plugin “Codestyling Localization” with the same problem: “Why does it not work?” I spent a lot time to find the reason for, thanks to a commenteer pointing me to the e-Commerce WordPress plugin. After activation of this plugin, my plugin suspends its functionality.
After investigation of e-Commerce I was shocked. I found code at this plugin showing a lot of ignorance in programming a plugin and doesn’t play cooperative with any other plugins or themes!
… keep the plugin working brute force
WP e-Commerce seems to claim the right, that it is the only one plugin at your blog. If it isn’t the case, this plugins claims the right to dictate, what other plugins can do or not. It behaves link a king and all other will get a bad break.
Where this harsh statement comes from? It’s very easy and can be shown best with code snippets from this plugin in version 3.8.4 from WordPress repository:
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 26 27 28 29 30 31 32 33 34 35 36 37
The above shown function will be executed if WordPress is about to display an administration page. Therefor WordPress calls the hook admin_head (beside others) and forces so the execution of the above shown function. Inside this function you will find the following part (can also be found inside a second function) that more precisely illustrates the problem:
// Prototype breaks dragging and dropping, I need it gone wp_deregister_script( 'prototype' );
Ahh, it is ok to remove for all administration pages the ability to utilize the prototype.js library, because somebody is not able to write code coping with the compatibility mode of protoype and jQuery ?
I would understand the fact, that a plugin author may protect it’s own adminstration pages against unwanted script code. But WP e-Commerce doesn’t care about if the page being rendered is it’s own one or one of an other plugin. I consider this as attack against all other plugins which are based on the prototype.js library!
known victim: “Codestyling Localization”
My Plugin is based on utilization of prototype.js library code and ensures, that this library will only be loaded, if one of my plugin admin pages are about to be rendered. But because WP e-Commerce has removed the ability to enqueue the library, my plugin doesn’t work any longer even if it’s correctly requesting the script library!
In my opinion this is not a accidentally break, it is an intentionally break of other plugins. I know a lot plugins loading additional code accidentally in backend pages and this I would name accidentally. But this removement is an intentionally break which harzards the consequences of malfunction at other plugins or themes!
Conclusion and Reaction
I have to circumvent this issue somehow. Currently I see only 2 ways to ensure my plugins functionality:
- I brutally load prototype.js at my own admin pages again.
- I present a fat, red warning message a my plugin pages if e-Commerce is active.
The last one is the worst one, because on the one hand side the user knows, where the issue comes from. But it doesn’t give the functionally of my plugin back to the user. So i only can go the first way and can only ensure a proper working plugin doing so (and only at my own plugin pages!).
I will also send a detailed explanation to the Authors of WP e-Commerce by mail. But independend from this I had to express it here loadly because this kind of rambo programming contradicts other authors good work. If this remains untold, it will never change.