PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Helpers/TabHelper.php +0 -91 10.11.1 → 11.1.1 View file →
@@ -1,91 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers;
4 -
5 -use AcyMailing\Core\AcymObject;
6 -
7 -class TabHelper extends AcymObject
8 -{
9 - private array $titles = [];
10 - private array $content = [];
11 - private array $inBarElements = [];
12 - private int $tabNumber = 0;
13 - private bool $opened = false;
14 - private string $identifier;
15 -
16 - public function __construct()
17 - {
18 - parent::__construct();
19 -
20 - $this->identifier = (string)rand(1000, 9000);
21 - }
22 -
23 - public function startTab(string $title, bool $selected = false, string $attributes = '', bool $clickable = true): string
24 - {
25 - if ($this->opened) {
26 - $this->endTab();
27 - }
28 - $this->opened = true;
29 -
30 - $attributes .= $clickable ? '' : 'data-empty="true"';
31 - $attributes .= $selected ? 'data-selected="true"' : '';
32 - $classLi = $clickable ? '' : 'tabs-title-empty';
33 -
34 - $this->identifier = preg_replace('#[^a-z0-9]#is', '_', strtolower((string)$title));
35 -
36 - $this->titles[] = '<li class="tabs-title '.$classLi.'"><a class="acym_tab acym__color__medium-gray" '.$attributes.' href="#" data-tab-identifier="'.$this->identifier.'" data-tabs-target="tab_'.$this->identifier.'_'.$this->tabNumber.'">'.$title.'</a></li>';
37 -
38 - ob_start();
39 -
40 - return $this->identifier;
41 - }
42 -
43 - public function endTab(): void
44 - {
45 - if (!$this->opened) {
46 - return;
47 - }
48 -
49 - $this->opened = false;
50 - $this->content[] = '<div class="tabs-panel" id="tab_'.$this->identifier.'_'.$this->tabNumber.'">'.ob_get_clean().'</div>';
51 - $this->tabNumber++;
52 - }
53 -
54 - public function addElementInBar(string $element, string $identifier = ''): void
55 - {
56 - $this->inBarElements[] = [
57 - 'element' => $element,
58 - 'identifier' => $identifier,
59 - ];
60 - }
61 -
62 - public function display(string $tabId): void
63 - {
64 - if ($this->opened) {
65 - $this->endTab();
66 - }
67 -
68 - $tabSystem = '<ul class="tabs" data-tabs id="'.acym_escape($tabId).'">';
69 - $tabSystem .= implode('', $this->titles);
70 -
71 - if (!empty($this->inBarElements)) {
72 - $tabSystem .= '<div class="acym__tabs__inbar">';
73 - foreach ($this->inBarElements as $oneElement) {
74 - $displayOptions = '';
75 - if (!empty($oneElement['identifier'])) {
76 - $displayOptions = 'acym-data-identifier="'.acym_escape($oneElement['identifier']).'" style="display: none;"';
77 - }
78 - $tabSystem .= '<div class="acym__tabs__inbar__element" '.$displayOptions.'>'.$oneElement['element'].'</div>';
79 - }
80 - $tabSystem .= '</div>';
81 - }
82 -
83 - $tabSystem .= '</ul>';
84 -
85 - $tabSystem .= '<div class="tabs-content margin-bottom-1" data-tabs-content="'.acym_escape($tabId).'">';
86 - $tabSystem .= implode('', $this->content);
87 - $tabSystem .= '</div>';
88 -
89 - echo $tabSystem;
90 - }
91 -}