A WordPress plugin starter to use as a starting template to build a custom plugin. The template encourages the use of namespaces as specified by PSR-4
The template uses a namespace prefix WPS\
, this can be changed to any other prefix you would like for your plugin, hence it needs to be replaced and used in every class file.
- Replace the prefix
WPS\
inwp-plugin-starter.php
with your custom one. - Replace the prefix in files
Back/Init.php
andFront/Init.php
.
The template code is organized under two main namespaces:
Includes/Back
for back-end related codeIncludes/Front
for front-end related code
A sub namespace can be used simply by adding a folder either in Includes/Back
or Includes/Front
folders, and add the path to the containing classes' namespace.
If a new namespace is needed, create the folder and add the namespace in wp-plugin-starter.php
before the $loader->register();
call.
$loader->addNamespace('{MYPREFIX}\{MYNAMESPACE}', __DIR__.'/Path/To/Folder');
// Before the register call
$loader->register();
Rename the plugin folder by changing both folder name and main file wp-plugin-starter.php
.