3.9 KiB
Usage Instructions
This guide provides instructions for using and customizing the WordPress Plugin Starter Template for your own plugin development.
Basic Usage
The WordPress Plugin Starter Template is designed to be a starting point for your WordPress plugin development. It provides a well-structured codebase that you can customize to create your own plugin.
Template Structure
The template follows a modular structure:
wp-plugin-starter-template.php
: Main plugin file with plugin headersincludes/
: Core plugin functionalityplugin.php
: Main plugin class that initializes everythingcore.php
: Core functionality classupdater.php
: Update mechanism for multiple sources
admin/
: Admin-specific functionalitylib/
: Admin classescss/
: Admin stylesheetsjs/
: Admin JavaScript files
languages/
: Translation files.github/workflows/
: GitHub Actions workflows.ai-workflows/
: Documentation for AI assistants.wiki/
: Wiki documentation templates
Customizing for Your Plugin
-
Rename Files and Update Namespaces:
- Rename
wp-plugin-starter-template.php
to your plugin name - Update the namespace from
WPALLSTARS\PluginStarterTemplate
to your own - Update text domain from
wp-plugin-starter-template
to your own
- Rename
-
Update Plugin Headers:
- Edit the plugin headers in the main PHP file
- Update GitHub/Gitea repository URLs
-
Customize Functionality:
- Modify the core functionality in
includes/core.php
- Add your own classes as needed
- Customize admin interfaces in the
admin/
directory
- Modify the core functionality in
-
Update Documentation:
- Update README.md and readme.txt with your plugin information
- Customize wiki documentation in the
.wiki/
directory
Advanced Usage
Adding Admin Pages
The template includes a structure for adding admin pages to the WordPress dashboard. To add an admin page:
- Uncomment the
add_admin_menu
method inadmin/lib/admin.php
- Customize the menu parameters to match your plugin
- Create the corresponding render method for your admin page
- Create template files in an
admin/templates/
directory
Adding Settings
To add settings to your plugin:
- Create a settings class in
includes/settings.php
- Register settings using the WordPress Settings API
- Create form fields for your settings
- Handle settings validation and sanitization
Adding Custom Post Types or Taxonomies
To add custom post types or taxonomies:
- Create a new class in
includes/
for your post type or taxonomy - Register the post type or taxonomy in the class constructor
- Initialize the class in
includes/plugin.php
Internationalization
The template is ready for internationalization. To make your plugin translatable:
- Use translation functions for all user-facing strings:
__()
for simple strings_e()
for echoed stringsesc_html__()
for escaped strings
- Update the text domain in all translation functions
- Generate a POT file for translations
Update Mechanism
The template includes an update mechanism that supports multiple sources:
- WordPress.org
- GitHub
- Gitea
To configure the update mechanism:
- Update the plugin headers in the main PHP file
- Customize the
updater.php
file if needed - Ensure your repository follows the required structure for updates
Building and Releasing
The template includes scripts for building and releasing your plugin:
-
Building the Plugin:
./build.sh <version>
-
Deploying to a Local WordPress Installation:
./scripts/deploy-local.sh
-
Creating a Release:
- Tag a new version in Git
- Push the tag to GitHub
- The GitHub Actions workflow will create a release
Next Steps
After customizing the template for your needs, refer to the Architecture Overview to understand the plugin's structure in more detail.