Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szepeviktor/starter-plugin
Template for WordPress plugins, it took 7️⃣ years to write
https://github.com/szepeviktor/starter-plugin
composer editorconfig php phpcs phpstan wordpress wordpress-plugin
Last synced: 17 days ago
JSON representation
Template for WordPress plugins, it took 7️⃣ years to write
- Host: GitHub
- URL: https://github.com/szepeviktor/starter-plugin
- Owner: szepeviktor
- License: mit
- Created: 2020-06-14T12:38:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-12T08:21:52.000Z (7 months ago)
- Last Synced: 2024-10-09T10:06:28.064Z (27 days ago)
- Topics: composer, editorconfig, php, phpcs, phpstan, wordpress, wordpress-plugin
- Language: PHP
- Homepage: https://github.com/szepeviktor/wordpress-website-lifecycle
- Size: 78.1 KB
- Stars: 52
- Watchers: 9
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ultimate WordPress Plugin Main File
_How to leave legacy technologies behind_
Source code in [`plugin-name.php`](/plugin-name.php) needs PHP 7 which is present on more than
[90% of WordPress installations](https://wordpress.org/about/stats/#php_versions).## Support my work
Please consider sponsoring me monthly if you use my packages in an agency.
[![Sponsor](https://github.com/szepeviktor/.github/raw/master/.github/assets/github-like-sponsor-button.svg)](https://github.com/sponsors/szepeviktor)
## Parts of plugin main file
- [Header comment](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields)
- [PHP strict types](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict)
- [PHP namespaces](https://www.php-fig.org/psr/psr-4/#2-specification)
- Prevent direct execution
- Load autoloader
- Prevent double activation
- Define constant values in an immutable container
- Load translations
- Check requirements
- PHP and WordPress minimum version
- Multisite installation
- Other plugins
- Current theme
- Composer packages
- Hook plugin activation functions
- Support [WP-CLI](https://wp-cli.org/)
- Display admin notice and deactivate plugin on error:bulb: Anything else goes into a separate file.
## What to avoid
- :x: Global constants
- :x: Global functions
- :x: Classes without namespace
- :x: Loading PHP files with `require`
- :x: Code with [side-effects](https://www.php-fig.org/psr/psr-1/#23-side-effects) outside the main file
- :x: Immediate execution without `add_action` in the main file
- :x: Conditional function or class definitions---
![Required PHP Version](https://img.shields.io/wordpress/plugin/required-php/bbpress)
![Required WP Version](https://img.shields.io/wordpress/plugin/wp-version/bbpress)## Installation
1. Get the plugin ZIP from ...
1. Upload to Plugins / Add new / Upload `/wp-admin/plugin-install.php?tab=upload`## Usage
1. Adjust settings ...
1. Or add a hook `add_filter('project/enable', '__return_true');` to `functions.php`