| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Admin meni class |
| 5 |
* |
| 6 |
* @package Timetics |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Timetics\Core\Admin; |
| 10 |
|
| 11 |
/** |
| 12 |
* Class Menu |
| 13 |
*/ |
| 14 |
class Menu |
| 15 |
{ |
| 16 |
|
| 17 |
use \Timetics\Utils\Singleton; |
| 18 |
|
| 19 |
/** |
| 20 |
* Initialize |
| 21 |
* |
| 22 |
* @return void |
| 23 |
*/ |
| 24 |
public function init() |
| 25 |
{ |
| 26 |
add_action('admin_menu', array($this, 'register_admin_menu')); |
| 27 |
|
| 28 |
// go pro link |
| 29 |
if (!class_exists('TimeticsPro')) { |
| 30 |
add_action('admin_menu', array($this, 'add_pro_admin_menu')); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
/** |
| 36 |
* Register admin menu |
| 37 |
* |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
|
| 41 |
public function register_admin_menu() |
| 42 |
{ |
| 43 |
global $submenu; |
| 44 |
$capability = 'manage_timetics'; |
| 45 |
$slug = 'timetics'; |
| 46 |
$url = 'admin.php?page=' . $slug . '#'; |
| 47 |
$menu_items = array( |
| 48 |
[ 'id' => 'overview', |
| 49 |
'title' => esc_html__('Overview', 'timetics'), |
| 50 |
'link' => '/', |
| 51 |
'capability' => $capability, |
| 52 |
'position' => 1, |
| 53 |
], |
| 54 |
[ |
| 55 |
'id' => 'meeting', |
| 56 |
'title' => esc_html__('Meetings', 'timetics'), |
| 57 |
'link' => '/meetings', |
| 58 |
'capability' => 'read_booking', |
| 59 |
'position' => 2, |
| 60 |
], |
| 61 |
[ |
| 62 |
'id' => 'staff', |
| 63 |
'title' => esc_html__('Staff Members', 'timetics'), |
| 64 |
'link' => '/staff', |
| 65 |
'capability' => 'edit_staff', |
| 66 |
'position' => 3, |
| 67 |
], |
| 68 |
|
| 69 |
[ |
| 70 |
'id' => 'booking', |
| 71 |
'title' => esc_html__('Bookings', 'timetics'), |
| 72 |
'link' => '/bookings', |
| 73 |
'capability' => 'read_booking', |
| 74 |
'position' => 4, |
| 75 |
], |
| 76 |
[ |
| 77 |
'id' => 'customer', |
| 78 |
'title' => esc_html__('Customers', 'timetics'), |
| 79 |
'link' => '/customers', |
| 80 |
'capability' => 'manage_options', |
| 81 |
'position' => 5, |
| 82 |
], |
| 83 |
[ |
| 84 |
'id' => 'settings', |
| 85 |
'title' => esc_html__('Settings', 'timetics'), |
| 86 |
'link' => '/settings', |
| 87 |
'capability' => 'manage_options', |
| 88 |
'position' => 6, |
| 89 |
], |
| 90 |
[ 'id' => 'my-profile', |
| 91 |
'title' => esc_html__('My Profile', 'timetics'), |
| 92 |
'link' => '/my-profile', |
| 93 |
'capability' => 'edit_profile', |
| 94 |
'position' => 7, |
| 95 |
], |
| 96 |
[ |
| 97 |
'id' => 'shortcode', |
| 98 |
'title' => esc_html__('Shortcodes', 'timetics'), |
| 99 |
'link' => '/shortcodes', |
| 100 |
'capability' => 'edit_profile', |
| 101 |
'position' => 8, |
| 102 |
], |
| 103 |
[ |
| 104 |
'id' => 'onboard', |
| 105 |
'title' => esc_html__('Setup Wizard', 'timetics'), |
| 106 |
'link' => '/onboard', |
| 107 |
'capability' => 'edit_profile', |
| 108 |
'position' => 9, |
| 109 |
], |
| 110 |
); |
| 111 |
|
| 112 |
add_menu_page( |
| 113 |
esc_html__('Timetics', 'timetics'), |
| 114 |
esc_html__('Timetics', 'timetics'), |
| 115 |
$capability, |
| 116 |
$slug, |
| 117 |
array($this, 'timetics_dashboard_view'), |
| 118 |
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTE0OCIgaGVpZ2h0PSIxMTQ4IiB2aWV3Qm94PSIwIDAgMTE0OCAxMTQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNODQ2Ljc1MyA5NzAuNTQ1QzgxNS41MDMgOTk1LjAzOCA3NzEuMTE4IDk4Mi40NjggNzUxLjgzNCA5NDcuNzY1QzczMi44NTYgOTEzLjYxMyA3NDUuNjI5IDg3MS4wNDMgNzc1LjE4MiA4NDUuNDgxQzg0OC4yNjkgNzgyLjI2MyA4OTMuMjcgNjkwLjcyMSA4OTMuMjcgNTkwLjE4MUM4OTMuMjcgNDA1LjI1NiA3NDAuNjY2IDI1Mi42OTMgNTU1LjY5MyAyNTIuNjkzQzQ1My42ODYgMjUyLjY5MyAzNTcuODUzIDI5OC45OCAyOTMuNDEgMzc2LjQyNkMyNjkuMjIyIDQwNS40OTUgMjI4LjE1OCA0MTguNDg2IDE5NC44NTYgNDAwLjU1OUMxNjEuNjYzIDM4Mi42OTEgMTQ4LjczIDM0MS4wMTQgMTcwLjg4IDMxMC41MTVDMjYwLjEwOCAxODcuNjUxIDQwMi42MzggMTE0IDU1NS42OTMgMTE0QzgxOS4yOCAxMTQgMTAzMiAzMjYuNjYzIDEwMzIgNTkwLjE4MUMxMDMyIDc0MS41MzUgOTYzLjM1MSA4NzkuMTY0IDg0Ni43NTMgOTcwLjU0NVoiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xODUuOTYyIDUyNi41MzFINjI0LjYwNFY5NjUuMDU3QzYyNC42MDQgMTAwMy4xMyA1OTMuNzI5IDEwMzQgNTU1LjY0MiAxMDM0QzUxNy41NTYgMTAzNCA0ODYuNjgxIDEwMDMuMTMgNDg2LjY4MSA5NjUuMDU3VjY2NC40MThIMTg1Ljk2MkMxNDcuODc1IDY2NC40MTggMTE3IDYzMy41NTEgMTE3IDU5NS40NzRDMTE3IDU1Ny4zOTggMTQ3Ljg3NSA1MjYuNTMxIDE4NS45NjIgNTI2LjUzMVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=", |
| 119 |
10 |
| 120 |
); |
| 121 |
|
| 122 |
$menu_items = apply_filters('timetics_menu', $menu_items); |
| 123 |
$position = array_column($menu_items, 'position'); |
| 124 |
|
| 125 |
array_multisort($position, SORT_ASC, $menu_items); |
| 126 |
|
| 127 |
foreach ($menu_items as $item) { |
| 128 |
$submenu[$slug][] = [$item['title'], $item['capability'], $url . $item['link']]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Admin dashboard view |
| 134 |
* |
| 135 |
* @return void |
| 136 |
*/ |
| 137 |
public function timetics_dashboard_view() |
| 138 |
{ |
| 139 |
?> |
| 140 |
<div class="wrap" id="time_tics_dashboard"> |
| 141 |
</div> |
| 142 |
<?php |
| 143 |
} |
| 144 |
|
| 145 |
// Add submenu page under "Settings" |
| 146 |
public function add_pro_admin_menu() |
| 147 |
{ |
| 148 |
add_submenu_page( |
| 149 |
'timetics', |
| 150 |
'Go Pro', |
| 151 |
'Go Pro', |
| 152 |
'edit_meeting', |
| 153 |
'https://arraytics.com/timetics', |
| 154 |
'', |
| 155 |
9, |
| 156 |
); |
| 157 |
} |
| 158 |
} |
| 159 |
|