PortableInfobox/includes/services/Sanitizers/NodeDataSanitizer.php

26 lines
543 B
PHP
Raw Normal View History

2015-12-23 14:54:03 +00:00
<?php
namespace PortableInfobox\Sanitizers;
class NodeDataSanitizer extends NodeSanitizer {
2016-01-04 12:09:39 +00:00
protected $allowedTags = [ 'a' ];
2015-12-23 14:54:03 +00:00
/**
* @desc remove all HTML tags but links from data labels.
* If label after sanitization became empty because contained only image
* do not sanitize it.
*
* @param $data
* @return mixed
*/
public function sanitize( $data ) {
2016-01-04 12:09:39 +00:00
$sanitizedLabel = $this->sanitizeElementData( $data[ 'label' ] );
2015-12-23 14:54:03 +00:00
if ( !empty( $sanitizedLabel) ) {
$data[ 'label' ] = $sanitizedLabel;
}
return $data;
}
}