Not a developer? Go to


Conditional Text Filtering

In the code sample above where a text filter is registered with Movable Type, a condition is defined under which text filtering is allowed. The call back determines whether or not the text filter can be selected by a user via the web interface. The callback is called with a single parameter, the type of the object being transformed. Allowable values for the object type are:

  • “entry”
  • “comment”

The callback should return “1” if filtering is allowed, and “0” otherwise.

# Will only allow the text filter to be applied to comments
sub transform_when {
    my ($obj_type) = @_;
    return 1 if $obj_type && ($obj_type eq 'comment');