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 | WpInit/Menu.php +11 -4 10.2.2 → 11.1.0 View file →
@@ -1,13 +1,11 @@
1 1 <?php
2 2
3 3 namespace AcyMailing\WpInit;
4 4
5 -use AcyMailing\Classes\PluginClass;
6 -
7 5 class Menu
8 6 {
9 - var $router;
7 + private Router $router;
10 8
11 9 public function __construct($router)
12 10 {
13 11 $this->router = $router;
@@ -12,18 +10,23 @@
12 10 {
13 11 $this->router = $router;
14 12
15 13 if (defined('WP_ADMIN') && WP_ADMIN) {
14 + // Add AcyMailing menu in the back-end's left menu of WordPress
16 15 add_action('admin_menu', [$this, 'addMenus'], 99);
17 16 }
18 17
18 + // Add "settings" link for acym on plugins listing
19 19 add_filter('plugin_action_links_'.plugin_basename(dirname(__DIR__).'/index.php'), [$this, 'addPluginLinks']);
20 20 }
21 21
22 + // Add AcyMailing menu to WP left menu and define controllers
22 23 public function addMenus()
23 24 {
25 + // Everyone in WordPress can read, the real test is made bellow
24 26 $capability = 'read';
25 27
28 + // Make sure the user is allowed to see admin features
26 29 $config = acym_config();
27 30 $allowedGroups = explode(',', $config->get('wp_access', 'administrator'));
28 31 $userGroups = acym_getGroupsByUser();
29 32
@@ -35,9 +38,10 @@
35 38 }
36 39 }
37 40 if (!$allowed) return;
38 41
39 - $svg = acym_loaderLogo(false);
42 + // Add the Acy menu items to the WP menu
43 + $svg = acym_fileGetContent(ACYM_IMAGES.'logos/logo_grey.svg');
40 44 add_menu_page(
41 45 acym_translation('ACYM_DASHBOARD'),
42 46 'AcyMailing',
43 47 $capability,
@@ -83,8 +87,9 @@
83 87 [$this->router, 'router']
84 88 );
85 89 }
86 90
91 + // Declare invisible menus
87 92 $controllers = ['dynamics', 'file', 'language'];
88 93 foreach ($controllers as $oneCtrl) {
89 94 add_submenu_page(
90 95 ACYM_COMPONENT.'_'.$oneCtrl,
@@ -95,8 +100,9 @@
95 100 [$this->router, 'router']
96 101 );
97 102 }
98 103
104 + // In WordPress, the first submenu is called "AcyMailing" instead of "Dashboard" so we rename it manually
99 105 global $submenu;
100 106 if (isset($submenu[ACYM_COMPONENT.'_dashboard'])) {
101 107 $submenu[ACYM_COMPONENT.'_dashboard'][0][0] = acym_translation('ACYM_DASHBOARD');
102 108 }
@@ -101,8 +107,9 @@
101 107 $submenu[ACYM_COMPONENT.'_dashboard'][0][0] = acym_translation('ACYM_DASHBOARD');
102 108 }
103 109 }
104 110
111 + // Add links on the plugins listing
105 112 public function addPluginLinks($links): array
106 113 {
107 114 $settings_link = '<a href="admin.php?page='.ACYM_COMPONENT.'_configuration">'.acym_translation('ACYM_SETTINGS').'</a>';
108 115