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
acymailing / back / Core / AcymView.php

AcymView.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.1.0, at back/Core/AcymView.php

171 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Core;
4
5 use AcyMailing\Helpers\HeaderHelper;
6
7 abstract class AcymView extends AcymObject
8 {
9 public string $name = '';
10 // Array of workflow steps: task => title
11 protected array $steps = [];
12 // Step to display
13 protected string $step = '';
14
15 public array $tabs = [];
16
17 public function __construct()
18 {
19 parent::__construct();
20
21 $classname = get_class($this);
22 $classname = substr($classname, strrpos($classname, '\\') + 1);
23 $this->name = strtolower(substr($classname, 0, -4));
24 $this->step = acym_getVar('string', 'nextstep', '');
25 if (empty($this->step)) {
26 $this->step = acym_getVar('string', 'step', '');
27 }
28 }
29
30 public function getName(): string
31 {
32 return $this->name;
33 }
34
35 public function getLayout(): string
36 {
37 return acym_getVar('cmd', 'layout', acym_getVar('cmd', 'task', 'listing'));
38 }
39
40 public function display(object $controller, array $data = []): void
41 {
42 $name = $this->getName();
43 $view = $this->getLayout();
44
45 if (method_exists($this, $view)) $this->$view();
46
47 $viewFolder = acym_isAdmin() ? ACYM_VIEW : ACYM_VIEW_FRONT;
48 if (!file_exists($viewFolder.ucfirst($name).DS.'tmpl'.DS.$view.'.php')) {
49 $view = 'listing';
50 }
51 $getCleanView = ($name !== 'archive' && $view !== 'listing') && ($name !== 'frontusers' || $view !== 'profile');
52 if (ACYM_CMS === 'wordpress' && $getCleanView) {
53 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- WordPress generated content temporary held to allow redirections (headers sent).
54 echo ob_get_clean();
55 }
56
57 // Load the needed scripts and styles
58 if (
59 ACYM_CMS !== 'wordpress'
60 || ($name === 'frontusers' && ($view === 'unsubscribe' || $view === 'unsubscribepage'))
61 || !defined('DOING_AJAX')
62 || !DOING_AJAX
63 || ($name === 'archive' && $view === 'view')
64 ) {
65 acym_loadAssets($name, $view);
66 $controller->loadScripts($view);
67 }
68
69 // On pages with the editor, we need to put the wrapper inside the form
70 $outsideForm = (strpos($name, 'mails') !== false && $view === 'edit') || (strpos($name, 'campaigns') !== false && $view === 'edit_email');
71 if ($outsideForm) {
72 echo '<form id="acym_form" action="'.esc_url(
73 acym_completeLink(
74 acym_getVar('cmd', 'ctrl')
75 )
76 ).'" class="acym__form__mail__edit" method="post" name="acyForm" data-abide novalidate enctype="multipart/form-data">';
77 }
78
79 // Open wrapper and display the header
80 if (acym_getVar('cmd', 'task') !== 'ajaxEncoding') {
81 echo '<div id="acym_wrapper" class="'.esc_attr($name).'_'.esc_attr($view).' cms_'.esc_attr(ACYM_CMS).' cms_v_'.esc_attr(substr(ACYM_CMSV, 0, 1)).'">';
82 }
83
84 //if joomla we add the left menu and a div for the content
85 if (acym_isLeftMenuNecessary()) {
86 acym_displayLeftMenu($name);
87 echo '<div id="acym_content">';
88 }
89
90 if (!empty($data['breadcrumb'])) {
91 $headerHelper = new HeaderHelper();
92 $headerHelper->display($data['breadcrumb']);
93 }
94
95 $remindme = json_decode($this->config->get('remindme', '[]'), true);
96 if ($this->config->get('walk_through', 0) == 0) {
97 if (acym_isAdmin()) {
98 if (!in_array('multilingual', $remindme) && acym_level(ACYM_ESSENTIAL) && $this->config->get('multilingual', '0') === '0') {
99 if (count(acym_getLanguages(false, true)) > 1) {
100 $message = acym_translation('ACYM_MULTILINGUAL_OPTIONS_PROMPT');
101 $message .= ' <a id="acym__multilingual__reminder" href="'.acym_completeLink('configuration&task=multilingual').'&'.acym_getFormToken().'">'.acym_translation('ACYM_YES').'</a>';
102 $message .= ' / <a href="#" title="multilingual" class="acym__do__not__remindme__multilingual">'.acym_translation('ACYM_NO').'</a>';
103 acym_display($message, 'info', false);
104 } else {
105 $remindme[] = 'multilingual';
106 $this->config->saveConfig(['remindme' => json_encode($remindme)]);
107 }
108 }
109
110 $maliciousScan = $this->config->get('malicious_scan', 0);
111 if (!empty($maliciousScan)) {
112 $this->config->saveConfig(['malicious_scan' => 0]);
113 acym_display(acym_translation('ACYM_NEW_SECURITY_TOOL'), 'info');
114 }
115 }
116 }
117
118 acym_trigger('acym_displayTrackingMessage', [&$message], 'plgAcymWoocommerce');
119
120 if (acym_isAdmin()) {
121 acym_trigger('onAcymDisplayPage');
122 acym_displayMessages();
123 }
124
125 include acym_getView($name, $view);
126
127 // Close the wrapper and the content if CMS = Joomla
128 if (acym_isLeftMenuNecessary()) {
129 echo '</div>';
130 }
131
132 if (acym_getVar('cmd', 'task') !== 'ajaxEncoding') {
133 echo '</div>';
134 }
135
136 if ($outsideForm) {
137 echo '</form>';
138 }
139
140 if (ACYM_CMS !== 'wordpress' || !acym_isAdmin() || in_array($controller->name, ['dashboard', 'language', 'campaigns']) || acym_isAjax()) {
141 return;
142 }
143
144 $remind = json_decode($this->config->get('remindme', '[]'));
145 $installationDate = $this->config->get('install_date', time());
146 $sevenDaysAgo = time() - 7 * 86400;
147
148 if (!in_array('reviews', $remind) && $installationDate < $sevenDaysAgo) {
149 echo '<div id="acym__reviews__footer" style="margin: 0 0 30px 30px;">';
150 echo wp_kses(
151 acym_translationSprintf(
152 'ACYM_REVIEW_FOOTER',
153 '<a title="reviews" id="acym__reviews__footer__link" target="_blank" href="https://wordpress.org/support/plugin/acymailing/reviews/?rate=5#new-post">
154 '.str_repeat('<i class="acymicon-star"></i>', 5).'</a>'
155 ),
156 [
157 'a' => [
158 'title' => true,
159 'id' => true,
160 'href' => true,
161 ],
162 'i' => [
163 'class' => true,
164 ],
165 ]
166 );
167 echo '</div>';
168 }
169 }
170 }
171