WordPress Plugin Development Structure
A scalable and maintainable folder structure for WordPress plugin development
File Structure
- my-plugin.php
- uninstall.php
- includes
- class-my-plugin.php
- class-loader.php
- class-activator.php
- class-deactivator.php
- core
- class-database.php
- class-settings.php
- api
- class-rest-api.php
- endpoints
- admin
- class-admin.php
- pages
- settings.php
- dashboard.php
- partials
- admin-display.php
- css
- js
- public
- class-public.php
- partials
- public-display.php
- css
- js
- templates
- single-custom-post.php
- archive-custom-post.php
- widgets
- class-custom-widget.php
- shortcodes
- class-shortcodes.php
- languages
- my-plugin.pot
- assets
- images
- fonts
- readme.txt
- CHANGELOG.md
Directory Structure Explanation
includes/class-loader.php
Loader class that manages hooks and filters registration for the plugin.
includes/core/
Core plugin functionality including database operations and settings management.
includes/api/
REST API functionality for exposing plugin data and operations via WordPress REST API.
admin/pages/
Individual admin page files for different sections of the plugin admin interface.
admin/partials/
Reusable admin template parts and partial views for the admin interface.
public/partials/
Reusable frontend template parts and partial views for public display.
templates/
Custom template files for post types and archives that override theme templates.
widgets/
Custom WordPress widget classes for adding plugin functionality to widget areas.
shortcodes/
Shortcode functionality for embedding plugin features in posts and pages.
assets/
Static assets like images and fonts used by the plugin.