| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Filter_Sidebar |
| 3 |
{ |
| 4 |
public function __construct( |
| 5 |
HC3_Ui $ui |
| 6 |
) |
| 7 |
{ |
| 8 |
$this->ui = $ui; |
| 9 |
} |
| 10 |
|
| 11 |
public function process( $element ) |
| 12 |
{ |
| 13 |
$tags = $element->getTags(); |
| 14 |
if( ! in_array('sidebar', $tags) ){ |
| 15 |
return $element; |
| 16 |
} |
| 17 |
|
| 18 |
$children = $element->getChildren(); |
| 19 |
$keys = array_keys($children); |
| 20 |
|
| 21 |
foreach( $keys as $key ){ |
| 22 |
$child = $children[$key]; |
| 23 |
|
| 24 |
if( ! is_object($child) ){ |
| 25 |
continue; |
| 26 |
} |
| 27 |
|
| 28 |
if( ! method_exists($child, 'getUiType') ){ |
| 29 |
continue; |
| 30 |
} |
| 31 |
|
| 32 |
$uiType = $child->getUiType(); |
| 33 |
$tags = $child->getTags(); |
| 34 |
|
| 35 |
if( $uiType == 'ahref' ){ |
| 36 |
$child |
| 37 |
->addAttr('class', 'hc-block') |
| 38 |
->addAttr('class', 'hc-theme-tab-link') |
| 39 |
; |
| 40 |
|
| 41 |
if( in_array('current', $tags) ){ |
| 42 |
$child |
| 43 |
->addAttr('class', 'hc-theme-tab-link-active') |
| 44 |
; |
| 45 |
} |
| 46 |
} |
| 47 |
else { |
| 48 |
$child |
| 49 |
->addAttr('class', 'hc-border-bottom') |
| 50 |
->addAttr('class', 'hc-border-gray') |
| 51 |
->addAttr('class', 'hc-p2') |
| 52 |
->addAttr('class', 'hc-fs2') |
| 53 |
; |
| 54 |
} |
| 55 |
|
| 56 |
$element->setChild( $key, $child ); |
| 57 |
} |
| 58 |
|
| 59 |
return $element; |
| 60 |
} |
| 61 |
} |