accordion-item.php
5 months ago
accordion.php
5 months ago
columns.php
5 months ago
control-group-item.php
5 months ago
control-group.php
5 months ago
div.php
5 months ago
form-group.php
5 months ago
index.php
6 months ago
more-link.php
5 months ago
tab-item.php
5 months ago
tab.php
5 months ago
control-group.php
92 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The file contains the class of Tab Control Holder. |
| 4 | * |
| 5 | * @package factory-forms |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | // Exit if accessed directly |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; |
| 12 | } |
| 13 | |
| 14 | if ( ! class_exists( 'Wbcr_FactoryForms600_ControlGroupHolder' ) ) { |
| 15 | |
| 16 | /** |
| 17 | * Tab Control Holder |
| 18 | * |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | class Wbcr_FactoryForms600_ControlGroupHolder extends Wbcr_FactoryForms600_ControlHolder { |
| 22 | |
| 23 | /** |
| 24 | * A holder type. |
| 25 | * |
| 26 | * @since 1.0.0 |
| 27 | * @var string |
| 28 | */ |
| 29 | public $type = 'control-group'; |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * Here we should render a beginning html of the tab. |
| 34 | * |
| 35 | * @since 1.0.0 |
| 36 | * @return void |
| 37 | */ |
| 38 | public function beforeRendering() { |
| 39 | $name = $this->getNameOnForm(); |
| 40 | $value = $this->getValue(); |
| 41 | |
| 42 | $title = $this->getOption( 'title', null ); |
| 43 | |
| 44 | ?> |
| 45 | <div <?php $this->attrs(); ?>> |
| 46 | <input type="hidden" name="<?php echo $name; ?>" id="<?php echo $name; ?>" class="factory-ui-control-group" value="<?php echo $value; ?>"/> |
| 47 | |
| 48 | <?php if ( $title ) { ?> |
| 49 | <strong class="factory-header"><?php echo $title; ?></strong> |
| 50 | <?php } ?> |
| 51 | |
| 52 | <ul class="factory-control-group-nav"> |
| 53 | <?php |
| 54 | foreach ( $this->elements as $element ) : |
| 55 | |
| 56 | if ( $element->options['type'] !== 'control-group-item' ) { |
| 57 | continue; |
| 58 | } |
| 59 | |
| 60 | $builder = new Wbcr_FactoryForms600_HtmlAttributeBuilder(); |
| 61 | |
| 62 | $builder->addCssClass( 'factory-control-group-nav-label' ); |
| 63 | $builder->addCssClass( 'factory-control-group-nav-label-' . $element->getOption( 'name' ) ); |
| 64 | $builder->addHtmlData( 'control-id', 'factory-control-group-item-' . $element->getOption( 'name' ) ); |
| 65 | $builder->addHtmlData( 'control-name', $element->getOption( 'name' ) ); |
| 66 | |
| 67 | if ( $value == $element->getOption( 'name' ) ) { |
| 68 | $builder->addCssClass( 'current' ); |
| 69 | } |
| 70 | |
| 71 | ?> |
| 72 | <li <?php $builder->printAttrs(); ?>><?php $element->title(); ?></li> |
| 73 | <?php endforeach; ?> |
| 74 | </ul> |
| 75 | <div class="factory-control-group-body"> |
| 76 | <?php |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Here we should render an end html of the tab. |
| 81 | * |
| 82 | * @since 1.0.0 |
| 83 | * @return void |
| 84 | */ |
| 85 | public function afterRendering() { |
| 86 | ?> |
| 87 | </div> |
| 88 | </div> |
| 89 | <?php |
| 90 | } |
| 91 | } |
| 92 | } |