PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Services/Menu/MenuManager.php +72 -9 0.3.1 → 1.5 View file →
@@ -1,19 +1,15 @@
1 1 <?php
2 2
3 3 /**
4 - * @copyright © TMS-Plugins. All rights reserved.
4 + * @copyright © Melograno Venture Studio. All rights reserved.
5 5 * @licence See LICENCE.md for license details.
6 6 */
7 7
8 8 namespace IvyForms\Services\Menu;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 10 use Closure;
11 +use IvyForms\Services\Permissions\IvyFormsAccess;
16 12
17 13 class MenuManager
18 14 {
19 15 private MenuMapper $menu;
@@ -30,8 +26,11 @@
30 26 public function registerMenus(): void
31 27 {
32 28 // Hook into WordPress 'admin_menu' action
33 29 add_action('admin_menu', [$this, 'addOptionsPages']);
30 +
31 + // Add admin CSS for upgrade menu styling
32 + add_action('admin_enqueue_scripts', [$this, 'addUpgradeMenuStyles']);
34 33 }
35 34
36 35 public function addOptionsPages(): void
37 36 {
@@ -37,12 +36,11 @@
37 36 {
38 37 add_menu_page(
39 38 'IvyForms',
40 39 'IvyForms',
41 - // TODO - Add IvyForms capability
42 - 'read',
40 + IvyFormsAccess::CAP_ACCESS_PLUGIN,
43 41 'ivyforms',
44 - '', // @phpstan-ignore argument.type
42 + null, // @phpstan-ignore argument.type
45 43 IVYFORMS_URL . 'frontend/src/assets/images/logos/logo-only-admin.svg'
46 44 );
47 45
48 46 foreach (($this->menu)() as $menu) {
@@ -49,8 +47,11 @@
49 47 $this->handleMenuItem($menu);
50 48 }
51 49
52 50 remove_submenu_page('ivyforms', 'ivyforms');
51 +
52 + // Add JavaScript to make upgrade menu open in new tab
53 + add_action('admin_footer', [$this, 'addUpgradeMenuScript']);
53 54 }
54 55
55 56 /**
56 57 *
@@ -57,8 +58,21 @@
57 58 * @param mixed[] $menu
58 59 * */
59 60 public function handleMenuItem(array $menu): void
60 61 {
62 + // For external links (like upgrade menu), just add without callback
63 + if (isset($menu['isExternal']) && $menu['isExternal']) {
64 + add_submenu_page(
65 + $menu['parentSlug'],
66 + $menu['pageTitle'],
67 + $menu['menuTitle'],
68 + $menu['capability'],
69 + $menu['menuSlug'],
70 + ''
71 + );
72 + return;
73 + }
74 +
61 75 $this->addSubmenuPage(
62 76 $menu['parentSlug'],
63 77 $menu['pageTitle'],
64 78 $menu['menuTitle'],
@@ -85,6 +99,55 @@
85 99 $capability,
86 100 $menuSlug,
87 101 $function
88 102 );
103 + }
104 +
105 + /**
106 + * Add CSS styling for upgrade menu
107 + */
108 + public function addUpgradeMenuStyles(): void
109 + {
110 + // Register an empty / dummy stylesheet (NO file needed)
111 + wp_register_style('ivyforms-admin-menu', false);
112 + wp_enqueue_style('ivyforms-admin-menu');
113 +
114 + $customCss = '
115 + #adminmenu .ivyforms-upgrade-to-pro {
116 + display: flex;
117 + align-items: flex-start;
118 + font-weight: 600 !important;
119 + color: #ffffff !important;
120 + }
121 + #adminmenu .ivyforms-upgrade-to-pro svg {
122 + width: 18px;
123 + height: 16px;
124 + flex-shrink: 0;
125 + }
126 + #adminmenu li a:has(.ivyforms-upgrade-to-pro) {
127 + background-color: #F69D0B !important;
128 + }
129 + #adminmenu li a:has(.ivyforms-upgrade-to-pro):hover {
130 + background-color: #E08D00 !important;
131 + }
132 + ';
133 + wp_add_inline_style('ivyforms-admin-menu', $customCss);
134 + }
135 +
136 + /**
137 + * Add JavaScript to make upgrade menu link open in new tab
138 + */
139 + public function addUpgradeMenuScript(): void
140 + {
141 + ?>
142 + <script>
143 + (function() {
144 + const upgradeLink = document.querySelector('#adminmenu a[href*="ivyforms.com/pricing"]');
145 + if (upgradeLink) {
146 + upgradeLink.setAttribute('target', '_blank');
147 + upgradeLink.setAttribute('rel', 'noopener nofollow noreferrer');
148 + }
149 + })();
150 + </script>
151 + <?php
89 152 }
90 153 }