PHP Класс Habari\Plugins

Provides an interface for the code to access plugins
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
_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

Приватные методы

Метод Описание
__construct ( ) function __construct A private constructor method to prevent this class from being instantiated.

Описание методов

_autoload() публичный статический Метод

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

act() публичный статический Метод

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() публичный статический Метод

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() публичный статический Метод

Activates a plugin file
public static activate_plugin ( $file )

changed_since_last_activation() публичный статический Метод

Detects whether the plugins that exist have changed since they were last activated.
public static changed_since_last_activation ( ) : boolean
Результат boolean true if the plugins have changed, false if not.

check_every_plugin_syntax() публичный статический Метод

Check the PHP syntax of every plugin available, activated or not.
См. также: Utils::php_check_file_syntax()
public static check_every_plugin_syntax ( ) : boolean
Результат boolean Returns true if all plugins were valid, return false if a plugin (or more) failed.

class_from_filename() публичный статический Метод

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
Результат string the class name

deactivate_plugin() публичный статический Метод

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.
Результат boolean If true, the plugin was deactivated

extends_plugin() публичный статический Метод

Get classes that extend Plugin.
public static extends_plugin ( $class ) : boolean
$class string A class name
Результат boolean true if the class extends Plugin

filter() публичный статический Метод

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.
Результат mixed The result of filtering the first $param value

filter_id() публичный статический Метод

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.
Результат mixed The result of filtering the first $param value

get_active() публичный статический Метод

Returns the internally stored references to all loaded plugins
public static get_active ( ) : array
Результат array An array of plugin objects

get_by_interface() публичный статический Метод

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
Результат array An array of matching plugins

get_plugin_classes() публичный статический Метод

public static get_plugin_classes ( )

id_from_file() публичный статический Метод

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
Результат string A plugin id.

implemented() публичный статический Метод

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
Результат array | boolean An array with the types of hook implemented, or false if not implemented

is_loaded() публичный статический Метод

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.
Результат boolean Returns true if name is found and version is equal or higher than required.

list_active() публичный статический Метод

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
Результат array An array of filenames

list_all() публичный статический Метод

function list_all Gets a list of all plugin filenames that are available
public static list_all ( ) : array
Результат array An array of filenames

load() публичный статический Метод

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
Результат Plugin The instance of the created plugin

load_active() публичный статический Метод

Instantiate and load all active plugins
public static load_active ( )

load_from_file() публичный статический Метод

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
Результат Plugin The instantiated plugin class

load_info() публичный статический Метод

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
Результат SimpleXMLElement The info structure for the plugin, or null if no info could be loaded

plugin_ui() публичный статический Метод

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() публичный статический Метод

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.
Результат array An array with keys of the feature name, values are an array of plugin names providing that feature

register() публичный статический Метод

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() публичный статический Метод

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

theme() публичный статический Метод

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
Результат mixed The filtered value

theme_implemented() публичный статический Метод

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
Результат boolean True if the hook is implemented

upgrade() публичный статический Метод

Upgrade all loaded plugins
public static upgrade ( )

xmlrpc() публичный статический Метод

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.
Результат boolean | mixed The result of the XMLRPC call