waPlugin

Base class for app plugins

Contents...

Class waPlugin is used to develop plugins for Webasyst apps. A plugin’s main class must extend base class waPlugin or its descendant; e.g., shopPlugin class in Shop-Script app.

Methods

protected function addCss ($url, $is_plugin = true)

Adds a URL of a CSS file to the array returned by method {$wa->css()}.

Parameters

Example

//relative to plugin’s root directory
$this->addCss('css/backend.css');
//absolute
$this->addCss(wa()->getConfig()->getRootUrl(true).'wa-content/css/wa/design.css', false);

protected function addJs ($url, $is_plugin = true)

Adds a URL of a JavaScript file to the array returned by method {$wa->js()}.

Parameters

Example

//relative to plugin’s root directory
$this->addJs('js/backend.js');
//absolute
$this->addJs(wa()->getConfig()->getRootUrl(true).'wa-content/js/jquery-wa/editor.js', false);

public function getId()

Returns plugin ID.

Example

$plugin_id = wa('someapp')->getPlugin('myplugin')->getId();

public function getName()

Returns localized plugin name.

Example

$plugin_name = wa('someapp')->getPlugin('myplugin')->getName();

public function getPluginStaticUrl ($absolute = false)

Returns plugin’s root directory URL.

Parameters

Example

//relative
$plugin_url = wa('someapp')->getPlugin('myplugin')->getPluginStaticUrl();
//absolute
$plugin_url = wa('someapp')->getPlugin('myplugin')->getPluginStaticUrl(true);

Result

'/wa-apps/someapp/plugins/myplugin/'
'https://mydomain.ru/wa-apps/someapp/plugins/myplugin/'

public function getSettings ($name = null)

Returns the values of plugin settings described in configuration file settings.php.

Parameters

Example

//all settings’ values
wa('someapp')->getPlugin('myplugin')->getSettings()
//one setting value
wa('someapp')->getPlugin('myplugin')->getSettings('some_setting')

public function getVersion()

Returns plugin version number. The version number is read from configuration file plugin.php. If the file also contains a 'build' parameter, then a period and a build number are added to the version number.

Example

$plugin_version = wa('someapp')->getPlpugin('myplugin')->getVersion();

Result

//without a build number
1.2.4
//with a build number
1.2.4.382