PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.2.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.2.2
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.2.2, at WpInit/Menu.php

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