loadPlugin

Availability: >= 3.0

Type: Object Method

Description: Loads a PHP API plugin.

Syntax:

$editor->loadPluginstring $plugin );

Parameters:

$plugin
Name of the plugin to load.

Plugins are stored in the wysiwygPro/plugins folder.

PHP API plugins can be used to hook into events, see PHP API Events

You can access loaded plugins using the plugins property. This property is an associative array where the key is the name of the plugin and the value is the plugin object.

PHP API plugins are also an ideal way to store reusable editor configurations. If you are displaying the editor in several places throughout your application and each editor has allot of common configuration settings you could create a plugin that stores all your settings so that you can maintain all your editors from a single file.

Example: Creating the plugin.

For the purposes of this example we will call the plugin 'myPlugin' but you may call your plugin anything just remember to change all instances of 'myPlugin' in the example code and file names with your plugin name.

Create the following file:

wysiwygpro/plugins/myPlugin/plugin.php

Place the following code inside it adding your settings:

if (!defined('IN_WPRO')) exit;

class
wproPlugin_myPlugin {

function
init(&$editor) {

// EXCHANGE ALL OF THE CODE BELOW FOR YOUR EDITOR CONFIGURATION.
// This is an example configuration, yours will certainly be different.

// apply a default appearance to the document:
$editor->stylesheet = '/sneakpeek/style.css';
$editor->cssText = 'body { background-color: #ffffff; background-image: none; text-align: left; margin: 5px; padding: 0px; }';

// CONFIGURE THE FILE MANAGER:
// full directory path for your images folder:
$editor->imageDir = dirname(dirname(dirname(dirname(__FILE__)))).'/demos/images/';
// URL of your images folder:
$editor->imageURL = '/sneakpeek/demos/images/';

// full directory path of your documents folder for storing PDF and Word files etc:
$editor->documentDir = dirname(dirname(dirname(dirname(__FILE__)))).'/demos/documents/';
// url of your documents folder:
$editor->documentURL = '/sneakpeek/demos/documents/';

// full directory path of your media folder for storing video files:
$editor->mediaDir = dirname(dirname(dirname(dirname(__FILE__)))).'/demos/media/';
// url of your media folder:
$editor->mediaURL = '/sneakpeek/demos/media/';

// File editing permissions:
$editor->editImages = true;
$editor->renameFiles = true;
$editor->renameFolders = true;
$editor->deleteFiles = true;
$editor->deleteFolders = true;
$editor->copyFiles = true;
$editor->copyFolders = true;
$editor->moveFiles = true;
$editor->moveFolders = true;
$editor->upload = true;
$editor->overwrite = false;
$editor->createFolders = true;

$editor->diskQuota = 4;

}
}
?>

For a list of other functions that can be used in the PHP API plugin see PHP API Events

To load the plugin named 'myPlugin' you would use the following code:

$editor->loadPlugin('myPlugin'); 

See also: 

plugins, loadPlugins, pluginIsLoaded, unloadPlugin, triggerEvent