Skip to content

Allowing or Blocking Elements

Ricardo Lopes edited this page Jan 16, 2015 · 2 revisions

Available since version 0.1.0

php-htmlfilter removes not allowed elements. Only <script> is not allowed by default. The usage of this filter may be done by either passing the pertaining configuration into the [__construct()] (#using-constructor) or by using [Parser::configureElements($elements)] (#using-configureElements) method

##Using Constructor##

<?php
//prepare our configuration
$config = array(
    'configureElements' => array(
        array('name'=>'script', 'permission' => 0),
        array('name'=>'aside', 'permission' => 1),
    )
);

//create a new instance of the filter, 
//while passing configs into the construct
$htmlFilter = new \HtmlFilter\Filter($config);

Using configureElements

<?php

$filter = new HtmlFilter\Filter();

$elementConfiguration = array(
    array('name'=>'script', 'permission' => 0),
    array('name'=>'aside', 'permission' => 1),
);

$filter->configureElements($elementConfiguration);

Clone this wiki locally