PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.3
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.3
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
← All changes | includes/Admin/EasyInvoiceAdmin.php +357 -30 2.1.1 → 2.4.3 View file →
@@ -71,8 +71,15 @@
71 71 */
72 72 private $payment_controller;
73 73
74 74 /**
75 + * Template Builder controller instance
76 + *
77 + * @var \EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController
78 + */
79 + private $template_builder_controller;
80 +
81 + /**
75 82 * Constructor
76 83 */
77 84 public function __construct() {
78 85 $this->invoice_controller = new InvoiceController();
@@ -81,8 +88,21 @@
81 88 $this->settings_controller = new SettingsController();
82 89 $this->report_controller = new ReportController();
83 90 $this->dashboard_controller = new DashboardController();
84 91 $this->payment_controller = new PaymentController();
92 +
93 + // Initialize Template Builder controller if Pro is active AND
94 + // the custom_templates addon is enabled. The addon owns this
95 + // feature — see addons/CustomTemplates/addon.php in the Pro
96 + // plugin. Constructing the controller here always-on would
97 + // register its admin_menu hook regardless of addon state.
98 + if (
99 + easy_invoice_has_pro()
100 + && \EasyInvoice\Addons\AddonManager::shouldLoad('custom_templates')
101 + && class_exists('\EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController')
102 + ) {
103 + $this->template_builder_controller = new \EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController();
104 + }
85 105 }
86 106
87 107 /**
88 108 * Initialize the admin class
@@ -89,8 +109,9 @@
89 109 */
90 110 public function init() {
91 111 // Add menu items
92 112 add_action('admin_menu', array($this, 'registerMenuPages'));
113 + add_action('admin_menu', array($this, 'relaxMenuCapabilities'), 9999);
93 114
94 115 // Register admin assets
95 116 $admin_assets = new AdminAssets();
96 117 $admin_assets->register();
@@ -103,8 +124,11 @@
103 124
104 125 // Hide admin UI
105 126 add_action('admin_head', array($this, 'hideAdminUi'));
106 127
128 + // Body class for layout fixes (admin bar offset, header strip alignment)
129 + add_filter('admin_body_class', array($this, 'adminBodyClass'));
130 +
107 131 // Initialize controllers
108 132 $this->invoice_controller->init();
109 133 $this->quote_controller->init();
110 134 $this->client_controller->init();
@@ -117,8 +141,74 @@
117 141 add_action('easy_invoice_admin_main_content', array($this, 'mainPageContent'));
118 142 }
119 143
120 144 /**
145 + * Let an addon lower the capability a menu page demands.
146 + *
147 + * Every page is registered with `manage_options`, which is right for a
148 + * site with one administrator and wrong the moment the Team Roles addon
149 + * hands a colleague an "EI Viewer" role: WordPress refused them every
150 + * screen before the plugin's own capability checks were even consulted.
151 + * add_submenu_page() drops a page outright when the current user lacks
152 + * the capability, so the plugin's own pages pass through menuCapability()
153 + * at registration; this late pass covers pages registered elsewhere.
154 + */
155 + public function menuCapability($slug) {
156 + /** This filter is documented in relaxMenuCapabilities(). */
157 + return (string) apply_filters('easy_invoice_menu_capability', 'manage_options', (string) $slug);
158 + }
159 +
160 + public function relaxMenuCapabilities() {
161 + global $menu, $submenu;
162 + $relax = static function ($cap, $slug) {
163 + if (!is_string($slug) || 0 !== strpos($slug, 'easy-') ) {
164 + return $cap;
165 + }
166 + /**
167 + * Filter the capability required to open an Easy Invoice admin page.
168 + *
169 + * @param string $cap Capability registered for the page.
170 + * @param string $slug Page slug.
171 + */
172 + return (string) apply_filters('easy_invoice_menu_capability', $cap, $slug);
173 + };
174 + if (is_array($menu)) {
175 + foreach ($menu as $i => $item) {
176 + if (isset($item[1], $item[2])) {
177 + $menu[$i][1] = $relax($item[1], $item[2]);
178 + }
179 + }
180 + }
181 + if (is_array($submenu)) {
182 + foreach ($submenu as $parent => $items) {
183 + foreach ((array) $items as $i => $item) {
184 + if (isset($item[1], $item[2])) {
185 + $submenu[$parent][$i][1] = $relax($item[1], $item[2]);
186 + }
187 + }
188 + }
189 + }
190 + }
191 +
192 + /**
193 + * The admin menu mark: the same document-and-tick glyph as the plugin
194 + * icon, monochrome so it follows WordPress' menu colour schemes. Falls
195 + * back to a dashicon if the file is ever missing from the build.
196 + *
197 + * @return string Data URI, or a dashicon class.
198 + */
199 + public static function menuIcon() {
200 + static $icon = null;
201 + if ($icon !== null) {
202 + return $icon;
203 + }
204 + $file = EASY_INVOICE_PLUGIN_DIR . 'assets/images/menu-icon.svg';
205 + $svg = is_readable($file) ? file_get_contents($file) : '';
206 + $icon = $svg ? 'data:image/svg+xml;base64,' . base64_encode($svg) : 'dashicons-media-text';
207 + return $icon;
208 + }
209 +
210 + /**
121 211 * Register admin menu pages
122 212 */
123 213 public function registerMenuPages() {
124 214 // Main menu item
@@ -124,12 +214,12 @@
124 214 // Main menu item
125 215 add_menu_page(
126 216 __('Easy Invoice', 'easy-invoice'),
127 217 __('Easy Invoice', 'easy-invoice'),
128 - 'manage_options',
218 + $this->menuCapability(PagesSlugs::DASHBOARD),
129 219 PagesSlugs::DASHBOARD,
130 220 array($this, 'displayMainPage'),
131 - 'dashicons-media-text',
221 + self::menuIcon(),
132 222 25
133 223 );
134 224
135 225 // Dashboard submenu
@@ -136,9 +226,9 @@
136 226 add_submenu_page(
137 227 'easy-invoice',
138 228 __('Dashboard', 'easy-invoice'),
139 229 __('Dashboard', 'easy-invoice'),
140 - 'manage_options',
230 + $this->menuCapability(PagesSlugs::DASHBOARD),
141 231 PagesSlugs::DASHBOARD,
142 232 array($this, 'displayMainPage')
143 233 );
144 234
@@ -146,9 +236,9 @@
146 236 add_submenu_page(
147 237 'easy-invoice',
148 238 __('All Invoices', 'easy-invoice'),
149 239 __('All Invoices', 'easy-invoice'),
150 - 'manage_options',
240 + $this->menuCapability(PagesSlugs::ALL_INVOICES),
151 241 PagesSlugs::ALL_INVOICES,
152 242 array($this, 'displayMainPage')
153 243 );
154 244
@@ -156,9 +246,9 @@
156 246 add_submenu_page(
157 247 'easy-invoice-hidden',
158 248 __('Add New Invoice', 'easy-invoice'),
159 249 __('Add New', 'easy-invoice'),
160 - 'manage_options',
250 + $this->menuCapability(PagesSlugs::INVOICE_NEW),
161 251 PagesSlugs::INVOICE_NEW,
162 252 array($this, 'displayMainPage')
163 253 );
164 254
@@ -166,9 +256,9 @@
166 256 add_submenu_page(
167 257 'easy-invoice',
168 258 __('All Quotes', 'easy-invoice'),
169 259 __('All Quotes', 'easy-invoice'),
170 - 'manage_options',
260 + $this->menuCapability(PagesSlugs::ALL_QUOTES),
171 261 PagesSlugs::ALL_QUOTES,
172 262 array($this, 'displayMainPage')
173 263 );
174 264
@@ -176,9 +266,9 @@
176 266 add_submenu_page(
177 267 'easy-invoice-hidden',
178 268 __('Add New Quote', 'easy-invoice'),
179 269 __('Add New Quote', 'easy-invoice'),
180 - 'manage_options',
270 + $this->menuCapability(PagesSlugs::QUOTE_NEW),
181 271 PagesSlugs::QUOTE_NEW,
182 272 array($this, 'displayMainPage')
183 273 );
184 274
@@ -186,9 +276,9 @@
186 276 add_submenu_page(
187 277 'easy-invoice-hidden',
188 278 __('Payments', 'easy-invoice'),
189 279 __('Payments', 'easy-invoice'),
190 - 'manage_options',
280 + $this->menuCapability(PagesSlugs::PAYMENTS),
191 281 PagesSlugs::PAYMENTS,
192 282 array($this, 'displayMainPage')
193 283 );
194 284
@@ -196,9 +286,9 @@
196 286 add_submenu_page(
197 287 'easy-invoice-hidden',
198 288 __('Add New Payment', 'easy-invoice'),
199 289 __('Add New Payment', 'easy-invoice'),
200 - 'manage_options',
290 + $this->menuCapability(PagesSlugs::PAYMENT_NEW),
201 291 PagesSlugs::PAYMENT_NEW,
202 292 array($this, 'displayMainPage')
203 293 );
204 294
@@ -206,19 +296,77 @@
206 296 add_submenu_page(
207 297 'easy-invoice',
208 298 __('All Clients', 'easy-invoice'),
209 299 __('All Clients', 'easy-invoice'),
210 - 'manage_options',
300 + $this->menuCapability(PagesSlugs::CLIENTS),
211 301 PagesSlugs::CLIENTS,
212 302 array($this, 'displayMainPage')
213 303 );
214 304
305 + // Item Library + Template Builder pages are reached via the
306 + // Easy Invoice in-app sidebar (templates/main-template.php), NOT
307 + // the WP admin submenu. We still register the page slugs so the
308 + // URLs resolve, but we parent them under 'easy-invoice-hidden'
309 + // so they don't render duplicate entries in the WP submenu —
310 + // the WP submenu showed the link AND the in-app sidebar showed
311 + // the same link, giving the user two visible navigation
312 + // entry-points to the same page.
313 + //
314 + // Registration is still gated on the addon being active — if
315 + // the addon is off, the slug isn't registered, so direct-URL
316 + // access returns the standard "you do not have sufficient
317 + // permissions" page.
318 + if (easy_invoice_has_pro() && \EasyInvoice\Addons\AddonManager::shouldLoad('item_library')) {
319 + add_submenu_page(
320 + 'easy-invoice-hidden',
321 + __('Item Library', 'easy-invoice'),
322 + __('Item Library', 'easy-invoice'),
323 + $this->menuCapability('easy-invoice-pro-item-library'),
324 + 'easy-invoice-pro-item-library',
325 + array($this, 'displayMainPage')
326 + );
327 + }
328 +
329 + if (easy_invoice_has_pro() && \EasyInvoice\Addons\AddonManager::shouldLoad('custom_templates')) {
330 + // Template listing — reachable from the in-app sidebar.
331 + add_submenu_page(
332 + 'easy-invoice-hidden',
333 + __('Template Builder', 'easy-invoice'),
334 + __('Template Builder', 'easy-invoice'),
335 + $this->menuCapability('easy-invoice-templates'),
336 + 'easy-invoice-templates',
337 + array($this, 'displayMainPage')
338 + );
339 +
340 + // Create New Template — used by deep-links from inside the
341 + // builder UI.
342 + add_submenu_page(
343 + 'easy-invoice-hidden',
344 + __('Create New Template', 'easy-invoice'),
345 + __('Create New', 'easy-invoice'),
346 + $this->menuCapability('easy-invoice-templates-new'),
347 + 'easy-invoice-templates-new',
348 + array($this, 'displayMainPage')
349 + );
350 +
351 + // Template Builder canvas — full-screen builder, reached
352 + // from the listing page's Edit / New buttons.
353 + add_submenu_page(
354 + 'easy-invoice-hidden',
355 + __('Template Builder Page', 'easy-invoice'),
356 + __('Template Builder Page', 'easy-invoice'),
357 + $this->menuCapability('easy-invoice-template-builder'),
358 + 'easy-invoice-template-builder',
359 + array($this, 'displayMainPage')
360 + );
361 + }
362 +
215 363 // Hidden submenu pages - not shown in the menu but accessible
216 364 add_submenu_page(
217 365 'easy-invoice-hidden', // Use main menu as parent to avoid title issues
218 366 __('Edit Client', 'easy-invoice'),
219 367 __('Edit Client', 'easy-invoice'),
220 - 'manage_options',
368 + $this->menuCapability(PagesSlugs::CLIENT_EDIT),
221 369 PagesSlugs::CLIENT_EDIT,
222 370 array($this, 'displayMainPage')
223 371 );
224 372
@@ -225,9 +373,9 @@
225 373 add_submenu_page(
226 374 'easy-invoice-hidden', // Use main menu as parent to avoid title issues
227 375 __('View Client', 'easy-invoice'),
228 376 __('View Client', 'easy-invoice'),
229 - 'manage_options',
377 + $this->menuCapability(PagesSlugs::CLIENT_VIEW),
230 378 PagesSlugs::CLIENT_VIEW,
231 379 array($this, 'displayMainPage')
232 380 );
233 381
@@ -234,9 +382,9 @@
234 382 add_submenu_page(
235 383 'easy-invoice-hidden', // Use main menu as parent to avoid title issues
236 384 __('Preview Invoice', 'easy-invoice'),
237 385 __('Preview Invoice', 'easy-invoice'),
238 - 'manage_options',
386 + $this->menuCapability(PagesSlugs::INVOICE_PREVIEW),
239 387 PagesSlugs::INVOICE_PREVIEW,
240 388 array($this, 'displayPreviewPage')
241 389 );
242 390
@@ -243,29 +391,46 @@
243 391 add_submenu_page(
244 392 'easy-invoice-hidden', // Use main menu as parent to avoid title issues
245 393 __('Preview Quote', 'easy-invoice'),
246 394 __('Preview Quote', 'easy-invoice'),
247 - 'manage_options',
395 + $this->menuCapability(PagesSlugs::QUOTE_PREVIEW),
248 396 PagesSlugs::QUOTE_PREVIEW,
249 397 array($this, 'displayMainPage')
250 398 );
251 399
400 + // Reports — addon-gated (Personal tier). Slug registered as a
401 + // HIDDEN submenu so the WP admin sidebar doesn't double the
402 + // in-app sidebar entry. When the reports addon is disabled, the
403 + // slug isn't registered at all, so direct-URL access falls
404 + // through to WP's "no permission" page.
405 + if (\EasyInvoice\Addons\AddonManager::shouldLoad('reports')) {
406 + add_submenu_page(
407 + 'easy-invoice-hidden',
408 + __('Reports', 'easy-invoice'),
409 + __('Reports', 'easy-invoice'),
410 + $this->menuCapability(PagesSlugs::REPORTS),
411 + PagesSlugs::REPORTS,
412 + array($this, 'displayMainPage')
413 + );
414 + }
415 +
416 + // Settings submenu
252 417 add_submenu_page(
253 418 'easy-invoice',
254 - __('Reports', 'easy-invoice'),
255 - __('Reports', 'easy-invoice'),
256 - 'manage_options',
257 - PagesSlugs::REPORTS,
419 + __('Settings', 'easy-invoice'),
420 + __('Settings', 'easy-invoice'),
421 + $this->menuCapability(PagesSlugs::SETTINGS),
422 + PagesSlugs::SETTINGS,
258 423 array($this, 'displayMainPage')
259 424 );
260 425
261 - // Settings submenu
426 + // Addons submenu
262 427 add_submenu_page(
263 428 'easy-invoice',
264 - __('Settings', 'easy-invoice'),
265 - __('Settings', 'easy-invoice'),
266 - 'manage_options',
267 - PagesSlugs::SETTINGS,
429 + __('Addons', 'easy-invoice'),
430 + __('Addons', 'easy-invoice'),
431 + $this->menuCapability(PagesSlugs::ADDONS),
432 + PagesSlugs::ADDONS,
268 433 array($this, 'displayMainPage')
269 434 );
270 435
271 436 // License submenu
@@ -272,9 +437,9 @@
272 437 add_submenu_page(
273 438 'easy-invoice',
274 439 __('License', 'easy-invoice'),
275 440 __('License', 'easy-invoice'),
276 - 'manage_options',
441 + $this->menuCapability(PagesSlugs::LICENSE),
277 442 PagesSlugs::LICENSE,
278 443 array($this, 'displayMainPage')
279 444 );
280 445
@@ -283,20 +448,43 @@
283 448 add_submenu_page(
284 449 'easy-invoice',
285 450 __('Free vs Pro', 'easy-invoice'),
286 451 __('Free vs Pro', 'easy-invoice'),
287 - 'manage_options',
452 + $this->menuCapability('easy-invoice-free-vs-pro'),
288 453 'easy-invoice-free-vs-pro',
289 454 array($this, 'displayMainPage')
290 455 );
291 456 }
457 +
458 + // Join Community submenu
459 + add_submenu_page(
460 + 'easy-invoice-hidden',
461 + __('Join Community', 'easy-invoice'),
462 + __('Join Community', 'easy-invoice'),
463 + 'read',
464 + 'easy-invoice-join-community',
465 + array($this, 'redirectToCommunity')
466 + );
292 467 }
293 468
294 469 /**
295 - * Register invoice preview page
470 + * Redirect to community page
296 471 */
472 + public function redirectToCommunity() {
473 + wp_safe_redirect(esc_url_raw('https://www.facebook.com/groups/mantrabraincommunity'));
474 + exit;
475 + }
476 +
477 + /**
478 + * Register invoice preview page.
479 + *
480 + * Placeholder kept as an extension point — the preview-page hook used to
481 + * be wired here but is now routed through the per-document preview
482 + * controller. Left in place so themes/plugins relying on a no-op
483 + * `registerPreviewPage()` call don't fatal.
484 + */
297 485 public function registerPreviewPage() {
298 - //add_action('admin_action_easy_invoice_preview', array($this, 'displayPreviewPage'));
486 + // No-op: preview rendering is handled by the per-document controller.
299 487 }
300 488
301 489 /**
302 490 * Display main page
@@ -319,8 +507,17 @@
319 507 include EASY_INVOICE_PLUGIN_DIR . 'templates/admin/license-page.php';
320 508 }
321 509
322 510 /**
511 + * Display addons page
512 + */
513 + public function displayAddonsPage() {
514 + if (class_exists('\\EasyInvoice\\Controllers\\AddonsController')) {
515 + (new \EasyInvoice\Controllers\AddonsController())->display();
516 + }
517 + }
518 +
519 + /**
323 520 * Handle main page content based on the current page
324 521 *
325 522 * @param string $page Current page
326 523 */
@@ -355,9 +552,9 @@
355 552 break;
356 553
357 554 case PagesSlugs::PAYMENTS:
358 555 if (isset($_GET['action'])) {
359 - $this->payment_controller->display(['page' => $_GET['action']]);
556 + $this->payment_controller->display(['page' => sanitize_key(wp_unslash($_GET['action']))]); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
360 557 } else {
361 558 $this->payment_controller->display(['page' => PagesSlugs::PAYMENTS]);
362 559 }
363 560 break;
@@ -373,14 +570,59 @@
373 570 case PagesSlugs::CLIENT_EDIT:
374 571 $this->client_controller->display(['page' => PagesSlugs::CLIENT_EDIT]);
375 572 break;
376 573
574 + // Handle Pro features — gated on addon-state. The menu
575 + // registrations above are also addon-gated, so these cases
576 + // should only fire when the addon is enabled. Re-checking
577 + // shouldLoad() here is defensive in case the user hits the
578 + // page slug directly via URL.
579 + case 'easy-invoice-pro-item-library':
580 + if (
581 + easy_invoice_has_pro()
582 + && \EasyInvoice\Addons\AddonManager::shouldLoad('item_library')
583 + && class_exists('\EasyInvoicePro\Addons\ItemLibrary\Controllers\ItemLibraryController')
584 + ) {
585 + $item_library_controller = new \EasyInvoicePro\Addons\ItemLibrary\Controllers\ItemLibraryController();
586 + $item_library_controller->displayMainPage();
587 + }
588 + break;
589 +
590 + case 'easy-invoice-templates':
591 + if (
592 + easy_invoice_has_pro()
593 + && \EasyInvoice\Addons\AddonManager::shouldLoad('custom_templates')
594 + && class_exists('\EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController')
595 + ) {
596 + $template_builder_controller = new \EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController();
597 + $template_builder_controller->displayMainPage();
598 + }
599 + break;
600 +
601 + case 'easy-invoice-template-builder':
602 + if (
603 + easy_invoice_has_pro()
604 + && \EasyInvoice\Addons\AddonManager::shouldLoad('custom_templates')
605 + && class_exists('\EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController')
606 + ) {
607 + $template_builder_controller = new \EasyInvoicePro\Addons\CustomTemplates\Controllers\TemplateBuilderController();
608 + $template_builder_controller->displayMainPage();
609 + }
610 + break;
611 +
377 612 case PagesSlugs::CLIENT_VIEW:
378 613 $this->client_controller->display(['page' => PagesSlugs::CLIENT_VIEW]);
379 614 break;
380 615
381 616 case PagesSlugs::REPORTS:
382 - $this->report_controller->display(['page' => PagesSlugs::REPORTS]);
617 + // Reports is addon-gated. The submenu page slug is only
618 + // registered when shouldLoad('reports') is true, so this
619 + // case ordinarily only fires for active-addon users —
620 + // but recheck defensively in case the page is reached
621 + // via direct URL right after the addon was disabled.
622 + if (\EasyInvoice\Addons\AddonManager::shouldLoad('reports')) {
623 + $this->report_controller->display(['page' => PagesSlugs::REPORTS]);
624 + }
383 625 break;
384 626
385 627 case PagesSlugs::SETTINGS:
386 628 $this->settings_controller->display(['page' => PagesSlugs::SETTINGS]);
@@ -389,8 +631,12 @@
389 631 case PagesSlugs::LICENSE:
390 632 $this->displayLicensePage();
391 633 break;
392 634
635 + case PagesSlugs::ADDONS:
636 + $this->displayAddonsPage();
637 + break;
638 +
393 639 case PagesSlugs::EMAIL_SETTINGS:
394 640 case PagesSlugs::EMAIL_SETTINGS_GENERAL:
395 641 case PagesSlugs::EMAIL_SETTINGS_INVOICE:
396 642 case PagesSlugs::EMAIL_SETTINGS_QUOTE:
@@ -406,8 +652,60 @@
406 652 include EASY_INVOICE_PLUGIN_DIR . 'templates/admin/free-vs-pro-page.php';
407 653 break;
408 654
409 655 default:
656 + // Addon pages render themselves via the
657 + // `easy_invoice_admin_main_content` action at priority 11. The
658 + // dispatcher must NOT fall through to the Dashboard for those
659 + // slugs, otherwise the Dashboard markup gets emitted first and
660 + // the addon panel renders on top of it (two pages stacked).
661 + //
662 + // We treat any slug that's either (a) prefixed with
663 + // `easy-invoice-addon-` or (b) registered in AddonRegistry as
664 + // an addon page — and just `break` to let the addon's own hook
665 + // handle the rendering.
666 + if (strpos($page, 'easy-invoice-addon-') === 0) {
667 + break;
668 + }
669 +
670 + /**
671 + * Slugs whose page draws itself on the same hook at a later
672 + * priority, and which must therefore not get the Dashboard
673 + * rendered underneath them.
674 + *
675 + * Addon pages were special-cased by prefix above, which left
676 + * anything in the free plugin that renders the same way — the
677 + * credit note screen, for one — falling through to the
678 + * Dashboard and stacking two pages on top of each other. A
679 + * filter means the next such page registers itself instead of
680 + * editing this switch and rediscovering the same bug.
681 + *
682 + * @param string[] $slugs Page slugs that render themselves.
683 + */
684 + // "Create New Template" is a deep-link slug with no screen of
685 + // its own; send it to the builder rather than draw the Dashboard.
686 + if ('easy-invoice-templates-new' === $page) {
687 + echo '<script>window.location.replace(' . wp_json_encode(admin_url('admin.php?page=easy-invoice-template-builder&action=new')) . ');</script>';
688 + break;
689 + }
690 + $self_rendering = (array) apply_filters('easy_invoice_self_rendering_pages', [
691 + \EasyInvoice\Controllers\CreditNoteController::PAGE_SLUG,
692 + ]);
693 +
694 + if (in_array($page, $self_rendering, true)) {
695 + break;
696 + }
697 + if (class_exists('\\EasyInvoice\\Addons\\AddonRegistry')) {
698 + foreach (\EasyInvoice\Addons\AddonRegistry::all() as $_addon) {
699 + if (empty($_addon['settings_url'])) continue;
700 + $parsed = wp_parse_url($_addon['settings_url']);
701 + if (empty($parsed['query'])) continue;
702 + parse_str($parsed['query'], $q);
703 + if (($q['page'] ?? '') === $page) {
704 + return; // Addon owns this slug — bail without rendering.
705 + }
706 + }
707 + }
410 708 $this->dashboard_controller->display(['page' => PagesSlugs::DASHBOARD]);
411 709 break;
412 710 }
413 711 }
@@ -440,8 +738,9 @@
440 738 'easy-invoice-settings' => __('Settings', 'easy-invoice'),
441 739 'easy-invoice-email-settings' => __('Email Settings', 'easy-invoice'),
442 740 'easy-invoice-migration' => __('Migration', 'easy-invoice'),
443 741 'easy-invoice-free-vs-pro' => __('Free vs Pro', 'easy-invoice'),
742 + 'easy-invoice-addons' => __('Addons', 'easy-invoice'),
444 743 ];
445 744
446 745 if (isset($page_titles[$current_page])) {
447 746 return $page_titles[$current_page] . ' - ' . get_bloginfo('name');
@@ -451,13 +750,30 @@
451 750 return $title;
452 751 }
453 752
454 753 /**
754 + * Body class for Easy Invoice full-width layout (used by hideAdminUi CSS).
755 + *
756 + * @param string $classes Space-separated classes.
757 + * @return string
758 + */
759 + public function adminBodyClass($classes) {
760 + $screen = get_current_screen();
761 + if (!$screen || !isset($screen->id)) {
762 + return $classes;
763 + }
764 + if (strpos($screen->id, 'easy-invoice') !== false || strpos($screen->id, 'easy-quote') !== false) {
765 + $classes .= ' easy-invoice-admin-body';
766 + }
767 + return $classes;
768 + }
769 +
770 + /**
455 771 * Hide the WordPress admin UI for our custom pages
456 772 */
457 773 public function hideAdminUi() {
458 774 $screen = get_current_screen();
459 - if ($screen && property_exists($screen, 'id') && strpos($screen->id, 'easy-invoice') !== false) {
775 + if ($screen && property_exists($screen, 'id') && (strpos($screen->id, 'easy-invoice') !== false || strpos($screen->id, 'easy-quote') !== false)) {
460 776 ?>
461 777 <style>
462 778 #wpadminbar,
463 779 #adminmenumain,
@@ -470,8 +786,19 @@
470 786 }
471 787 .wrap {
472 788 margin: 0 !important;
473 789 padding: 0 !important;
790 + }
791 + /*
792 + * Admin bar is hidden but body.admin-bar often still gets top padding,
793 + * shifting #wpbody down while the fixed plugin sidebar stays at y=0 — header borders misalign.
794 + */
795 + body.easy-invoice-admin-body.admin-bar {
796 + padding-top: 0 !important;
797 + }
798 + body.easy-invoice-admin-body.admin-bar #wpbody,
799 + body.easy-invoice-admin-body.admin-bar #wpbody-content {
800 + padding-top: 0 !important;
474 801 }
475 802 </style>
476 803 <?php
477 804 }