This documentation describes unreleased changes on the main branch.

Plugin

Class.

use Saij\WpAppFramework\Plugin;

Boots the framework for a plugin and provides its paths.

The instance is created only by boot() and handed to the container as a predefined instance: the container never builds it, but services of a plugin can inject it to read the paths.

Methods

boot()

Plugin::boot(string $file): void

Boots the framework. Called once from the main plugin file: Plugin::boot(__FILE__). The main file must be {slug}/{slug}.php.

Release mode applies if the plugin contains generated/manifest.php (created only by the release build). Caches live in wp-content/cache/{slug}. Templates are looked up in overrides/{slug}/ of the child theme and the theme before the plugin's own src/. At its end, boot() fires the action wp_app_framework/init/{slug}.

ParameterTypeDefaultDescription
filestringrequiredThe main plugin file, __FILE__.

getDirectory()

getDirectory(): string

Directory of the plugin below WP_PLUGIN_DIR.

Returns string

getDirectoryUri()

getDirectoryUri(): string

URL of the plugin directory, without trailing slash.

Returns string

getFile()

getFile(): string

The main plugin file, as passed to boot() (__FILE__; a real path if the plugin is a symlink).

Returns string

getFrameworkDirectory()

getFrameworkDirectory(): string

Filesystem path of the framework package; never derive URLs from it.

Returns string

getSlug()

getSlug(): string

Directory name of the plugin; it names everything global of the framework instance.

Returns non-empty-string