PHP Class Habari\Pluggable

Show file Open project: habari/system

Public Properties

Property Type Description
$info
$plugin_id

Protected Properties

Property Type Description
$_added_templates

Public Methods

Method Description
__construct ( ) Pluggable constructor.
_configure_plugin_config ( array $actions, string $plugin_id ) : array Registered to the plugin_config hook to supply a config via a plugin's configure() method
_configure_plugin_ui ( string $plugin_id, string $action ) Registered to the plugin_ui hook to supply a config via a plugin's configure() method
_filter_rewrite_rules ( array $rules ) : array Add the rewrite rules queued by add_rule() to the full rule set
_help_plugin_config ( array $actions, string $plugin_id ) : array Registered to the plugin_config hook to supply help via a plugin's help() method
_help_plugin_ui ( string $plugin_id, string $action ) Registered to the plugin_ui hook to supply help via a plugin's help() method
_plugin_available_templates ( array $list ) : array Add plugin templates to the list of templates that are present in the current theme
_plugin_include_template_file ( string $file, string $name ) : string Potentially serve a different file for the requested template name
add_rule ( mixed $rule, string $hook, Callback $fn = null ) Add a rewrite rule that dispatches entirely to a plugin hook
get_db_schema ( ) : string Gets a database schema associated with this pluggable
get_file ( ) : string Gets the filename that contains this pluggable class
get_url ( boolean | string $trail = false ) : string Get a fully-qualified URL directory that contains this pluggable class
get_version ( ) : string Provide a method to return the version number from a pluggable's info
get_xml_text ( string $filename, SimpleXMLElement $node ) : mixed | string Get the text associated to an info xml node, possibly using an href parameter
load ( ) Called when a pluggable is loaded to register its actions and filters.
load_hooks ( mixed $object ) Registers all of this class' action_ and filter_ functions with the Plugins dispatcher Registers xmlrpc_ functions with the Plugins dispatcher, and turns '__' into '.' for the purposes of matching dotted XMLRPC requests.
load_text_domain ( string $domain ) : boolean Load a translation domain/file for this pluggable
plugin_id ( ) : string Returns a unique id for this pluggable
upgrade ( ) Execute the upgrade action on any pluggable that has a version number change Update the version number of the pluggable in the database to what is installed

Protected Methods

Method Description
add_rest_rule ( string $hook, Pluggable $object, Callable $fn ) Adds a RewriteRule to the REST handler for the rule provided
add_template ( string $name, string $filename, boolean $override = false ) Adds a template to the default theme that is stored in a specified path.

Method Details

__construct() public method

This function creates some internal structures that are required for plugin processing Plugins should not define their own constructors, because they are instantiated to extract plugin info. Instead, include a sink for a "init" hook which is executed immediately after the plugin is loaded during normal execution.
public __construct ( )

_configure_plugin_config() public method

Registered to the plugin_config hook to supply a config via a plugin's configure() method
public _configure_plugin_config ( array $actions, string $plugin_id ) : array
$actions array An array of actions applicable to this plugin
$plugin_id string The plugin id to which the actions belong
return array The modified array of actions

_configure_plugin_ui() public method

Registered to the plugin_ui hook to supply a config via a plugin's configure() method
public _configure_plugin_ui ( string $plugin_id, string $action )
$plugin_id string The id of the plugin whose action was triggered
$action string The action triggered

_filter_rewrite_rules() public method

Add the rewrite rules queued by add_rule() to the full rule set
public _filter_rewrite_rules ( array $rules ) : array
$rules array The array of current RewriteRules
return array The appended array of RewriteRules

_help_plugin_config() public method

Registered to the plugin_config hook to supply help via a plugin's help() method
public _help_plugin_config ( array $actions, string $plugin_id ) : array
$actions array An array of actions applicable to this plugin
$plugin_id string The plugin id to which the actions belong
return array The modified array of actions

_help_plugin_ui() public method

Registered to the plugin_ui hook to supply help via a plugin's help() method
public _help_plugin_ui ( string $plugin_id, string $action )
$plugin_id string The id of the plugin whose action was triggered
$action string The action triggered

_plugin_available_templates() public method

Add plugin templates to the list of templates that are present in the current theme
public _plugin_available_templates ( array $list ) : array
$list array List of template names in the current theme
return array The modified list of template names

_plugin_include_template_file() public method

Potentially serve a different file for the requested template name
public _plugin_include_template_file ( string $file, string $name ) : string
$file string The filename of the template the theme will display
$name string The name of the template requested
return string The potentially modified filename to use for the requested template.

add_rest_rule() protected static method

Adds a RewriteRule to the REST handler for the rule provided
protected static add_rest_rule ( string $hook, Pluggable $object, Callable $fn )
$hook string The hook name to add a RewriteRule for
$object Pluggable The pluggable object holding the hook
$fn Callable The hook function to use to dispatch the request

add_rule() public method

Add a rewrite rule that dispatches entirely to a plugin hook
public add_rule ( mixed $rule, string $hook, Callback $fn = null )
$rule mixed An old-style rewrite rule string, where quoted segments are literals and unquoted segments are variable names, OR a RewriteRule object
$hook string The suffix of the hook function: action_plugin_act_{$suffix}
$fn Callback A potential function/method to register directly to the newly created hook

add_template() protected method

Use this function as a shortcut to make available additional templates to a theme from within the plugin directory.
protected add_template ( string $name, string $filename, boolean $override = false )
$name string The name of the template that will be displayed, sans extension
$filename string The full path of the template file used for the specified name
$override boolean If false, allow a template with the same name in the active theme directory to override this one. If true, always override the active theme's template with this one.

get_db_schema() final public method

Gets a database schema associated with this pluggable
final public get_db_schema ( ) : string
return string The database schema

get_file() final public method

Gets the filename that contains this pluggable class
final public get_file ( ) : string
return string The filename of the file that contains the pluggable class.

get_url() public method

Get a fully-qualified URL directory that contains this pluggable class
public get_url ( boolean | string $trail = false ) : string
$trail boolean | string If true, include a trailing slash. If string, append this to the requested url. Default: Add nothing.
return string URL

get_version() abstract public method

Provide a method to return the version number from a pluggable's info
abstract public get_version ( ) : string
return string The version of the pluggable

get_xml_text() public static method

Get the text associated to an info xml node, possibly using an href parameter
public static get_xml_text ( string $filename, SimpleXMLElement $node ) : mixed | string
$filename string The filename of the xml file
$node SimpleXMLElement The text node with value children to sift through
return mixed | string The result text

load() public method

Called when a pluggable is loaded to register its actions and filters.
public load ( )

load_hooks() public static method

If the class is an instance of Pluggable, registers the hooks with a plugin id also.
public static load_hooks ( mixed $object )
$object mixed The object or class name to register the hooks of

load_text_domain() public method

Load a translation domain/file for this pluggable
public load_text_domain ( string $domain ) : boolean
$domain string The name of the domain to load
return boolean true if data was successfully loaded, false otherwise

plugin_id() final public method

Returns a unique id for this pluggable
final public plugin_id ( ) : string
return string A plugin id

upgrade() public method

Execute the upgrade action on any pluggable that has a version number change Update the version number of the pluggable in the database to what is installed
public upgrade ( )

Property Details

$_added_templates protected property

protected $_added_templates

$info public property

public $info

$plugin_id public property

public $plugin_id