| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Filter_Padding |
| 3 |
{ |
| 4 |
public function __construct( HC3_Ui $htmlFactory ) |
| 5 |
{ |
| 6 |
$this->htmlFactory = $htmlFactory; |
| 7 |
} |
| 8 |
|
| 9 |
public function process( $element ) |
| 10 |
{ |
| 11 |
$tags = $element->getTags(); |
| 12 |
if( ! in_array('padding', array_keys($tags)) ){ |
| 13 |
return $element; |
| 14 |
} |
| 15 |
|
| 16 |
if( ! method_exists($element, 'addAttr') ){ |
| 17 |
$element = $this->htmlFactory->makeBlock( $element ); |
| 18 |
} |
| 19 |
|
| 20 |
$padding = $tags['padding']; |
| 21 |
if( ! is_array($padding) ){ |
| 22 |
$padding = array( $padding ); |
| 23 |
} |
| 24 |
|
| 25 |
foreach( $padding as $p ){ |
| 26 |
$element->addAttr('class', 'hc-p' . $p); |
| 27 |
} |
| 28 |
|
| 29 |
return $element; |
| 30 |
} |
| 31 |
} |