PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.11.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.11.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
acymailing / WpInit / Menu.php

Menu.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.11.1, at WpInit/Menu.php

110 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\WpInit;
4
5 class Menu
6 {
7 private Router $router;
8
9 public function __construct($router)
10 {
11 $this->router = $router;
12
13 if (defined('WP_ADMIN') && WP_ADMIN) {
14 add_action('admin_menu', [$this, 'addMenus'], 99);
15 }
16
17 add_filter('plugin_action_links_'.plugin_basename(dirname(__DIR__).'/index.php'), [$this, 'addPluginLinks']);
18 }
19
20 public function addMenus()
21 {
22 $capability = 'read';
23
24 $config = acym_config();
25 $allowedGroups = explode(',', $config->get('wp_access', 'administrator'));
26 $userGroups = acym_getGroupsByUser();
27
28 $allowed = false;
29 foreach ($userGroups as $oneGroup) {
30 if ($oneGroup == 'administrator' || in_array($oneGroup, $allowedGroups)) {
31 $allowed = true;
32 break;
33 }
34 }
35 if (!$allowed) return;
36
37 $svg = acym_loaderLogo(false);
38 add_menu_page(
39 acym_translation('ACYM_DASHBOARD'),
40 'AcyMailing',
41 $capability,
42 ACYM_COMPONENT.'_dashboard',
43 [$this->router, 'router'],
44 'data:image/svg+xml;base64,'.base64_encode(
45 $svg
46 ),
47 42
48 );
49
50 $menuExtra = [];
51 $menus = [
52 'ACYM_SUBSCRIPTION_FORMS' => 'forms',
53 'ACYM_SUBSCRIBERS' => 'users',
54 'ACYM_CUSTOM_FIELDS' => 'fields',
55 'ACYM_LISTS' => 'lists',
56 ];
57 $menus['ACYM_EMAILS'] = 'campaigns';
58 $menus['ACYM_TEMPLATES'] = 'mails';
59 $menus['ACYM_EMAILS_OVERRIDE'] = 'override';
60 $menus['ACYM_QUEUE'] = 'queue';
61 $menus['ACYM_STATISTICS'] = 'stats';
62 $menus['ACYM_ADD_ONS'] = 'plugins';
63 $menus['ACYM_CONFIGURATION'] = 'configuration';
64
65 if (!acym_level(ACYM_ESSENTIAL)) {
66 $menus['ACYM_GOPRO'] = 'gopro';
67 $menuExtra['ACYM_GOPRO']['icon'] = '<i class="acymicon-star"></i>';
68 }
69
70 foreach ($menus as $title => $ctrl) {
71 if (!acym_isAllowed($ctrl)) continue;
72
73 $text = acym_translation($title);
74 if (!empty($menuExtra[$title]['icon'])) $text .= ' '.$menuExtra[$title]['icon'];
75 add_submenu_page(
76 ACYM_COMPONENT.'_dashboard',
77 acym_translation($title),
78 $text,
79 $capability,
80 ACYM_COMPONENT.'_'.$ctrl,
81 [$this->router, 'router']
82 );
83 }
84
85 $controllers = ['dynamics', 'file', 'language'];
86 foreach ($controllers as $oneCtrl) {
87 add_submenu_page(
88 ACYM_COMPONENT.'_'.$oneCtrl,
89 $oneCtrl,
90 $oneCtrl,
91 $capability,
92 ACYM_COMPONENT.'_'.$oneCtrl,
93 [$this->router, 'router']
94 );
95 }
96
97 global $submenu;
98 if (isset($submenu[ACYM_COMPONENT.'_dashboard'])) {
99 $submenu[ACYM_COMPONENT.'_dashboard'][0][0] = acym_translation('ACYM_DASHBOARD');
100 }
101 }
102
103 public function addPluginLinks($links): array
104 {
105 $settings_link = '<a href="admin.php?page='.ACYM_COMPONENT.'_configuration">'.acym_translation('ACYM_SETTINGS').'</a>';
106
107 return array_merge([$settings_link], $links);
108 }
109 }
110