Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
DreamOn Posted April 22, 2020 Posted April 22, 2020 Hello, I'm creating a plugin for IPS with many hooks. I want all my plugin hooks can access to a PHP function but I don't know where to define this function, I would like to define a custom class in the plugin but how? For the moment, I have created a hook of \IPS\Settings with my PHP function: class hook13 extends _HOOK_CLASS_ { public function myFunction() { ... myFunction() is reachable by all plugin hooks via \IPS\Settings::i()->myFunction() but it's not clean, the PHP function is reachable by all others plugins and could create conflict. Do you know how can I have a PHP function reachable by all hooks in a plugin? Thanks!
bfarber Posted April 22, 2020 Posted April 22, 2020 The method you are describing is fine. Plugins can't really add their own classes cleanly like an application can so unless you want to build an application instead of a plugin, just add your methods to an existing class. DreamOn 1
DreamOn Posted April 22, 2020 Author Posted April 22, 2020 5 hours ago, bfarber said: The method you are describing is fine. Plugins can't really add their own classes cleanly like an application can so unless you want to build an application instead of a plugin, just add your methods to an existing class. Thanks @bfarber. So I have to define function with unique name to prevent conflict with others plugins?
Recommended Posts