Search for Resources and Solutions

How to create a plugin

A plugin in the Midrub CMS has a lot of features(it could process ajax requests, api requests, could use the cron job, could delete the user's records if has, could register hooks and even api permissions). Each plugin should follow this interface

Each plugin should be in a folder(which should have unique name). The folder name should be without spaces or special characters. The folder's name isn't used as plugin's name and you could give any kind of name to a folder by respecting the requests above.

In the plugin's folder with php files should be the file main.php which follow the Plugins interace.

The file main.php should have a class with these methods:

  • ajax - receives the ajax requests for plugin.
  • rest - receives the rest requests for plugins(this allows to create new api's endpoints).
  • cron_jobs - receives the cron job requests.
  • delete_account - is used when a user's account is deleted.
  • load_hooks - registers the hooks.
  • plugin_info - contains the user's information.

The plugin_info should return an array with these keys:

  • plugin_name - contains the plugin's name which is displayed in the administrator panel -> plugins.
  • plugin_description - contains the plugin's description which is displayed in the administrator panel -> plugins.
  • plugin_cover - contains the plugin's cover which is displayed in the administrator panel -> plugins.
  • plugin_slug - contains the plugin's slug.
  • version - contains the plugin's version which is displayed in the administrator panel -> plugins.
  • update_url - contains the update's url from where will be updated the plugin.
  • update_code - contains boolean TRUE or FALSE. If is true means administrator should have a update code to update the plugin.
  • update_code_url - contains the page where user could get information about the update code.
  • min_version - contains the minimum's supported version.
  • max_version - contains the maximum's supported version.¬†

The plugin's cover is optionally.

Both folder with php and assets files should have same name.

Was this article helpful?