Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
How to version-proof customizations?
Avatar
chris.crabtree
Member
Free Members
sp_UserOfflineSmall Offline
Jan 23, 2013 - 9:05 am

From time to time, I may need to modify certain functions in SP, or more likely, one of its plugins.

I would like to be able to do so in such a way that updates to SP or one of its plugins does not overwrite my customization. In this way, I can evaluate the changes in the new version and decide in an organized fashion whether I can safely remove my customization (obviously, this would be preferred), or if I need to leave it in place or even modify it further.

Apart from filters and action hooks, what is the best practice way to do this in PHP/WordPress/SP?

For example, the file sp-email-post-imap.php contains a function sp_process_inbox_imap(). Let's assume for discussion that this function is not called as part of a filter or hook chain.

If I wanted to modify sp_process_inbox_imap(), is there a way to do it so that my mods won't be overridden by future updates to sp-email-post-imap.php?

I am new to PHP & WordPress, so forgive me if this is either a FAQ or an impossibility, but I was thinking along these lines.

Define my own plugin: call it MySPCustomizations and in that plugin redefine the sp_process_inbox_imap() function. If my function is defined after SP's function, will mine always be called?

Or is there a better way? Appreciate any guidance here!

Thanks!

 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 23, 2013 - 12:09 pm

The bottom line and simple truth is that of you change code in any plugin or core then it will get lost on subsequent updates. It is possible to create alternative functions that already exist in the WP or SP core (look at the 'pluggable.php' file in the WordPress code for examples of how to do this) but this needs the original core code to be created specifically for that purpose.

We have tried to use filter and action hooks as extensively as possible to enable custom coding to be achieved without disturbing supplied code but that will always have certain limitations. I would suggest that if you decide you need to make changes and when you work out what they are, see if they could be achieved with the addition of a new filter/action as we will always be willing to add new ones into core. if not come and talk it over with us and we can see if we can come up with a model that would allow you not to lose your custom code.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 23, 2013 - 8:25 pm

but you could change the name/version and make it your own plugin... then it wont get over written... but of course, you wont get any updates either...

Avatar
chris.crabtree
Member
Free Members
sp_UserOfflineSmall Offline
Feb 1, 2013 - 9:21 pm

Sounds very reasonable, guys. I will, hopefully, not need to do many changes anyway, but just curious what the best practices are in this world. The filters and discussion about where new filters could be needed is a great approach. thanks!

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Feb 1, 2013 - 10:29 pm

let us know how you make out with it...  we can offer guidance if needed or perhaps more hooks...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625