Better way to handle plugins

enricodias4654

Member
YetiShare User
Jan 13, 2015
411
1
16
Hello.

I think the current method of handling plugins is inefficient. The script needs to check if multiple files exists on every plugin folder every time. Useless information is also loaded in the session of all users, like plugin description.

It would be better if the plugins have a main class that would be initialized every time and this class will register hooks to be used. Those hooks could be registered in a php array. So, instead of checking if a file exists every time the script could check registered hooks in an array. This could also be used to add css and js only in specific pages.

The hooks could call a method from the plugin's class to preserve the scope. This method will also allow the use of permissions on plugins. When installing the plugin the user could select permissions for the plugin, selecting which hooks it would be allowed to register and which database tables it will be able to access. This will prevent a plugin from having full control of your script.