Create Plugin-Filter (en)

Summary
Create Plugin-Filter (en)
Create and install a Plugin-FilterPlugin-Filter are module-like ZIP-packages build from the files plugin_info.php, plugin_install.php, filter.php 

Create and install a Plugin-Filter

Plugin-Filter are module-like ZIP-packages build from the files plugin_info.php, plugin_install.php, filter.php and maybe plugin_uninstall.php.

The following tokens can be used instead of hardcoded pathes within OpF-Plugins

{SYSVAR:WB_URL}   = will replace with the content of the Constant WB_URL
{SYSVAR:WB_PATH}  = will replace with the content of the Constant WB_PATH
{OPF:PLUGIN_URL}  = will replace with WB_URL.'/modules/outputfilter_dashboard/plugins/{your_plugin}'
{OPF:PLUGIN_PATH} = will replace with WB_PATH.'/modules/outputfilter_dashboard/plugins/{your_plugin}'

inside the filter functions the following CONSTANTS work with OPF Plugins

OPF_PLUGINS_PATH
OPF_PLUGINS_URL

the path and url to the plugins folder is very long and is being used extensivly in Filters, therefore the constants are a convenient addition.  The URL is

OPF_PLUGINS_URL = [ WB_URL.'/modules/'.basename(dirname(__FILE__)).'/plugins/' ]

plugin_info.php

<?php
$plugin_directory   = 'cachecontrol';
$plugin_name        = 'Cache Control';
$plugin_version     = '1.0.0';
$plugin_author      = 'author...';
$plugin_license     = 'GNU General Public License, Version 2 or later';
$plugin_description = 'Filter to automatically prevent browsers from delivering outdated files (css,js) from cache';

plugin_install.php

See opf_register_filter().

<?php
if(!defined('WB_PATH')) die(header('Location: ../../index.php'));

opf_register_filter(array(
        'plugin' => 'cachecontrol',
        'name' => 'Cache Control',
        'type' => OPF_TYPE_PAGE_LAST,
        'file' => '{OPF:PLUGIN_PATH}/filter.php',
        'funcname' => 'opff_cachecontrol',
        'desc' => array('EN' => "Description ... Take care that this filter is called last!",
                        'DE' => "Beschreibung ... Achten Sie darauf, daß dieser Filter als letzter aufgerufen wird!"
        ),
        'modules' => 'all',
        'active' => 1,
        'allowedit' => 0,
        'allowedittarget' => 1
));

By default during installation filters are appended to the end of the list, but you can influence the position later on using the function opf_move_up_before.

filter.php

This file contains the filter-function itself.  See The Filter-Function itself.

<?php
if(!defined('WB_PATH')) die(header('Location: ../../index.php'));

function opff_cachecontrol(&$content, $page_id, $section_id, $module, $wb) {
        // function code here

        return(TRUE);
}

plugin_uninstall.php

This file is optional, and can be omitted.

<?php
if(!defined('WB_PATH')) die(header('Location: ../../index.php'));

// clean up.
// But do NEVER CALL opf_unregister_filter() in this file!
function opf_register_filter($filter,  
$serialized = FALSE)
Register a new Filter.
function opf_move_up_before($name,  
$ref_name = "")
Upon registration move a filter up to a position before another one.
The Filter function must have an unique name, and should have a “opff_”-prefix
Close