Included Plugins

This section documents the plugins that are included with WysiwygPro.

You can load a plugin using the loadPlugin method. 

Plugins are stored in the wysiwygPro/plugins folder. 

EXAMPLE

This is an example plugin that you can look at to see how to create your own plugins.

JSEmbed

Loading this plugin will cause WysiwygPro to use JavaScript to embed media objects instead of object and embed tags. Many developers will prefer this because it results in valid markup (Embed tags are not valid markup) And it gets rid of the "Click to activate" requirement in Internet Explorer.

If you would prefer that your media objects be displayed with a 3rd party JavaScript library you could use this plugin as a base for creating your own plugin.

repeatingRegions (since version 3.1.3)

Load this plugin and you will be able to template repeating regions in your content.

Repeating regions can be defined by adding HTML comment tags to your document source.

To create a repeating block that cannot be deleted surround the block of code you want with:


Repeating HTML goes here

To create a repeating region that can be deleted use:


Repeating HTML goes here

The plugin cannot currently be used to repeat table elements, this functionality is planned for a future release.

serverPreview

This plugin allows you to offload previews to a server script of your design to perform parsing of dynamic template syntax or to display the content as it would appear within a site template. You can use this feature to display a more accurate preview.

Example:
The following loads the serverPreview plugin and tells the editor to send previews to a script named preview.php

$editor->loadPlugin('serverPreview');
$editor->plugins['serverPreview']->URL '/preview.php';

The editor will pass 2 parameters to your preview script via post:

wproHTML
This will contain the raw HTML code generated from the editor. Equivalent to editor.getValue();

wproPreviewHTML
This will contain the editor value with additional tags such as stylesheets and the baseurl to ensure that the code will display as expected. This is the same code that the editor would normally have used for the preview.

Your preview script should then display the code with any template tags parsed and placed within the design of your website (or whatever needs to be done to display the code exactly as it would appear on your website)

To prevent phishing attacks you should place the following code at the top of your preview script to protect it. This code ensures that the script can only be displayed within a WysiwygPro preview:

if (!isset($_POST['wproHTML'])) exit('No Data');
define('IN_WPRO', true);
include_once(
'wysiwygPro/core/libs/wproSession.class.php');
$WPRO_SESS = new wproSession();
if (!
$WPRO_SESS->exists()) exit('No Session');
?>

The following example preview script takes the wproHTML property and includes common site header and footer files so that the code is displayed within the design of the website. (obviously this only makes sense when editing a snippet of HTML code rather than a complete document)

// protect the script:
if (!isset($_POST['wproHTML'])) exit('No Data');
define('IN_WPRO', true);
include_once(
'wysiwygPro/core/libs/wproSession.class.php');
$WPRO_SESS = new wproSession();
if (!
$WPRO_SESS->exists()) exit('No Session');

// include common header:
include_once('includes/header.php');

// display the HTML code:
echo $_POST['wproHTML'];

// include the common footer:
include_once('includes/footer.php');
?>
 

tagPath

Loading this plugin will add the optional tagPath beneath the design view of the editor. The tag path lists all the HTML tags surrounding the current selection and allows you to select and edit each tag individually. This plugin is very useful for advanced editors.

templateFilter

This plugin makes use of WysiwygPro's HTML Filter interface to provide an easy method for parsing basic placeholder tags.

The template filter plugin has two methods:

protect:

$plugin->protectstring $openingTagstring $closingTag );

This function allows you to specify opening and closing tags that should be protected form HTML entity or URL encoding. Content between the tags, including the tags themselves will be protected.

The function should be passed two parameters. The first should be an opening tag to protect. The second should be a closing tag to protect.

This function must be called for each opening and closing tag you would like to protect.

assign:

$plugin->assignstring $tagstring $value [, boolean $replace_in_design ]);

This function will display $tag as $value in the design and preview views. If you would like the substitution to only happen in the preview view then set the third parameter to false.

Replacing $tag with $value in both the design and preview views is a good idea for tags that represent URLs because this will ensure that images and links are not broken in the design view. Setting the third parameter to false so that the tag is only substituted in preview view may be more appropriate for other types of tags.

The third parameter was added in version 3.1.0, in earlier versions the substitution will occur in both design and preview, the third parameter will be ignored.

$tag will always be displayed unchanged in source view.

This function must be called for each place holder tag you would like to assign.

Example:
The following example creates a place holder tag for the site's URL, this is a great idea if you would like content to be moved easily between domains.

// load and configure the template filter plugin
$editor->loadPlugin('templateFilter');
$editor->plugins['templateFilter']->protect('{','}');
$editor->plugins['templateFilter']->assign('{site_url}','http://www.wysiwygpro.com');