PHP Class Habari\Plugins

Provides an interface for the code to access plugins
Mostrar archivo Open project: habari/system Class Usage Examples

Public Methods

Method Description
_autoload ( $class ) Autoload function to load plugin file from classname
act ( string $hookname, mixed $param = null ) Call to execute a plugin action
act_id ( string $hookname, mixed $param = null ) Call to execute a plugin action, by id
activate_plugin ( $file ) Activates a plugin file
changed_since_last_activation ( ) : boolean Detects whether the plugins that exist have changed since they were last activated.
check_every_plugin_syntax ( ) : boolean Check the PHP syntax of every plugin available, activated or not.
class_from_filename ( string $file, boolean $check_realpath = false ) : string function class_from_filename returns the class name from a plugin's filename
deactivate_plugin ( string $file, boolean $force = false ) : boolean Deactivates a plugin file
extends_plugin ( $class ) : boolean Get classes that extend Plugin.
filter ( string $hookname, mixed $param ) : mixed Call to execute a plugin filter
filter_id ( string $hookname, string $id, mixed $param ) : mixed Call to execute a plugin filter on a specific plugin, by id
get_active ( ) : array Returns the internally stored references to all loaded plugins
get_by_interface ( string $interface ) : array Get references to plugin objects that implement a specific interface
get_plugin_classes ( )
id_from_file ( string $file ) : string Returns a plugin id for the filename specified.
implemented ( string $hookname, string $searchtype = null ) : array | boolean Determine if a hook of any type is implemented
is_loaded ( string $name, string $version = null ) : boolean Verify if a plugin is loaded.
list_active ( boolean $refresh = false ) : array function list_active Gets a list of active plugin filenames to be included
list_all ( ) : array function list_all Gets a list of all plugin filenames that are available
load ( string $class, boolean $activate = true ) : Plugin Load a pluign into memory by class name
load_active ( ) Instantiate and load all active plugins
load_from_file ( string $file, boolean $activate = true ) : Plugin Initialize all loaded plugins by calling their load() method
load_info ( string $file ) : SimpleXMLElement Return the info XML for a plugin based on a filename
plugin_ui ( string $configure, $configaction ) Produce the UI for a plugin based on the user's selected config option
provided ( null | string $exclude = null, boolean $include_inactive = false, boolean $use_file = false ) : array Get a list of features and the active plugins that provide that feature
register ( Callable $fn, string $type, string $hook, integer $priority = 8 ) function register Registers a plugin action for possible execution
set_present ( ) Stores the list of plugins that are present (not necessarily active) in the Options table for future comparison.
theme ( string $hookname, mixed $param ) : mixed Call to execute a theme function
theme_implemented ( string $hookname ) : boolean Determine if any plugin implements the indicated theme hook
upgrade ( ) Upgrade all loaded plugins
xmlrpc ( string $hookname, mixed $param ) : boolean | mixed Call to execute an XMLRPC function

Private Methods

Method Description
__construct ( ) function __construct A private constructor method to prevent this class from being instantiated.

Method Details

_autoload() public static method

Autoload function to load plugin file from classname
public static _autoload ( $class )

act() public static method

Call to execute a plugin action
public static act ( string $hookname, mixed $param = null )
$hookname string The name of the action to execute
$param mixed Optional arguments needed for action

act_id() public static method

Call to execute a plugin action, by id
public static act_id ( string $hookname, mixed $param = null )
$hookname string The name of the action to execute
$param mixed Optional arguments needed for action

activate_plugin() public static method

Activates a plugin file
public static activate_plugin ( $file )

changed_since_last_activation() public static method

Detects whether the plugins that exist have changed since they were last activated.
public static changed_since_last_activation ( ) : boolean
return boolean true if the plugins have changed, false if not.

check_every_plugin_syntax() public static method

Check the PHP syntax of every plugin available, activated or not.
See also: Utils::php_check_file_syntax()
public static check_every_plugin_syntax ( ) : boolean
return boolean Returns true if all plugins were valid, return false if a plugin (or more) failed.

class_from_filename() public static method

function class_from_filename returns the class name from a plugin's filename
public static class_from_filename ( string $file, boolean $check_realpath = false ) : string
$file string the full path to a plugin file
$check_realpath boolean whether or not to try realpath resolution
return string the class name

deactivate_plugin() public static method

Deactivates a plugin file
public static deactivate_plugin ( string $file, boolean $force = false ) : boolean
$file string the Filename of the plugin to deactivate
$force boolean If true, deactivate this plugin regardless of what filters may say about it.
return boolean If true, the plugin was deactivated

extends_plugin() public static method

Get classes that extend Plugin.
public static extends_plugin ( $class ) : boolean
$class string A class name
return boolean true if the class extends Plugin

filter() public static method

Call to execute a plugin filter
public static filter ( string $hookname, mixed $param ) : mixed
$hookname string The name of the filter to execute
$param mixed The value to filter.
return mixed The result of filtering the first $param value

filter_id() public static method

Call to execute a plugin filter on a specific plugin, by id
public static filter_id ( string $hookname, string $id, mixed $param ) : mixed
$hookname string The name of the filter to execute
$id string The id of the only plugin on which to execute
$param mixed The value to filter.
return mixed The result of filtering the first $param value

get_active() public static method

Returns the internally stored references to all loaded plugins
public static get_active ( ) : array
return array An array of plugin objects

get_by_interface() public static method

Get references to plugin objects that implement a specific interface
public static get_by_interface ( string $interface ) : array
$interface string The interface to check for
return array An array of matching plugins

get_plugin_classes() public static method

public static get_plugin_classes ( )

id_from_file() public static method

Used to unify the way plugin ids are generated, rather than spreading the calls internal to this function over several files.
public static id_from_file ( string $file ) : string
$file string The filename to generate an id for
return string A plugin id.

implemented() public static method

Determine if a hook of any type is implemented
public static implemented ( string $hookname, string $searchtype = null ) : array | boolean
$hookname string The name of the hook to check for
$searchtype string Optional. The type of hook to check for
return array | boolean An array with the types of hook implemented, or false if not implemented

is_loaded() public static method

You may supply an optional argument $version as a minimum version requirement.
public static is_loaded ( string $name, string $version = null ) : boolean
$name string Name or class name of the plugin to find.
$version string Optional minimal version of the plugin.
return boolean Returns true if name is found and version is equal or higher than required.

list_active() public static method

function list_active Gets a list of active plugin filenames to be included
public static list_active ( boolean $refresh = false ) : array
$refresh boolean Whether to refresh the cached array. Default false
return array An array of filenames

list_all() public static method

function list_all Gets a list of all plugin filenames that are available
public static list_all ( ) : array
return array An array of filenames

load() public static method

Load a pluign into memory by class name
public static load ( string $class, boolean $activate = true ) : Plugin
$class string The name of the class of the plugin to load
$activate boolean True to run the load routine of the plugin and add it to the loaded plugins list
return Plugin The instance of the created plugin

load_active() public static method

Instantiate and load all active plugins
public static load_active ( )

load_from_file() public static method

Initialize all loaded plugins by calling their load() method
public static load_from_file ( string $file, boolean $activate = true ) : Plugin
$file string the class name to load
$activate boolean True if the plugin's load() method should be called
return Plugin The instantiated plugin class

load_info() public static method

Return the info XML for a plugin based on a filename
public static load_info ( string $file ) : SimpleXMLElement
$file string The filename of the plugin file
return SimpleXMLElement The info structure for the plugin, or null if no info could be loaded

plugin_ui() public static method

Produce the UI for a plugin based on the user's selected config option
public static plugin_ui ( string $configure, $configaction )
$configure string The id of the configured plugin
$configaction

provided() public static method

Get a list of features and the active plugins that provide that feature
public static provided ( null | string $exclude = null, boolean $include_inactive = false, boolean $use_file = false ) : array
$exclude null | string A plugin id to exclude from the results
$include_inactive boolean Default false. If true, include inactive plugins in the list.
$use_file boolean If true, return a filename as the depenedency. If false (default), return the name of the plugin.
return array An array with keys of the feature name, values are an array of plugin names providing that feature

register() public static method

function register Registers a plugin action for possible execution
public static register ( Callable $fn, string $type, string $hook, integer $priority = 8 )
$fn Callable A reference to the function to register by string or array(object, string)
$type string Usually either 'filter' or 'action' depending on the hook type.
$hook string The plugin hook to register
$priority integer An optional execution priority, from 1-16. The lower the priority, the earlier the function will execute in the chain. Default value = 8.

set_present() public static method

Stores the list of plugins that are present (not necessarily active) in the Options table for future comparison.
public static set_present ( )

theme() public static method

Call to execute a theme function
public static theme ( string $hookname, mixed $param ) : mixed
$hookname string The name of the filter to execute
$param mixed The value to filter
return mixed The filtered value

theme_implemented() public static method

Determine if any plugin implements the indicated theme hook
public static theme_implemented ( string $hookname ) : boolean
$hookname string The name of the hook to check for
return boolean True if the hook is implemented

upgrade() public static method

Upgrade all loaded plugins
public static upgrade ( )

xmlrpc() public static method

Call to execute an XMLRPC function
public static xmlrpc ( string $hookname, mixed $param ) : boolean | mixed
$hookname string The name of the filter to execute
$param mixed The value to filter.
return boolean | mixed The result of the XMLRPC call