PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
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/ToolbarHelper.php +58 -22 10.11.1 → 11.1.0 View file →
@@ -5,38 +5,39 @@
5 5 use AcyMailing\Core\AcymObject;
6 6
7 7 class ToolbarHelper extends AcymObject
8 8 {
9 - private string $leftPart = '';
10 - private string $rightPart = '';
11 - private array $moreOptionsPart = [];
9 + private array $searchBarInformation = [];
10 + private array $actionButtons = [];
11 + private array $filteringOptions = [];
12 12
13 + public function addSearchBar(string $search, string $name, string $placeholder = 'ACYM_SEARCH', bool $showClearBtn = true): void
14 + {
15 + $this->searchBarInformation = [
16 + 'search' => $search,
17 + 'name' => $name,
18 + 'placeholder' => $placeholder,
19 + 'showClearBtn' => $showClearBtn,
20 + ];
21 + }
22 +
13 23 public function addButton(string $textContent, array $attributes, string $icon = '', bool $isPrimary = false): void
14 24 {
15 - $data = [
25 + $this->actionButtons[] = [
26 + 'type' => 'button',
16 27 'icon' => $icon,
17 28 'content' => acym_translation($textContent),
18 29 'attributes' => $attributes,
19 30 'isPrimary' => $isPrimary,
20 31 ];
21 -
22 - ob_start();
23 - include acym_getPartial('toolbar', 'button_main');
24 - $this->rightPart .= ob_get_clean();
25 32 }
26 33
27 - public function addOtherContent(string $content, string $side = 'right'): void
34 + public function addModalButton(array $options): void
28 35 {
29 - if (in_array($side, ['left', 'right'])) {
30 - $this->{$side.'Part'} .= $content;
31 - }
36 + $options['type'] = 'modal';
37 + $this->actionButtons[] = $options;
32 38 }
33 39
34 - public function addSearchBar(string $search, string $name, string $placeholder = 'ACYM_SEARCH', bool $showClearBtn = true): void
35 - {
36 - $this->leftPart .= acym_filterSearch($search, $name, $placeholder, $showClearBtn, 'acym__toolbar__search-field margin-bottom-0');
37 - }
38 -
39 40 public function addFilterByTag(array &$data, string $name, string $class): void
40 41 {
41 42 $allTags = new \stdClass();
42 43 $allTags->name = acym_translation('ACYM_ALL_TAGS');
@@ -46,9 +47,9 @@
46 47 acym_translation('ACYM_TAG'),
47 48 acym_select(
48 49 $data['allTags'],
49 50 $name,
50 - acym_escape($data['tag']),
51 + $data['tag'],
51 52 [
52 53 'class' => $class,
53 54 ],
54 55 'value',
@@ -58,15 +59,50 @@
58 59 }
59 60
60 61 public function addOptionSelect(string $title, string $select): void
61 62 {
62 - $this->moreOptionsPart[] = '<div class="cell grid-x shrink acym__toolbar__filters__select"><label class="cell">'.$title.'</label>'.$select.'</div>';
63 + $this->filteringOptions[] = [
64 + 'title' => $title,
65 + 'select' => $select,
66 + ];
63 67 }
64 68
65 69 public function displayToolbar(array $data): void
66 70 {
67 - $data['leftPart'] = $this->leftPart;
68 - $data['rightPart'] = $this->rightPart;
69 - $data['moreOptionsPart'] = $this->moreOptionsPart;
71 + $data['toolbarHelper'] = $this;
72 + $data['searchBarInformation'] = $this->searchBarInformation;
73 + $data['actionButtons'] = $this->actionButtons;
74 + $data['filteringOptions'] = $this->filteringOptions;
70 75 include acym_getPartial('toolbar', 'toolbar');
76 + }
77 +
78 + public function displaySearchBar(): void
79 + {
80 + acym_filterSearch(
81 + $this->searchBarInformation['search'],
82 + $this->searchBarInformation['name'],
83 + $this->searchBarInformation['placeholder'],
84 + $this->searchBarInformation['showClearBtn'],
85 + 'acym__toolbar__search-field margin-bottom-0'
86 + );
87 + }
88 +
89 + public function displayActionButtons(): void
90 + {
91 + foreach ($this->actionButtons as $data) {
92 + if ($data['type'] === 'button') {
93 + include acym_getPartial('toolbar', 'button_main');
94 + } else {
95 + acym_modal(
96 + $data['button'],
97 + $data['modalContent'] ?? '',
98 + $data['id'] ?? null,
99 + $data['attributesModal'] ?? [],
100 + $data['attributesButton'] ?? [],
101 + $data['isButton'] ?? true,
102 + $data['isLarge'] ?? true,
103 + $data['classesModal'] ?? '',
104 + );
105 + }
106 + }
71 107 }
72 108 }