WordPress Plugin Boilerplate

Basic File Structure

  • admin – Code that is only used on the admin side of the site.
    • css
    • js
    • partials
  • includes – Code that is used on both the admin and public sides.
    • class-plugin-name.php – The core class for the plugin.
      • Used to keep plugin name and version.
      • Loads dependencies, including those in the other class-plugin-* files.
    • class-plugin-name-activator.php – Used when you need to perform an action upon plugin activation.
    • class-plugin-name-deactivator.php – Used when you need to perform an action upon plugin deactivation.
    • class-plugin-name-loader.php – Orchestrates the hooks of the plugin.
      • $actions and $filters – where the various hooks are stored.
      • add_action()
      • add_filter()
      • The hooks added through the above classes will be registered by the class run().
    • class-plugin-name-i18n.php – Defines internationalization functionality.
    • class-plugin-name-admin.php – Defines all hooks for the admin area.
    • class-plugin-name-plugin.php – Defines all hooks for the public side of site.
  • languages – Language files.
  • public – Code that is only used on the public side.
    • css
    • js
    • partials
  • index.php – Used to keep folks from browsing the directory when published to the web.
  • plugin-name.php – The initial file loaded by the plugin which then loads other files within the plugin.
  • uninstall.php – What should be done when the plugin is deleted, e.g. removing data, cleaning up files.
%d bloggers like this: