| 1 |
<?php |
| 2 |
/** |
| 3 |
* EasyInvoice Admin Class |
| 4 |
* |
| 5 |
* @package Easy_Invoice |
| 6 |
* @subpackage Admin |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace EasyInvoice\Admin; |
| 10 |
|
| 11 |
use EasyInvoice\Admin\AdminAssets; |
| 12 |
use EasyInvoice\Constants\PagesSlugs; |
| 13 |
use EasyInvoice\Controllers\InvoiceController; |
| 14 |
use EasyInvoice\Controllers\QuoteController; |
| 15 |
use EasyInvoice\Controllers\ClientController; |
| 16 |
use EasyInvoice\Controllers\SettingsController; |
| 17 |
use EasyInvoice\Controllers\ReportController; |
| 18 |
use EasyInvoice\Controllers\DashboardController; |
| 19 |
use EasyInvoice\Controllers\PaymentController; |
| 20 |
|
| 21 |
/** |
| 22 |
* EasyInvoiceAdmin is the main admin class that initializes all controllers |
| 23 |
*/ |
| 24 |
class EasyInvoiceAdmin { |
| 25 |
/** |
| 26 |
* Invoice controller instance |
| 27 |
* |
| 28 |
* @var InvoiceController |
| 29 |
*/ |
| 30 |
private $invoice_controller; |
| 31 |
|
| 32 |
/** |
| 33 |
* Quote controller instance |
| 34 |
* |
| 35 |
* @var QuoteController |
| 36 |
*/ |
| 37 |
private $quote_controller; |
| 38 |
|
| 39 |
/** |
| 40 |
* Client controller instance |
| 41 |
* |
| 42 |
* @var ClientController |
| 43 |
*/ |
| 44 |
private $client_controller; |
| 45 |
|
| 46 |
/** |
| 47 |
* Settings controller instance |
| 48 |
* |
| 49 |
* @var SettingsController |
| 50 |
*/ |
| 51 |
private $settings_controller; |
| 52 |
|
| 53 |
/** |
| 54 |
* Report controller instance |
| 55 |
* |
| 56 |
* @var ReportController |
| 57 |
*/ |
| 58 |
private $report_controller; |
| 59 |
|
| 60 |
/** |
| 61 |
* Dashboard controller instance |
| 62 |
* |
| 63 |
* @var DashboardController |
| 64 |
*/ |
| 65 |
private $dashboard_controller; |
| 66 |
|
| 67 |
/** |
| 68 |
* Payment controller instance |
| 69 |
* |
| 70 |
* @var PaymentController |
| 71 |
*/ |
| 72 |
private $payment_controller; |
| 73 |
|
| 74 |
/** |
| 75 |
* Template Builder controller instance |
| 76 |
* |
| 77 |
* @var \EasyInvoicePro\Controllers\TemplateBuilderController |
| 78 |
*/ |
| 79 |
private $template_builder_controller; |
| 80 |
|
| 81 |
/** |
| 82 |
* Constructor |
| 83 |
*/ |
| 84 |
public function __construct() { |
| 85 |
$this->invoice_controller = new InvoiceController(); |
| 86 |
$this->quote_controller = new QuoteController(); |
| 87 |
$this->client_controller = new ClientController(); |
| 88 |
$this->settings_controller = new SettingsController(); |
| 89 |
$this->report_controller = new ReportController(); |
| 90 |
$this->dashboard_controller = new DashboardController(); |
| 91 |
$this->payment_controller = new PaymentController(); |
| 92 |
|
| 93 |
// Initialize Template Builder controller if Pro is active |
| 94 |
if (easy_invoice_has_pro() && class_exists('\EasyInvoicePro\Controllers\TemplateBuilderController')) { |
| 95 |
$this->template_builder_controller = new \EasyInvoicePro\Controllers\TemplateBuilderController(); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Initialize the admin class |
| 101 |
*/ |
| 102 |
public function init() { |
| 103 |
// Add menu items |
| 104 |
add_action('admin_menu', array($this, 'registerMenuPages')); |
| 105 |
|
| 106 |
// Register admin assets |
| 107 |
$admin_assets = new AdminAssets(); |
| 108 |
$admin_assets->register(); |
| 109 |
|
| 110 |
// Register invoice preview page |
| 111 |
add_action('admin_init', array($this, 'registerPreviewPage')); |
| 112 |
|
| 113 |
// Ensure proper page titles to avoid WordPress core issues |
| 114 |
add_filter('admin_title', array($this, 'setAdminTitle')); |
| 115 |
|
| 116 |
// Hide admin UI |
| 117 |
add_action('admin_head', array($this, 'hideAdminUi')); |
| 118 |
|
| 119 |
// Body class for layout fixes (admin bar offset, header strip alignment) |
| 120 |
add_filter('admin_body_class', array($this, 'adminBodyClass')); |
| 121 |
|
| 122 |
// Initialize controllers |
| 123 |
$this->invoice_controller->init(); |
| 124 |
$this->quote_controller->init(); |
| 125 |
$this->client_controller->init(); |
| 126 |
$this->settings_controller->init(); |
| 127 |
$this->report_controller->init(); |
| 128 |
$this->dashboard_controller->init(); |
| 129 |
$this->payment_controller->init(); |
| 130 |
|
| 131 |
// Main content hook |
| 132 |
add_action('easy_invoice_admin_main_content', array($this, 'mainPageContent')); |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Register admin menu pages |
| 137 |
*/ |
| 138 |
public function registerMenuPages() { |
| 139 |
// Main menu item |
| 140 |
add_menu_page( |
| 141 |
__('Easy Invoice', 'easy-invoice'), |
| 142 |
__('Easy Invoice', 'easy-invoice'), |
| 143 |
'manage_options', |
| 144 |
PagesSlugs::DASHBOARD, |
| 145 |
array($this, 'displayMainPage'), |
| 146 |
'dashicons-media-text', |
| 147 |
25 |
| 148 |
); |
| 149 |
|
| 150 |
// Dashboard submenu |
| 151 |
add_submenu_page( |
| 152 |
'easy-invoice', |
| 153 |
__('Dashboard', 'easy-invoice'), |
| 154 |
__('Dashboard', 'easy-invoice'), |
| 155 |
'manage_options', |
| 156 |
PagesSlugs::DASHBOARD, |
| 157 |
array($this, 'displayMainPage') |
| 158 |
); |
| 159 |
|
| 160 |
// All invoices submenu |
| 161 |
add_submenu_page( |
| 162 |
'easy-invoice', |
| 163 |
__('All Invoices', 'easy-invoice'), |
| 164 |
__('All Invoices', 'easy-invoice'), |
| 165 |
'manage_options', |
| 166 |
PagesSlugs::ALL_INVOICES, |
| 167 |
array($this, 'displayMainPage') |
| 168 |
); |
| 169 |
|
| 170 |
// Add new invoice submenu |
| 171 |
add_submenu_page( |
| 172 |
'easy-invoice-hidden', |
| 173 |
__('Add New Invoice', 'easy-invoice'), |
| 174 |
__('Add New', 'easy-invoice'), |
| 175 |
'manage_options', |
| 176 |
PagesSlugs::INVOICE_NEW, |
| 177 |
array($this, 'displayMainPage') |
| 178 |
); |
| 179 |
|
| 180 |
// All quotes submenu |
| 181 |
add_submenu_page( |
| 182 |
'easy-invoice', |
| 183 |
__('All Quotes', 'easy-invoice'), |
| 184 |
__('All Quotes', 'easy-invoice'), |
| 185 |
'manage_options', |
| 186 |
PagesSlugs::ALL_QUOTES, |
| 187 |
array($this, 'displayMainPage') |
| 188 |
); |
| 189 |
|
| 190 |
// Add new quote submenu |
| 191 |
add_submenu_page( |
| 192 |
'easy-invoice-hidden', |
| 193 |
__('Add New Quote', 'easy-invoice'), |
| 194 |
__('Add New Quote', 'easy-invoice'), |
| 195 |
'manage_options', |
| 196 |
PagesSlugs::QUOTE_NEW, |
| 197 |
array($this, 'displayMainPage') |
| 198 |
); |
| 199 |
|
| 200 |
// Payments submenu |
| 201 |
add_submenu_page( |
| 202 |
'easy-invoice-hidden', |
| 203 |
__('Payments', 'easy-invoice'), |
| 204 |
__('Payments', 'easy-invoice'), |
| 205 |
'manage_options', |
| 206 |
PagesSlugs::PAYMENTS, |
| 207 |
array($this, 'displayMainPage') |
| 208 |
); |
| 209 |
|
| 210 |
// Add new payment submenu |
| 211 |
add_submenu_page( |
| 212 |
'easy-invoice-hidden', |
| 213 |
__('Add New Payment', 'easy-invoice'), |
| 214 |
__('Add New Payment', 'easy-invoice'), |
| 215 |
'manage_options', |
| 216 |
PagesSlugs::PAYMENT_NEW, |
| 217 |
array($this, 'displayMainPage') |
| 218 |
); |
| 219 |
|
| 220 |
// Clients submenu |
| 221 |
add_submenu_page( |
| 222 |
'easy-invoice', |
| 223 |
__('All Clients', 'easy-invoice'), |
| 224 |
__('All Clients', 'easy-invoice'), |
| 225 |
'edit_posts', |
| 226 |
PagesSlugs::CLIENTS, |
| 227 |
array($this, 'displayMainPage') |
| 228 |
); |
| 229 |
|
| 230 |
// Item Library submenu - only show if Pro is active |
| 231 |
if (easy_invoice_has_pro()) { |
| 232 |
add_submenu_page( |
| 233 |
'easy-invoice', |
| 234 |
__('Item Library', 'easy-invoice'), |
| 235 |
__('Item Library', 'easy-invoice'), |
| 236 |
'manage_options', |
| 237 |
'easy-invoice-pro-item-library', |
| 238 |
array($this, 'displayMainPage') |
| 239 |
); |
| 240 |
|
| 241 |
// Template Builder submenu - only show if Pro is active |
| 242 |
add_submenu_page( |
| 243 |
'easy-invoice', |
| 244 |
__('Template Builder', 'easy-invoice'), |
| 245 |
__('Template Builder', 'easy-invoice'), |
| 246 |
'manage_options', |
| 247 |
'easy-invoice-templates', |
| 248 |
array($this, 'displayMainPage') |
| 249 |
); |
| 250 |
|
| 251 |
// Create New Template submenu - only show if Pro is active |
| 252 |
add_submenu_page( |
| 253 |
'easy-invoice-hidden', |
| 254 |
__('Create New Template', 'easy-invoice'), |
| 255 |
__('Create New', 'easy-invoice'), |
| 256 |
'manage_options', |
| 257 |
'easy-invoice-templates-new', |
| 258 |
array($this, 'displayMainPage') |
| 259 |
); |
| 260 |
|
| 261 |
// Template Builder Page submenu - only show if Pro is active (hidden page) |
| 262 |
add_submenu_page( |
| 263 |
'easy-invoice-hidden', |
| 264 |
__('Template Builder Page', 'easy-invoice'), |
| 265 |
__('Template Builder Page', 'easy-invoice'), |
| 266 |
'manage_options', |
| 267 |
'easy-invoice-template-builder', |
| 268 |
array($this, 'displayMainPage') |
| 269 |
); |
| 270 |
} |
| 271 |
|
| 272 |
// Hidden submenu pages - not shown in the menu but accessible |
| 273 |
add_submenu_page( |
| 274 |
'easy-invoice-hidden', // Use main menu as parent to avoid title issues |
| 275 |
__('Edit Client', 'easy-invoice'), |
| 276 |
__('Edit Client', 'easy-invoice'), |
| 277 |
'manage_options', |
| 278 |
PagesSlugs::CLIENT_EDIT, |
| 279 |
array($this, 'displayMainPage') |
| 280 |
); |
| 281 |
|
| 282 |
add_submenu_page( |
| 283 |
'easy-invoice-hidden', // Use main menu as parent to avoid title issues |
| 284 |
__('View Client', 'easy-invoice'), |
| 285 |
__('View Client', 'easy-invoice'), |
| 286 |
'manage_options', |
| 287 |
PagesSlugs::CLIENT_VIEW, |
| 288 |
array($this, 'displayMainPage') |
| 289 |
); |
| 290 |
|
| 291 |
add_submenu_page( |
| 292 |
'easy-invoice-hidden', // Use main menu as parent to avoid title issues |
| 293 |
__('Preview Invoice', 'easy-invoice'), |
| 294 |
__('Preview Invoice', 'easy-invoice'), |
| 295 |
'manage_options', |
| 296 |
PagesSlugs::INVOICE_PREVIEW, |
| 297 |
array($this, 'displayPreviewPage') |
| 298 |
); |
| 299 |
|
| 300 |
add_submenu_page( |
| 301 |
'easy-invoice-hidden', // Use main menu as parent to avoid title issues |
| 302 |
__('Preview Quote', 'easy-invoice'), |
| 303 |
__('Preview Quote', 'easy-invoice'), |
| 304 |
'manage_options', |
| 305 |
PagesSlugs::QUOTE_PREVIEW, |
| 306 |
array($this, 'displayMainPage') |
| 307 |
); |
| 308 |
|
| 309 |
add_submenu_page( |
| 310 |
'easy-invoice', |
| 311 |
__('Reports', 'easy-invoice'), |
| 312 |
__('Reports', 'easy-invoice'), |
| 313 |
'manage_options', |
| 314 |
PagesSlugs::REPORTS, |
| 315 |
array($this, 'displayMainPage') |
| 316 |
); |
| 317 |
|
| 318 |
// Settings submenu |
| 319 |
add_submenu_page( |
| 320 |
'easy-invoice', |
| 321 |
__('Settings', 'easy-invoice'), |
| 322 |
__('Settings', 'easy-invoice'), |
| 323 |
'manage_options', |
| 324 |
PagesSlugs::SETTINGS, |
| 325 |
array($this, 'displayMainPage') |
| 326 |
); |
| 327 |
|
| 328 |
// License submenu |
| 329 |
add_submenu_page( |
| 330 |
'easy-invoice', |
| 331 |
__('License', 'easy-invoice'), |
| 332 |
__('License', 'easy-invoice'), |
| 333 |
'manage_options', |
| 334 |
PagesSlugs::LICENSE, |
| 335 |
array($this, 'displayMainPage') |
| 336 |
); |
| 337 |
|
| 338 |
// Free vs Pro submenu - only show in free version |
| 339 |
if (!easy_invoice_has_pro()) { |
| 340 |
add_submenu_page( |
| 341 |
'easy-invoice', |
| 342 |
__('Free vs Pro', 'easy-invoice'), |
| 343 |
__('Free vs Pro', 'easy-invoice'), |
| 344 |
'manage_options', |
| 345 |
'easy-invoice-free-vs-pro', |
| 346 |
array($this, 'displayMainPage') |
| 347 |
); |
| 348 |
} |
| 349 |
|
| 350 |
// Join Community submenu |
| 351 |
add_submenu_page( |
| 352 |
'easy-invoice-hidden', |
| 353 |
__('Join Community', 'easy-invoice'), |
| 354 |
__('Join Community', 'easy-invoice'), |
| 355 |
'read', |
| 356 |
'easy-invoice-join-community', |
| 357 |
array($this, 'redirectToCommunity') |
| 358 |
); |
| 359 |
} |
| 360 |
|
| 361 |
/** |
| 362 |
* Redirect to community page |
| 363 |
*/ |
| 364 |
public function redirectToCommunity() { |
| 365 |
wp_redirect(esc_url_raw('https://www.facebook.com/groups/mantrabraincommunity')); |
| 366 |
exit; |
| 367 |
} |
| 368 |
|
| 369 |
/** |
| 370 |
* Register invoice preview page |
| 371 |
*/ |
| 372 |
public function registerPreviewPage() { |
| 373 |
//add_action('admin_action_easy_invoice_preview', array($this, 'displayPreviewPage')); |
| 374 |
} |
| 375 |
|
| 376 |
/** |
| 377 |
* Display main page |
| 378 |
*/ |
| 379 |
public function displayMainPage() { |
| 380 |
include EASY_INVOICE_PLUGIN_DIR . 'templates/main-template.php'; |
| 381 |
} |
| 382 |
|
| 383 |
/** |
| 384 |
* Display preview page |
| 385 |
*/ |
| 386 |
public function displayPreviewPage() { |
| 387 |
$this->invoice_controller->display(['page' => PagesSlugs::INVOICE_PREVIEW]); |
| 388 |
} |
| 389 |
|
| 390 |
/** |
| 391 |
* Display license page |
| 392 |
*/ |
| 393 |
public function displayLicensePage() { |
| 394 |
include EASY_INVOICE_PLUGIN_DIR . 'templates/admin/license-page.php'; |
| 395 |
} |
| 396 |
|
| 397 |
/** |
| 398 |
* Handle main page content based on the current page |
| 399 |
* |
| 400 |
* @param string $page Current page |
| 401 |
*/ |
| 402 |
public function mainPageContent($page) { |
| 403 |
switch ($page) { |
| 404 |
case PagesSlugs::DASHBOARD: |
| 405 |
$this->dashboard_controller->display(['page' => PagesSlugs::DASHBOARD]); |
| 406 |
break; |
| 407 |
|
| 408 |
case PagesSlugs::ALL_INVOICES: |
| 409 |
$this->invoice_controller->display(['page' => PagesSlugs::ALL_INVOICES]); |
| 410 |
break; |
| 411 |
|
| 412 |
case PagesSlugs::INVOICE_NEW: |
| 413 |
$this->invoice_controller->display(['page' => PagesSlugs::INVOICE_NEW]); |
| 414 |
break; |
| 415 |
|
| 416 |
case PagesSlugs::INVOICE_PREVIEW: |
| 417 |
$this->invoice_controller->display(['page' => PagesSlugs::INVOICE_PREVIEW]); |
| 418 |
break; |
| 419 |
|
| 420 |
case PagesSlugs::ALL_QUOTES: |
| 421 |
$this->quote_controller->display(['page' => PagesSlugs::ALL_QUOTES]); |
| 422 |
break; |
| 423 |
|
| 424 |
case PagesSlugs::QUOTE_NEW: |
| 425 |
$this->quote_controller->display(['page' => PagesSlugs::QUOTE_NEW]); |
| 426 |
break; |
| 427 |
|
| 428 |
case PagesSlugs::QUOTE_PREVIEW: |
| 429 |
$this->quote_controller->display(['page' => PagesSlugs::QUOTE_PREVIEW]); |
| 430 |
break; |
| 431 |
|
| 432 |
case PagesSlugs::PAYMENTS: |
| 433 |
if (isset($_GET['action'])) { |
| 434 |
$this->payment_controller->display(['page' => $_GET['action']]); |
| 435 |
} else { |
| 436 |
$this->payment_controller->display(['page' => PagesSlugs::PAYMENTS]); |
| 437 |
} |
| 438 |
break; |
| 439 |
|
| 440 |
case PagesSlugs::PAYMENT_NEW: |
| 441 |
$this->payment_controller->display(['page' => PagesSlugs::PAYMENT_NEW]); |
| 442 |
break; |
| 443 |
|
| 444 |
case PagesSlugs::CLIENTS: |
| 445 |
$this->client_controller->display(['page' => PagesSlugs::CLIENTS]); |
| 446 |
break; |
| 447 |
|
| 448 |
case PagesSlugs::CLIENT_EDIT: |
| 449 |
$this->client_controller->display(['page' => PagesSlugs::CLIENT_EDIT]); |
| 450 |
break; |
| 451 |
|
| 452 |
// Handle Pro features |
| 453 |
case 'easy-invoice-pro-item-library': |
| 454 |
if (easy_invoice_has_pro()) { |
| 455 |
// Use the Pro controller's displayMainPage method like other controllers |
| 456 |
if (class_exists('\EasyInvoicePro\Controllers\ItemLibraryController')) { |
| 457 |
$item_library_controller = new \EasyInvoicePro\Controllers\ItemLibraryController(); |
| 458 |
$item_library_controller->displayMainPage(); |
| 459 |
} |
| 460 |
} |
| 461 |
break; |
| 462 |
|
| 463 |
case 'easy-invoice-templates': |
| 464 |
if (easy_invoice_has_pro()) { |
| 465 |
// Use the Pro controller's displayMainPage method like other controllers |
| 466 |
if (class_exists('\EasyInvoicePro\Controllers\TemplateBuilderController')) { |
| 467 |
$template_builder_controller = new \EasyInvoicePro\Controllers\TemplateBuilderController(); |
| 468 |
$template_builder_controller->displayMainPage(); |
| 469 |
} |
| 470 |
} |
| 471 |
break; |
| 472 |
|
| 473 |
case 'easy-invoice-template-builder': |
| 474 |
if (easy_invoice_has_pro()) { |
| 475 |
// Use the Pro controller's displayMainPage method like other controllers |
| 476 |
if (class_exists('\EasyInvoicePro\Controllers\TemplateBuilderController')) { |
| 477 |
$template_builder_controller = new \EasyInvoicePro\Controllers\TemplateBuilderController(); |
| 478 |
$template_builder_controller->displayMainPage(); |
| 479 |
} |
| 480 |
} |
| 481 |
break; |
| 482 |
|
| 483 |
case PagesSlugs::CLIENT_VIEW: |
| 484 |
$this->client_controller->display(['page' => PagesSlugs::CLIENT_VIEW]); |
| 485 |
break; |
| 486 |
|
| 487 |
case PagesSlugs::REPORTS: |
| 488 |
$this->report_controller->display(['page' => PagesSlugs::REPORTS]); |
| 489 |
break; |
| 490 |
|
| 491 |
case PagesSlugs::SETTINGS: |
| 492 |
$this->settings_controller->display(['page' => PagesSlugs::SETTINGS]); |
| 493 |
break; |
| 494 |
|
| 495 |
case PagesSlugs::LICENSE: |
| 496 |
$this->displayLicensePage(); |
| 497 |
break; |
| 498 |
|
| 499 |
case PagesSlugs::EMAIL_SETTINGS: |
| 500 |
case PagesSlugs::EMAIL_SETTINGS_GENERAL: |
| 501 |
case PagesSlugs::EMAIL_SETTINGS_INVOICE: |
| 502 |
case PagesSlugs::EMAIL_SETTINGS_QUOTE: |
| 503 |
case PagesSlugs::EMAIL_SETTINGS_PAYMENT: |
| 504 |
$this->settings_controller->display(['page' => PagesSlugs::SETTINGS, 'subsection' => $page]); |
| 505 |
break; |
| 506 |
|
| 507 |
case 'easy-invoice-migration': |
| 508 |
include EASY_INVOICE_PLUGIN_DIR . 'includes/Migration/templates/migration-page.php'; |
| 509 |
break; |
| 510 |
|
| 511 |
case 'easy-invoice-free-vs-pro': |
| 512 |
include EASY_INVOICE_PLUGIN_DIR . 'templates/admin/free-vs-pro-page.php'; |
| 513 |
break; |
| 514 |
|
| 515 |
default: |
| 516 |
$this->dashboard_controller->display(['page' => PagesSlugs::DASHBOARD]); |
| 517 |
break; |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
/** |
| 522 |
* Set proper admin title to avoid WordPress core issues |
| 523 |
* |
| 524 |
* @param string $title The current admin title |
| 525 |
* @return string The modified admin title |
| 526 |
*/ |
| 527 |
public function setAdminTitle($title) { |
| 528 |
$current_page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
| 529 |
|
| 530 |
// Only modify titles for our plugin pages |
| 531 |
if (strpos($current_page, 'easy-invoice') === 0 || strpos($current_page, 'easy-quote') === 0) { |
| 532 |
$page_titles = [ |
| 533 |
'easy-invoice' => __('Dashboard', 'easy-invoice'), |
| 534 |
'easy-invoice-all' => __('All Invoices', 'easy-invoice'), |
| 535 |
'easy-invoice-builder' => __('Add New Invoice', 'easy-invoice'), |
| 536 |
'easy-invoice-preview' => __('Preview Invoice', 'easy-invoice'), |
| 537 |
'easy-quote-all' => __('All Quotes', 'easy-invoice'), |
| 538 |
'easy-invoice-quote-builder' => __('Add New Quote', 'easy-invoice'), |
| 539 |
'easy-quote-preview' => __('Preview Quote', 'easy-invoice'), |
| 540 |
'easy-invoice-payments' => __('Payments', 'easy-invoice'), |
| 541 |
'easy-invoice-payment-new' => __('Add New Payment', 'easy-invoice'), |
| 542 |
'easy-invoice-clients' => __('Clients', 'easy-invoice'), |
| 543 |
'easy-invoice-client-edit' => __('Edit Client', 'easy-invoice'), |
| 544 |
'easy-invoice-client-view' => __('View Client', 'easy-invoice'), |
| 545 |
'easy-invoice-reports' => __('Reports', 'easy-invoice'), |
| 546 |
'easy-invoice-settings' => __('Settings', 'easy-invoice'), |
| 547 |
'easy-invoice-email-settings' => __('Email Settings', 'easy-invoice'), |
| 548 |
'easy-invoice-migration' => __('Migration', 'easy-invoice'), |
| 549 |
'easy-invoice-free-vs-pro' => __('Free vs Pro', 'easy-invoice'), |
| 550 |
]; |
| 551 |
|
| 552 |
if (isset($page_titles[$current_page])) { |
| 553 |
return $page_titles[$current_page] . ' - ' . get_bloginfo('name'); |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
return $title; |
| 558 |
} |
| 559 |
|
| 560 |
/** |
| 561 |
* Body class for Easy Invoice full-width layout (used by hideAdminUi CSS). |
| 562 |
* |
| 563 |
* @param string $classes Space-separated classes. |
| 564 |
* @return string |
| 565 |
*/ |
| 566 |
public function adminBodyClass($classes) { |
| 567 |
$screen = get_current_screen(); |
| 568 |
if (!$screen || !isset($screen->id)) { |
| 569 |
return $classes; |
| 570 |
} |
| 571 |
if (strpos($screen->id, 'easy-invoice') !== false || strpos($screen->id, 'easy-quote') !== false) { |
| 572 |
$classes .= ' easy-invoice-admin-body'; |
| 573 |
} |
| 574 |
return $classes; |
| 575 |
} |
| 576 |
|
| 577 |
/** |
| 578 |
* Hide the WordPress admin UI for our custom pages |
| 579 |
*/ |
| 580 |
public function hideAdminUi() { |
| 581 |
$screen = get_current_screen(); |
| 582 |
if ($screen && property_exists($screen, 'id') && (strpos($screen->id, 'easy-invoice') !== false || strpos($screen->id, 'easy-quote') !== false)) { |
| 583 |
?> |
| 584 |
<style> |
| 585 |
#wpadminbar, |
| 586 |
#adminmenumain, |
| 587 |
#wpfooter { |
| 588 |
display: none !important; |
| 589 |
} |
| 590 |
#wpcontent { |
| 591 |
margin-left: 0 !important; |
| 592 |
padding: 0 !important; |
| 593 |
} |
| 594 |
.wrap { |
| 595 |
margin: 0 !important; |
| 596 |
padding: 0 !important; |
| 597 |
} |
| 598 |
/* |
| 599 |
* Admin bar is hidden but body.admin-bar often still gets top padding, |
| 600 |
* shifting #wpbody down while the fixed plugin sidebar stays at y=0 — header borders misalign. |
| 601 |
*/ |
| 602 |
body.easy-invoice-admin-body.admin-bar { |
| 603 |
padding-top: 0 !important; |
| 604 |
} |
| 605 |
body.easy-invoice-admin-body.admin-bar #wpbody, |
| 606 |
body.easy-invoice-admin-body.admin-bar #wpbody-content { |
| 607 |
padding-top: 0 !important; |
| 608 |
} |
| 609 |
</style> |
| 610 |
<?php |
| 611 |
} |
| 612 |
} |
| 613 |
} |
| 614 |
|