Download the PHP package abuyoyo/plugincore without Composer
On this page you can find all versions of the php package abuyoyo/plugincore. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abuyoyo/plugincore
More information about abuyoyo/plugincore
Files in abuyoyo/plugincore
Package plugincore
Short Description WordPress plugin core helper class
License BSD-3-Clause
Informations about the package plugincore
WPHelper \ PluginCore
Helper class for registering WordPress plugins.
Plugin Boilerplates and boilerplate generator are a hassle. The file structure they impose is way too cumbersome (and redundant) to push into every single plugin. WPHelper\PluginCore replaces boilerplates with one simple class (usually hidden away somewhere in your vendor/
dir).
WPHelper\AdminMenuPage can be used to register and generate admin menus if your plugin requires that.
Requirements
Installation
Install with Composer or just drop PluginCore.php into your plugin folder and require it.
OR
WPHelper\PluginCore uses PSR-4 to autoload.
Basic Usage
WpHelper/PluginCore replaces the many plugin core skeleton generators out there. Just add these lines of code at the top of your plugin file and you're good to go.
WpHelper/PluginCore will define %PLUGIN%_BASENAME, %PLUGIN%_PATH, %PLUGIN%_URL, %PLUGIN%_FILE constants available to your code.
Constants
WPHelper\PluginCore defines constants for use in your code. Where __FILE__
is the filename provided to the class and %PLUGIN%
is the 'const'
option.
Like so:
These are the constants defined by WPHelper\PluginCore. There are some redundancies to account for different conventions.
- %PLUGIN%_PATH:
plugin_dir_path( __FILE__ ) )
- %PLUGIN%_DIR:
plugin_dir_path( __FILE__ ) )
- %PLUGIN%_URL:
plugin_dir_url( __FILE__ ) )
- %PLUGIN%_BASENAME:
plugin_basename( __FILE__ ) )
- %PLUGIN%_FILE:
__FILE__
- %PLUGIN%_PLUGIN_FILE:
__FILE__
Get Instance
All PluginCore instances can be referenced anywhere in your code using static method get()
and the plugin slug. Available on plugins_loaded
hook or later.