| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Services\Menu; |
| 4 |
|
| 5 |
// phpcs:disable PSR1.Files.SideEffects |
| 6 |
if (!defined('ABSPATH')) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
use IvyForms\Services\API\IvyFormsAPI; |
| 11 |
use IvyForms\Services\Translations\BackendStrings; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class Menu |
| 15 |
*/ |
| 16 |
class MenuMapper |
| 17 |
{ |
| 18 |
/** |
| 19 |
* @return mixed[] |
| 20 |
*/ |
| 21 |
public function __invoke(): array |
| 22 |
{ |
| 23 |
$menus = |
| 24 |
[ |
| 25 |
// [ |
| 26 |
// 'parentSlug' => 'ivyforms', |
| 27 |
// 'pageTitle' => 'Dashboard', |
| 28 |
// 'menuTitle' => BackendStrings::getDashboardStrings()['dashboard'], |
| 29 |
// // TODO - Add IvyForms capability |
| 30 |
// 'capability' => 'read', |
| 31 |
// 'menuSlug' => 'ivyforms-dashboard', |
| 32 |
// ], |
| 33 |
[ |
| 34 |
'parentSlug' => 'ivyforms', |
| 35 |
'pageTitle' => 'All Forms', |
| 36 |
'menuTitle' => BackendStrings::getCommonStrings()['all_forms'], |
| 37 |
// TODO - Add IvyForms capability |
| 38 |
'capability' => 'read', |
| 39 |
'menuSlug' => 'ivyforms-forms', |
| 40 |
], |
| 41 |
[ |
| 42 |
'parentSlug' => 'ivyforms', |
| 43 |
'pageTitle' => 'New form', |
| 44 |
'menuTitle' => BackendStrings::getCommonStrings()['new_form'], |
| 45 |
// TODO - Add IvyForms capability |
| 46 |
'capability' => 'read', |
| 47 |
'menuSlug' => 'ivyforms-builder', |
| 48 |
], |
| 49 |
[ |
| 50 |
'parentSlug' => 'ivyforms', |
| 51 |
'pageTitle' => 'Entries', |
| 52 |
'menuTitle' => BackendStrings::getEntriesStrings()['entries'], |
| 53 |
// TODO - Add IvyForms capability |
| 54 |
'capability' => 'read', |
| 55 |
'menuSlug' => 'ivyforms-entries', |
| 56 |
], |
| 57 |
// // TODO Add Settings page |
| 58 |
[ |
| 59 |
'parentSlug' => 'ivyforms', |
| 60 |
'pageTitle' => 'Settings', |
| 61 |
'menuTitle' => BackendStrings::getCommonStrings()['settings'], |
| 62 |
// TODO - Add IvyForms capability |
| 63 |
'capability' => 'read', |
| 64 |
'menuSlug' => 'ivyforms-settings', |
| 65 |
], |
| 66 |
[ |
| 67 |
'parentSlug' => 'ivyforms', |
| 68 |
'pageTitle' => 'Integrations', |
| 69 |
'menuTitle' => BackendStrings::getIntegrationsStrings()['integrations'], |
| 70 |
// TODO - Add IvyForms capability |
| 71 |
'capability' => 'read', |
| 72 |
'menuSlug' => 'ivyforms-integrations', |
| 73 |
], |
| 74 |
]; |
| 75 |
|
| 76 |
// Add "Upgrade to PRO" menu only if Pro plugin is not installed/activated |
| 77 |
if (!IvyFormsAPI::isProPluginActive()) { |
| 78 |
$menus[] = [ |
| 79 |
'parentSlug' => 'ivyforms', |
| 80 |
'pageTitle' => 'Upgrade to PRO', |
| 81 |
// phpcs:ignore Generic.Files.LineLength.TooLong |
| 82 |
'menuTitle' => '<span class="ivyforms-upgrade-to-pro">' . __('Upgrade to PRO', 'ivyforms') . '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M3.30739 5.78346L5.09363 3.36669C6.24826 1.80449 6.82558 1.02339 7.3642 1.18846C7.90283 1.35352 7.90283 2.31153 7.90283 4.22757V4.40823C7.90283 5.0993 7.90283 5.44483 8.12364 5.66157L8.13533 5.6728C8.36091 5.88496 8.72054 5.88496 9.4398 5.88496C10.7341 5.88496 11.3813 5.88496 11.6 6.27751C11.6037 6.28401 11.6072 6.29056 11.6106 6.29716C11.8171 6.69579 11.4424 7.20277 10.6929 8.21673L8.90667 10.6335C7.75202 12.1957 7.1747 12.9768 6.63607 12.8117C6.09744 12.6466 6.09746 11.6886 6.09748 9.77256L6.09749 9.59198C6.0975 8.9009 6.0975 8.55536 5.87669 8.33861L5.865 8.32739C5.63942 8.11522 5.27979 8.11522 4.56052 8.11522C3.26618 8.11522 2.61901 8.11522 2.40029 7.72267C2.39666 7.71617 2.39314 7.70962 2.38973 7.70302C2.18325 7.3044 2.55796 6.79742 3.30739 5.78346Z" fill="white"/></svg></span>', |
| 83 |
'capability' => 'read', |
| 84 |
// phpcs:ignore Generic.Files.LineLength.TooLong |
| 85 |
'menuSlug' => 'https://ivyforms.com/pricing?utm_source=ivy-lite&utm_medium=lite-upgrade&utm_content=ivy&utm_campaign=ivy', |
| 86 |
'isExternal' => true, |
| 87 |
]; |
| 88 |
} |
| 89 |
|
| 90 |
return $menus; |
| 91 |
} |
| 92 |
} |
| 93 |
|