Skip to content

A WordPress plugin starter to use as a starting template to build a custom plugin using namespaces

Notifications You must be signed in to change notification settings

xiki808/wp-plugin-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

WordPress Plugin Starter

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

Template

Getting Started

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.

  1. Replace the prefix WPS\ in wp-plugin-starter.php with your custom one.
  2. Replace the prefix in files Back/Init.php and Front/Init.php.

The template code is organized under two main namespaces:

  • Includes/Back for back-end related code
  • Includes/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.

Credits

About

A WordPress plugin starter to use as a starting template to build a custom plugin using namespaces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages