Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 778 |
|
0.00% |
0 / 9 |
CRAP | n/a |
0 / 0 |
|
| zeroBSCRM_menu_buildMenu | |
0.00% |
0 / 661 |
|
0.00% |
0 / 1 |
552 | |||
| zeroBSCRM_menu_applyWPMenu | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| zeroBSCRM_menu_applyTakeover | |
0.00% |
0 / 41 |
|
0.00% |
0 / 1 |
90 | |||
| zeroBSCRM_menu_securityGuard | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
132 | |||
| zeroBSCRM_menu_order | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |||
| zeroBSCRM_menu_order_sort | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
56 | |||
| zeroBSCRM_menu_add_toplevel | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
210 | |||
| zeroBSCRM_menu_add_sublevel | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
56 | |||
| zeroBSCRM_menus_removeWPSubMenu | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /* |
| 3 | * Jetpack CRM |
| 4 | * https://jetpackcrm.com |
| 5 | * V2.4+ |
| 6 | * |
| 7 | * Copyright 2020 Automattic |
| 8 | * |
| 9 | * Date: 05/02/2017 |
| 10 | */ |
| 11 | |
| 12 | // block access to this file |
| 13 | if ( ! defined( 'ZEROBSCRM_PATH' ) ) { |
| 14 | exit( 0 ); |
| 15 | } |
| 16 | |
| 17 | /* |
| 18 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 19 | ! |
| 20 | ! THIS FILE IS FOR WordPress Menu related changes - later to be unified into one .Menu file |
| 21 | ! |
| 22 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 23 | */ |
| 24 | |
| 25 | /* |
| 26 | When positioning menus, consider the following order: |
| 27 | |
| 28 | * 1-9: important menu items (e.g. dashboard, contacts, quotes, invoices) |
| 29 | * 10-49: good for semi-important modules/extensions (e.g. WooSync) |
| 30 | * 50-89: less-important menu items (e.g. segments, forms, tasks) |
| 31 | * 90+: config/settings/administrative stuff (e.g. Settings, Extensions, Modules, Feedback) |
| 32 | |
| 33 | */ |
| 34 | |
| 35 | /* |
| 36 | ====================================================== |
| 37 | v3 ZBS Menu Arr -> WP Admin Menu Associated Funcs |
| 38 | ====================================================== */ |
| 39 | |
| 40 | // This builds out our ZBS menu array() |
| 41 | // ... which ultimately forms the "default" zbs menu |
| 42 | // ... which the core then uses to inject what it needs to into wp admin menus :) |
| 43 | function zeroBSCRM_menu_buildMenu() { |
| 44 | |
| 45 | global $zbs; |
| 46 | |
| 47 | // Get the admin layout option 1 = Full, 2 = Slimline, 3 = CRM Only |
| 48 | $crm_menu_mode = zeroBSCRM_getSetting( 'menulayout' ); |
| 49 | |
| 50 | if ( ! isset( $crm_menu_mode ) || ! in_array( $crm_menu_mode, array( 1, 2, 3 ) ) ) { |
| 51 | $crm_menu_mode = ZBS_MENU_SLIM; // Defaults to slimline |
| 52 | } |
| 53 | |
| 54 | // Get other settings |
| 55 | |
| 56 | // b2b mode |
| 57 | $is_b2b_mode = zeroBSCRM_getSetting( 'companylevelcustomers' ) == 1; |
| 58 | |
| 59 | // other feats |
| 60 | $use_quotes = zeroBSCRM_getSetting( 'feat_quotes' ) == 1; |
| 61 | $use_invoices = zeroBSCRM_getSetting( 'feat_invs' ) == 1; |
| 62 | $use_transactions = zeroBSCRM_getSetting( 'feat_transactions' ) == 1; |
| 63 | $use_forms = zeroBSCRM_isExtensionInstalled( 'forms' ) == 1; // zeroBSCRM_getSetting('feat_forms'); |
| 64 | $use_calendar = zeroBSCRM_getSetting( 'feat_calendar' ) == 1; |
| 65 | |
| 66 | // Check if it has license to show the Support menu |
| 67 | $license = zeroBSCRM_getSetting( 'license_key' ); |
| 68 | $has_license = is_array( $license ) && ! empty( $license['key'] ); |
| 69 | $support_menu = $has_license ? 'jpcrm' : 'hidden'; |
| 70 | |
| 71 | // this is the "first build" function, so begin with this :) |
| 72 | $menu = array( |
| 73 | 'hidden' => array( |
| 74 | 'perms' => 'zbs_dash', |
| 75 | 'subitems' => array(), |
| 76 | ), |
| 77 | ); |
| 78 | |
| 79 | // =================================================== |
| 80 | // ======= Slimline Main Menu |
| 81 | // =================================================== |
| 82 | if ( $crm_menu_mode === ZBS_MENU_SLIM ) { |
| 83 | |
| 84 | // handle main menu position based on special cases |
| 85 | if ( is_plugin_active( 'jetpack/jetpack.php' ) ) { |
| 86 | // Check if it's in the context of WoA (Atomic infrastructure). |
| 87 | if ( class_exists( '\Automattic\Jetpack\Status\Host' ) && ( new \Automattic\Jetpack\Status\Host() )->is_woa_site() ) { |
| 88 | $menu_position = 52; |
| 89 | } else { |
| 90 | $menu_position = 4; |
| 91 | } |
| 92 | } else { |
| 93 | $menu_position = 2; |
| 94 | } |
| 95 | |
| 96 | // ZBS Slimline Main Menu (Top Level) |
| 97 | $menu['jpcrm'] = array( |
| 98 | 'ico' => 'dashicons-groups', |
| 99 | 'title' => 'Jetpack CRM', |
| 100 | 'url' => $zbs->slugs['dash'], |
| 101 | 'perms' => 'zbs_dash', |
| 102 | 'order' => 1, |
| 103 | 'wpposition' => $menu_position, |
| 104 | 'subitems' => array(), |
| 105 | 'callback' => 'zeroBSCRM_pages_dash', |
| 106 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_homedash' ), |
| 107 | ); |
| 108 | |
| 109 | /** |
| 110 | * Start slimline submenu items |
| 111 | */ |
| 112 | // Dash (sub) |
| 113 | $menu['jpcrm']['subitems']['dashboard'] = array( |
| 114 | 'title' => __( 'Dashboard', 'zero-bs-crm' ), |
| 115 | 'url' => $zbs->slugs['dash'], |
| 116 | 'perms' => 'zbs_dash', |
| 117 | 'order' => 1, |
| 118 | 'wpposition' => 1, |
| 119 | 'callback' => 'zeroBSCRM_pages_dash', |
| 120 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_homedash' ), |
| 121 | ); |
| 122 | |
| 123 | // Contacts (sub) |
| 124 | $menu['jpcrm']['subitems']['contacts'] = array( |
| 125 | 'title' => __( 'Contacts', 'zero-bs-crm' ), |
| 126 | 'url' => $zbs->slugs['managecontacts'], |
| 127 | 'perms' => 'admin_zerobs_view_customers', |
| 128 | 'order' => 2, |
| 129 | 'wpposition' => 2, |
| 130 | 'callback' => 'zeroBSCRM_render_customerslist_page', |
| 131 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 132 | ); |
| 133 | |
| 134 | if ( $is_b2b_mode ) { |
| 135 | // Companies (sub) |
| 136 | $menu['jpcrm']['subitems']['companies'] = array( |
| 137 | 'title' => jpcrm_label_company( true ), |
| 138 | 'url' => $zbs->slugs['managecompanies'], |
| 139 | 'perms' => 'admin_zerobs_view_customers', |
| 140 | 'order' => 2.1, |
| 141 | 'wpposition' => 2.1, |
| 142 | 'callback' => 'zeroBSCRM_render_companyslist_page', |
| 143 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | if ( $use_quotes ) { |
| 148 | |
| 149 | // Quotes (sub) |
| 150 | $menu['jpcrm']['subitems']['quotes'] = array( |
| 151 | 'title' => __( 'Quotes', 'zero-bs-crm' ), |
| 152 | 'url' => $zbs->slugs['managequotes'], |
| 153 | 'perms' => 'admin_zerobs_view_quotes', |
| 154 | 'order' => 3, |
| 155 | 'wpposition' => 3, |
| 156 | 'callback' => 'zeroBSCRM_render_quoteslist_page', |
| 157 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 158 | ); |
| 159 | |
| 160 | // Templates (sub) |
| 161 | $menu['jpcrm']['subitems']['quotetemplates'] = array( |
| 162 | 'title' => __( 'Quote Templates', 'zero-bs-crm' ), |
| 163 | 'url' => $zbs->slugs['quote-templates'], |
| 164 | 'perms' => 'admin_zerobs_quotes', |
| 165 | 'order' => 3.1, |
| 166 | 'wpposition' => 3.1, |
| 167 | 'callback' => 'zeroBSCRM_render_quotetemplateslist_page', |
| 168 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 169 | ); |
| 170 | |
| 171 | } |
| 172 | |
| 173 | if ( $use_invoices ) { |
| 174 | // Invoices (sub) |
| 175 | $menu['jpcrm']['subitems']['invoices'] = array( |
| 176 | 'title' => __( 'Invoices', 'zero-bs-crm' ), |
| 177 | 'url' => $zbs->slugs['manageinvoices'], |
| 178 | 'perms' => 'admin_zerobs_view_invoices', |
| 179 | 'order' => 4, |
| 180 | 'wpposition' => 4, |
| 181 | 'callback' => 'zeroBSCRM_render_invoiceslist_page', |
| 182 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 183 | ); |
| 184 | } |
| 185 | |
| 186 | if ( $use_transactions ) { |
| 187 | // Transactions (sub) |
| 188 | $menu['jpcrm']['subitems']['transactions'] = array( |
| 189 | 'title' => __( 'Transactions', 'zero-bs-crm' ), |
| 190 | 'url' => $zbs->slugs['managetransactions'], |
| 191 | 'perms' => 'admin_zerobs_view_transactions', |
| 192 | 'order' => 5, |
| 193 | 'wpposition' => 5, |
| 194 | 'callback' => 'zeroBSCRM_render_transactionslist_page', |
| 195 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 196 | ); |
| 197 | } |
| 198 | |
| 199 | if ( $use_calendar ) { |
| 200 | // Calendar (sub) |
| 201 | $menu['jpcrm']['subitems']['calendar'] = array( |
| 202 | 'title' => __( 'Task Scheduler', 'zero-bs-crm' ), |
| 203 | 'url' => $zbs->slugs['manage-tasks'], |
| 204 | 'perms' => 'admin_zerobs_view_events', |
| 205 | 'order' => 50, |
| 206 | 'wpposition' => 50, |
| 207 | 'callback' => 'zeroBSCRM_render_tasks_calendar_page', |
| 208 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_calendar_admin_styles' ), |
| 209 | ); |
| 210 | } |
| 211 | |
| 212 | // Segments (sub) |
| 213 | $menu['jpcrm']['subitems']['segments'] = array( |
| 214 | 'title' => __( 'Segments', 'zero-bs-crm' ), |
| 215 | 'url' => $zbs->slugs['segments'], |
| 216 | 'perms' => 'admin_zerobs_customers', |
| 217 | 'order' => 51, |
| 218 | 'wpposition' => 51, |
| 219 | 'callback' => 'zeroBSCRM_render_segmentslist_page', |
| 220 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 221 | ); |
| 222 | |
| 223 | if ( $use_forms ) { |
| 224 | // Forms (sub) |
| 225 | $menu['jpcrm']['subitems']['forms'] = array( |
| 226 | 'title' => __( 'Forms', 'zero-bs-crm' ), |
| 227 | 'url' => $zbs->slugs['manageformscrm'], |
| 228 | 'perms' => 'admin_zerobs_forms', |
| 229 | 'order' => 52, |
| 230 | 'wpposition' => 52, |
| 231 | 'callback' => 'zeroBSCRM_render_formslist_page', |
| 232 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 233 | ); |
| 234 | } |
| 235 | |
| 236 | $menu['jpcrm']['subitems']['modules'] = array( |
| 237 | 'title' => '<span>' . __( 'Core Modules', 'zero-bs-crm' ) . '</span>', |
| 238 | 'url' => $zbs->slugs['modules'], |
| 239 | 'perms' => 'admin_zerobs_customers', |
| 240 | 'order' => 97, |
| 241 | 'wpposition' => 97, |
| 242 | 'callback' => 'jpcrm_pages_modules', |
| 243 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_extension_admin_styles', 'zeroBSCRM_settingspage_admin_styles' ), |
| 244 | ); |
| 245 | |
| 246 | ##WLREMOVE |
| 247 | // Install Extensions (sub) |
| 248 | if ( current_user_can( 'manage_options' ) ) { |
| 249 | $menu['jpcrm']['subitems']['installext'] = array( |
| 250 | 'title' => __( 'Extensions', 'zero-bs-crm' ), |
| 251 | 'url' => $zbs->slugs['extensions'], |
| 252 | 'perms' => 'admin_zerobs_customers', |
| 253 | 'order' => 98, |
| 254 | 'wpposition' => 98, |
| 255 | 'callback' => 'zeroBSCRM_pages_extensions', |
| 256 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_extension_admin_styles', 'zeroBSCRM_settingspage_admin_styles' ), |
| 257 | ); |
| 258 | } |
| 259 | ##/WLREMOVE |
| 260 | |
| 261 | // System Status (sub) |
| 262 | $menu['jpcrm']['subitems']['systemstatus'] = array( |
| 263 | 'title' => __( 'System Assistant', 'zero-bs-crm' ), |
| 264 | 'url' => $zbs->slugs['systemstatus'], |
| 265 | 'perms' => 'admin_zerobs_manage_options', |
| 266 | 'order' => 99, |
| 267 | 'wpposition' => 99, |
| 268 | 'callback' => 'zeroBSCRM_pages_systemstatus', |
| 269 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'jpcrm_admin_scripts_systems_page' ), |
| 270 | ); |
| 271 | |
| 272 | // Settings (sub) |
| 273 | $menu['jpcrm']['subitems']['settings'] = array( |
| 274 | 'title' => __( 'CRM Settings', 'zero-bs-crm' ), |
| 275 | 'url' => $zbs->slugs['settings'], |
| 276 | 'perms' => 'admin_zerobs_manage_options', |
| 277 | 'order' => 100, |
| 278 | 'wpposition' => 100, |
| 279 | 'callback' => 'zeroBSCRM_pages_settings', |
| 280 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_settingspage_admin_styles' ), |
| 281 | ); |
| 282 | |
| 283 | ##WLREMOVE |
| 284 | |
| 285 | // Feedback (sub) |
| 286 | $menu['jpcrm']['subitems']['crmresources'] = array( |
| 287 | 'title' => '<span style="color: #64ca43;">' . __( 'Resources', 'zero-bs-crm' ) . '</span>', |
| 288 | 'url' => $zbs->slugs['crmresources'], |
| 289 | 'perms' => 'admin_zerobs_manage_options', |
| 290 | 'order' => 101, |
| 291 | 'wpposition' => 101, |
| 292 | 'callback' => 'zeroBSCRM_pages_crmresources', |
| 293 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'jpcrm_crm_resources_page_styles_scripts' ), |
| 294 | ); |
| 295 | |
| 296 | $menu[ $support_menu ]['subitems']['support'] = array( |
| 297 | 'title' => '<span>' . __( 'Support', 'zero-bs-crm' ) . '</span>', |
| 298 | 'url' => $zbs->slugs['support'], |
| 299 | 'perms' => 'admin_zerobs_manage_options', |
| 300 | 'order' => 102, |
| 301 | 'wpposition' => 102, |
| 302 | 'callback' => 'jpcrm_pages_support', |
| 303 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'jpcrm_support_page_styles_scripts' ), |
| 304 | ); |
| 305 | |
| 306 | ##/WLREMOVE |
| 307 | |
| 308 | } |
| 309 | /** |
| 310 | * End slimline submenu items |
| 311 | */ |
| 312 | |
| 313 | // =================================================== |
| 314 | // ======= / Slimline Main Menu |
| 315 | // =================================================== |
| 316 | |
| 317 | // =================================================== |
| 318 | // ======= Non-slimline menus |
| 319 | // =================================================== |
| 320 | else { // $crm_menu_mode !== ZBS_MENU_SLIM |
| 321 | |
| 322 | // Jetpack CRM (Top Level) |
| 323 | $menu['jpcrm'] = array( |
| 324 | 'ico' => 'dashicons-groups', |
| 325 | 'title' => __( 'Jetpack CRM', 'zero-bs-crm' ), |
| 326 | 'url' => $zbs->slugs['dash'], |
| 327 | 'perms' => 'zbs_dash', |
| 328 | 'order' => 1, |
| 329 | 'wpposition' => 2, |
| 330 | 'subitems' => array(), |
| 331 | 'callback' => 'zeroBSCRM_pages_dash', |
| 332 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_homedash' ), |
| 333 | ); |
| 334 | |
| 335 | /** |
| 336 | * Start Jetpack CRM submenu items |
| 337 | */ |
| 338 | // Dash (sub) |
| 339 | $menu['jpcrm']['subitems']['dashboard'] = array( |
| 340 | 'title' => __( 'Dashboard', 'zero-bs-crm' ), |
| 341 | 'url' => $zbs->slugs['dash'], |
| 342 | 'perms' => 'zbs_dash', |
| 343 | 'order' => 1, |
| 344 | 'wpposition' => 1, |
| 345 | 'callback' => 'zeroBSCRM_pages_dash', |
| 346 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_homedash' ), |
| 347 | ); |
| 348 | |
| 349 | // Core modules (sub) |
| 350 | $menu['jpcrm']['subitems']['modules'] = array( |
| 351 | 'title' => '<span>' . __( 'Core Modules', 'zero-bs-crm' ) . '</span>', |
| 352 | 'url' => $zbs->slugs['modules'], |
| 353 | 'perms' => 'admin_zerobs_customers', |
| 354 | 'order' => 97, |
| 355 | 'wpposition' => 97, |
| 356 | 'callback' => 'jpcrm_pages_modules', |
| 357 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_extension_admin_styles', 'zeroBSCRM_settingspage_admin_styles' ), |
| 358 | ); |
| 359 | |
| 360 | ##WLREMOVE |
| 361 | // Extensions (sub) |
| 362 | if ( current_user_can( 'manage_options' ) ) { |
| 363 | $menu['jpcrm']['subitems']['installext'] = array( |
| 364 | 'title' => __( 'Extensions', 'zero-bs-crm' ), |
| 365 | 'url' => $zbs->slugs['extensions'], |
| 366 | 'perms' => 'admin_zerobs_customers', |
| 367 | 'order' => 98, |
| 368 | 'wpposition' => 98, |
| 369 | 'callback' => 'zeroBSCRM_pages_extensions', |
| 370 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_extension_admin_styles', 'zeroBSCRM_settingspage_admin_styles' ), |
| 371 | ); |
| 372 | } |
| 373 | ##/WLREMOVE |
| 374 | |
| 375 | // System Status (sub) |
| 376 | $menu['jpcrm']['subitems']['systemstatus'] = array( |
| 377 | 'title' => __( 'System Assistant', 'zero-bs-crm' ), |
| 378 | 'url' => $zbs->slugs['systemstatus'], |
| 379 | 'perms' => 'admin_zerobs_manage_options', |
| 380 | 'order' => 99, |
| 381 | 'wpposition' => 99, |
| 382 | 'callback' => 'zeroBSCRM_pages_systemstatus', |
| 383 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'jpcrm_admin_scripts_systems_page' ), |
| 384 | ); |
| 385 | |
| 386 | // Settings (sub) |
| 387 | $menu['jpcrm']['subitems']['settings'] = array( |
| 388 | 'title' => __( 'CRM Settings', 'zero-bs-crm' ), |
| 389 | 'url' => $zbs->slugs['settings'], |
| 390 | 'perms' => 'admin_zerobs_manage_options', |
| 391 | 'order' => 100, |
| 392 | 'wpposition' => 100, |
| 393 | 'callback' => 'zeroBSCRM_pages_settings', |
| 394 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_settingspage_admin_styles' ), |
| 395 | ); |
| 396 | |
| 397 | ##WLREMOVE |
| 398 | // Resources (sub) |
| 399 | $menu['jpcrm']['subitems']['crmresources'] = array( |
| 400 | 'title' => '<span style="color: #64ca43;">' . __( 'Resources', 'zero-bs-crm' ) . '</span>', |
| 401 | 'url' => $zbs->slugs['crmresources'], |
| 402 | 'perms' => 'admin_zerobs_manage_options', |
| 403 | 'order' => 101, |
| 404 | 'wpposition' => 101, |
| 405 | 'callback' => 'zeroBSCRM_pages_crmresources', |
| 406 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'jpcrm_crm_resources_page_styles_scripts' ), |
| 407 | ); |
| 408 | |
| 409 | $menu[ $support_menu ]['subitems']['support'] = array( |
| 410 | 'title' => '<span>' . __( 'Support', 'zero-bs-crm' ) . '</span>', |
| 411 | 'url' => $zbs->slugs['support'], |
| 412 | 'perms' => 'admin_zerobs_manage_options', |
| 413 | 'order' => 102, |
| 414 | 'wpposition' => 102, |
| 415 | 'callback' => 'jpcrm_pages_support', |
| 416 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'jpcrm_support_page_styles_scripts' ), |
| 417 | ); |
| 418 | ##/WLREMOVE |
| 419 | /** |
| 420 | * End Jetpack CRM submenu items |
| 421 | */ |
| 422 | |
| 423 | // Contacts (Top Level) |
| 424 | $menu['contacts'] = array( |
| 425 | 'ico' => 'dashicons-admin-users', |
| 426 | 'title' => __( 'Contacts', 'zero-bs-crm' ), |
| 427 | 'url' => $zbs->slugs['managecontacts'], |
| 428 | 'perms' => 'admin_zerobs_view_customers', |
| 429 | 'order' => 25, |
| 430 | 'wpposition' => 25, |
| 431 | 'subitems' => array(), |
| 432 | 'callback' => 'zeroBSCRM_render_customerslist_page', |
| 433 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 434 | ); |
| 435 | |
| 436 | /** |
| 437 | * Start contact submenu items |
| 438 | */ |
| 439 | // Tags (sub) |
| 440 | $menu['contacts']['subitems']['tags'] = array( |
| 441 | 'title' => __( 'Contact Tags', 'zero-bs-crm' ), |
| 442 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=contact', |
| 443 | 'perms' => 'admin_zerobs_customers', |
| 444 | 'order' => 1, |
| 445 | 'wpposition' => 1, |
| 446 | 'callback' => '', // not used...this is just a 'link' |
| 447 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 448 | ); |
| 449 | |
| 450 | // Segments (sub) |
| 451 | $menu['contacts']['subitems']['segments'] = array( |
| 452 | 'title' => __( 'Segments', 'zero-bs-crm' ), |
| 453 | 'url' => $zbs->slugs['segments'], |
| 454 | 'perms' => 'admin_zerobs_customers', |
| 455 | 'order' => 2, |
| 456 | 'wpposition' => 2, |
| 457 | 'callback' => 'zeroBSCRM_render_segmentslist_page', |
| 458 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 459 | ); |
| 460 | |
| 461 | // Export Tools (sub) |
| 462 | $menu['contacts']['subitems']['export'] = array( |
| 463 | 'title' => __( 'Export', 'zero-bs-crm' ), |
| 464 | 'url' => $zbs->slugs['export-tools'], |
| 465 | 'perms' => 'admin_zerobs_customers', |
| 466 | 'order' => 3, |
| 467 | 'wpposition' => 3, |
| 468 | 'callback' => 'zeroBSCRM_page_exportRecords', |
| 469 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_exportTools' ), |
| 470 | ); |
| 471 | |
| 472 | // Add New (sub) |
| 473 | $menu['contacts']['subitems']['addnew'] = array( |
| 474 | 'title' => __( 'Add New Contact', 'zero-bs-crm' ), |
| 475 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=contact', |
| 476 | 'perms' => 'admin_zerobs_customers', |
| 477 | 'order' => 99, |
| 478 | 'wpposition' => 99, |
| 479 | 'callback' => '', // not used...this is just a 'link' |
| 480 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 481 | ); |
| 482 | |
| 483 | /** |
| 484 | * End contact submenu items |
| 485 | */ |
| 486 | |
| 487 | if ( $is_b2b_mode ) { |
| 488 | |
| 489 | // Companies (Top Level) |
| 490 | $menu['companies'] = array( |
| 491 | 'ico' => 'dashicons-store', |
| 492 | 'title' => jpcrm_label_company( true ), |
| 493 | 'url' => $zbs->slugs['managecompanies'], |
| 494 | 'perms' => 'admin_zerobs_view_customers', |
| 495 | 'order' => 26, |
| 496 | 'wpposition' => 26, |
| 497 | 'subitems' => array(), |
| 498 | 'callback' => 'zeroBSCRM_render_companyslist_page', |
| 499 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 500 | ); |
| 501 | |
| 502 | /** |
| 503 | * Start company submenu items |
| 504 | */ |
| 505 | // Tags (sub) |
| 506 | $menu['companies']['subitems']['tags'] = array( |
| 507 | 'title' => jpcrm_label_company() . ' ' . __( 'Tags', 'zero-bs-crm' ), |
| 508 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=company', |
| 509 | 'perms' => 'admin_zerobs_customers', |
| 510 | 'order' => 1, |
| 511 | 'wpposition' => 1, |
| 512 | 'callback' => '', |
| 513 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 514 | ); |
| 515 | |
| 516 | // Add New (sub) |
| 517 | $menu['companies']['subitems']['addnew'] = array( |
| 518 | 'title' => __( 'Add New', 'zero-bs-crm' ) . ' ' . jpcrm_label_company(), |
| 519 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=company', |
| 520 | 'perms' => 'admin_zerobs_customers', |
| 521 | 'order' => 99, |
| 522 | 'wpposition' => 99, |
| 523 | 'callback' => '', // not used? this is just a 'link'? |
| 524 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 525 | ); |
| 526 | |
| 527 | /** |
| 528 | * End company submenu items |
| 529 | */ |
| 530 | |
| 531 | } |
| 532 | |
| 533 | if ( $use_quotes ) { |
| 534 | |
| 535 | // Quotes (Top Level) |
| 536 | $menu['quotes'] = array( |
| 537 | 'ico' => 'dashicons-clipboard', |
| 538 | 'title' => __( 'Quotes', 'zero-bs-crm' ), |
| 539 | 'url' => $zbs->slugs['managequotes'], |
| 540 | 'perms' => 'admin_zerobs_view_quotes', |
| 541 | 'order' => 27, |
| 542 | 'wpposition' => 27, |
| 543 | 'subitems' => array(), |
| 544 | 'callback' => 'zeroBSCRM_render_quoteslist_page', |
| 545 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 546 | ); |
| 547 | |
| 548 | /** |
| 549 | * Start quotes submenu items |
| 550 | */ |
| 551 | // Tags (sub) |
| 552 | $menu['quotes']['subitems']['tags'] = array( |
| 553 | 'title' => __( 'Quote Tags', 'zero-bs-crm' ), |
| 554 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=quote', |
| 555 | 'perms' => 'admin_zerobs_quotes', |
| 556 | 'order' => 1, |
| 557 | 'wpposition' => 1, |
| 558 | 'callback' => '', |
| 559 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 560 | ); |
| 561 | |
| 562 | // Templates (sub) |
| 563 | $menu['quotes']['subitems']['templates'] = array( |
| 564 | 'title' => __( 'Quote Templates', 'zero-bs-crm' ), |
| 565 | 'url' => $zbs->slugs['quote-templates'], |
| 566 | 'perms' => 'admin_zerobs_quotes', |
| 567 | 'order' => 2, |
| 568 | 'wpposition' => 2, |
| 569 | 'callback' => 'zeroBSCRM_render_quotetemplateslist_page', |
| 570 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 571 | ); |
| 572 | |
| 573 | // Add New (sub) |
| 574 | $menu['quotes']['subitems']['addnew'] = array( |
| 575 | 'title' => __( 'Add New Quote', 'zero-bs-crm' ), |
| 576 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=quote', |
| 577 | 'perms' => 'admin_zerobs_quotes', |
| 578 | 'order' => 99, |
| 579 | 'wpposition' => 99, |
| 580 | 'callback' => '', // not used? this is just a 'link'? |
| 581 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 582 | ); |
| 583 | /** |
| 584 | * End quotes submenu items |
| 585 | */ |
| 586 | |
| 587 | } |
| 588 | |
| 589 | if ( $use_invoices ) { |
| 590 | |
| 591 | // Invoices (Top Level) |
| 592 | $menu['invoices'] = array( |
| 593 | 'ico' => 'dashicons-media-text', |
| 594 | 'title' => __( 'Invoices', 'zero-bs-crm' ), |
| 595 | 'url' => $zbs->slugs['manageinvoices'], |
| 596 | 'perms' => 'admin_zerobs_view_invoices', |
| 597 | 'order' => 28, |
| 598 | 'wpposition' => 28, |
| 599 | 'subitems' => array(), |
| 600 | 'callback' => 'zeroBSCRM_render_invoiceslist_page', |
| 601 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), // zeroBSCRM_scriptStyles_admin_invoiceBuilder |
| 602 | ); |
| 603 | |
| 604 | /** |
| 605 | * Start invoices submenu items |
| 606 | */ |
| 607 | // Tags (sub) |
| 608 | $menu['invoices']['subitems']['tags'] = array( |
| 609 | 'title' => __( 'Invoice Tags', 'zero-bs-crm' ), |
| 610 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=invoice', |
| 611 | 'perms' => 'admin_zerobs_view_invoices', |
| 612 | 'order' => 1, |
| 613 | 'wpposition' => 1, |
| 614 | 'callback' => '', |
| 615 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 616 | ); |
| 617 | |
| 618 | // Add New (sub) |
| 619 | $menu['invoices']['subitems']['addnew'] = array( |
| 620 | 'title' => __( 'Add New Invoice', 'zero-bs-crm' ), |
| 621 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=invoice', |
| 622 | 'perms' => 'admin_zerobs_view_invoices', |
| 623 | 'order' => 99, |
| 624 | 'wpposition' => 99, |
| 625 | 'callback' => '', // not used? this is just a 'link'? |
| 626 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_scriptStyles_admin_invoiceBuilder' ), |
| 627 | ); |
| 628 | |
| 629 | /** |
| 630 | * End invoices submenu items |
| 631 | */ |
| 632 | |
| 633 | } |
| 634 | |
| 635 | if ( $use_transactions ) { |
| 636 | |
| 637 | // Transactions (Top Level) |
| 638 | $menu['transactions'] = array( |
| 639 | 'ico' => 'dashicons-cart', |
| 640 | 'title' => __( 'Transactions', 'zero-bs-crm' ), |
| 641 | 'url' => $zbs->slugs['managetransactions'], |
| 642 | 'perms' => 'admin_zerobs_view_transactions', |
| 643 | 'order' => 29, |
| 644 | 'wpposition' => 29, |
| 645 | 'subitems' => array(), |
| 646 | 'callback' => 'zeroBSCRM_render_transactionslist_page', |
| 647 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 648 | ); |
| 649 | |
| 650 | /** |
| 651 | * Start transactions submenu items |
| 652 | */ |
| 653 | // Tags (sub) |
| 654 | $menu['transactions']['subitems']['tags'] = array( |
| 655 | 'title' => __( 'Transaction Tags', 'zero-bs-crm' ), |
| 656 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=transaction', |
| 657 | 'perms' => 'admin_zerobs_view_transactions', |
| 658 | 'order' => 1, |
| 659 | 'wpposition' => 1, |
| 660 | 'callback' => '', |
| 661 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 662 | ); |
| 663 | |
| 664 | // Add New (sub) |
| 665 | $menu['transactions']['subitems']['addnew'] = array( |
| 666 | 'title' => __( 'Add New Transaction', 'zero-bs-crm' ), |
| 667 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=transaction', |
| 668 | 'perms' => 'admin_zerobs_view_transactions', |
| 669 | 'order' => 99, |
| 670 | 'wpposition' => 99, |
| 671 | 'callback' => '', // not used? this is just a 'link'? |
| 672 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 673 | ); |
| 674 | |
| 675 | /** |
| 676 | * End transactions submenu items |
| 677 | */ |
| 678 | |
| 679 | } |
| 680 | |
| 681 | if ( $use_calendar ) { |
| 682 | |
| 683 | // Task Scheduler (Top Level) |
| 684 | $menu['calendar'] = array( |
| 685 | 'ico' => 'dashicons-calendar-alt', |
| 686 | 'title' => __( 'Task Scheduler', 'zero-bs-crm' ), |
| 687 | 'url' => $zbs->slugs['manage-tasks'], |
| 688 | 'perms' => 'admin_zerobs_view_events', |
| 689 | 'order' => 50, |
| 690 | 'wpposition' => 50, |
| 691 | 'subitems' => array(), |
| 692 | 'callback' => 'zeroBSCRM_render_tasks_calendar_page', |
| 693 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_calendar_admin_styles' ), |
| 694 | ); |
| 695 | |
| 696 | /** |
| 697 | * Start tasks submenu items |
| 698 | */ |
| 699 | // Listview (sub) |
| 700 | $menu['calendar']['subitems']['list'] = array( |
| 701 | 'title' => __( 'Task List', 'zero-bs-crm' ), |
| 702 | 'url' => $zbs->slugs['manage-tasks-list'], |
| 703 | 'perms' => 'admin_zerobs_view_events', |
| 704 | 'order' => 1, |
| 705 | 'wpposition' => 1, |
| 706 | 'callback' => 'zeroBSCRM_render_tasks_list_page', |
| 707 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 708 | ); |
| 709 | |
| 710 | // Tags (sub) |
| 711 | $menu['calendar']['subitems']['tags'] = array( |
| 712 | 'title' => __( 'Task Tags', 'zero-bs-crm' ), |
| 713 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=event', |
| 714 | 'perms' => 'admin_zerobs_view_events', |
| 715 | 'order' => 2, |
| 716 | 'wpposition' => 2, |
| 717 | 'callback' => '', |
| 718 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 719 | ); |
| 720 | |
| 721 | // Add New (sub) |
| 722 | $menu['calendar']['subitems']['addnew'] = array( |
| 723 | 'title' => __( 'Add New Task', 'zero-bs-crm' ), |
| 724 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=event', |
| 725 | 'perms' => 'admin_zerobs_events', |
| 726 | 'order' => 99, |
| 727 | 'wpposition' => 99, |
| 728 | 'callback' => '', // not used? this is just a 'link'? |
| 729 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_calendar_admin_styles' ), |
| 730 | ); |
| 731 | |
| 732 | /** |
| 733 | * End tasks submenu items |
| 734 | */ |
| 735 | } |
| 736 | |
| 737 | if ( $use_forms ) { |
| 738 | |
| 739 | // Forms (Top Level) |
| 740 | $menu['forms'] = array( |
| 741 | 'ico' => 'dashicons-welcome-widgets-menus', |
| 742 | 'title' => __( 'Forms', 'zero-bs-crm' ), |
| 743 | 'url' => $zbs->slugs['manageformscrm'], |
| 744 | 'perms' => 'admin_zerobs_forms', |
| 745 | 'order' => 51, |
| 746 | 'wpposition' => 51, |
| 747 | 'subitems' => array(), |
| 748 | 'callback' => 'zeroBSCRM_render_formslist_page', |
| 749 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 750 | ); |
| 751 | |
| 752 | // Add New (sub) |
| 753 | $menu['forms']['subitems']['addnew'] = array( |
| 754 | 'title' => __( 'Add New Form', 'zero-bs-crm' ), |
| 755 | 'url' => 'admin.php?page=' . $zbs->slugs['addedit'] . '&action=edit&zbstype=form', |
| 756 | 'perms' => 'admin_zerobs_forms', |
| 757 | 'order' => 99, |
| 758 | 'wpposition' => 99, |
| 759 | 'callback' => '', // not used? this is just a 'link'? |
| 760 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_scriptStyles_admin_formBuilder' ), |
| 761 | ); |
| 762 | |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | // =================================================== |
| 767 | // ======= / Non-slimline menus |
| 768 | // =================================================== |
| 769 | |
| 770 | // =================================================== |
| 771 | // ======= Hidden |
| 772 | // =================================================== |
| 773 | |
| 774 | // Welcome to CRM (sub) |
| 775 | $menu['hidden']['subitems']['welcome'] = array( |
| 776 | 'title' => __( 'Welcome', 'zero-bs-crm' ), |
| 777 | 'url' => $zbs->slugs['home'], |
| 778 | 'perms' => 'admin_zerobs_manage_options', |
| 779 | 'order' => 1, |
| 780 | 'wpposition' => 1, |
| 781 | 'callback' => 'zeroBSCRM_pages_home', |
| 782 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_intro_admin_styles' ), |
| 783 | ); |
| 784 | |
| 785 | // Data Tools (sub) |
| 786 | $menu['hidden']['subitems']['datatools'] = array( |
| 787 | 'title' => __( 'Data Tools', 'zero-bs-crm' ), |
| 788 | 'url' => $zbs->slugs['datatools'], |
| 789 | 'perms' => 'admin_zerobs_manage_options', |
| 790 | 'order' => 1, |
| 791 | 'wpposition' => 1, |
| 792 | 'callback' => 'zeroBSCRM_pages_datatools', |
| 793 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 794 | ); |
| 795 | |
| 796 | // Add/Edit (hidden) |
| 797 | $menu['hidden']['subitems']['addedit'] = array( |
| 798 | 'title' => __( 'Add New', 'zero-bs-crm' ), |
| 799 | 'url' => $zbs->slugs['addedit'], |
| 800 | 'perms' => 'admin_zerobs_customers', |
| 801 | 'order' => 1, |
| 802 | 'wpposition' => 1, |
| 803 | 'callback' => 'zeroBSCRM_pages_admin_addedit', |
| 804 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_editview', 'zeroBSCRM_load_libs_js_momentdatepicker' ), |
| 805 | ); |
| 806 | |
| 807 | // File Edit (hidden) |
| 808 | $menu['hidden']['subitems']['fileedit'] = array( |
| 809 | 'title' => __( 'Edit File', 'zero-bs-crm' ), |
| 810 | 'url' => $zbs->slugs['editfile'], |
| 811 | 'perms' => 'admin_zerobs_customers', |
| 812 | 'order' => 1, |
| 813 | 'wpposition' => 1, |
| 814 | 'callback' => 'zeroBSCRM_pages_add_or_edit_file', |
| 815 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 816 | ); |
| 817 | $menu['hidden']['subitems']['fileaddnew'] = array( |
| 818 | 'title' => __( 'New File', 'zero-bs-crm' ), |
| 819 | 'url' => $zbs->slugs['addnewfile'], |
| 820 | 'perms' => 'admin_zerobs_customers', |
| 821 | 'order' => 1, |
| 822 | 'wpposition' => 1, |
| 823 | 'callback' => 'zeroBSCRM_pages_add_or_edit_file', |
| 824 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 825 | ); |
| 826 | |
| 827 | // Tag Manager (hidden) |
| 828 | $menu['hidden']['subitems']['tagmanager'] = array( |
| 829 | 'title' => __( 'Tags', 'zero-bs-crm' ), |
| 830 | 'url' => $zbs->slugs['tagmanager'], |
| 831 | 'perms' => 'admin_zerobs_customers', |
| 832 | 'order' => 1, |
| 833 | 'wpposition' => 1, |
| 834 | 'callback' => 'zeroBSCRM_pages_admin_tags', |
| 835 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_editview' ), |
| 836 | ); |
| 837 | |
| 838 | // Export Tools (hidden) |
| 839 | $menu['hidden']['subitems']['exporttools'] = array( |
| 840 | 'title' => __( 'Export Tools', 'zero-bs-crm' ), |
| 841 | 'url' => $zbs->slugs['export-tools'], |
| 842 | 'perms' => 'admin_zerobs_manage_options', |
| 843 | 'order' => 1, |
| 844 | 'wpposition' => 1, |
| 845 | 'callback' => 'zeroBSCRM_page_exportRecords', |
| 846 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_exportTools' ), |
| 847 | ); |
| 848 | |
| 849 | // Notifications (hidden) |
| 850 | $menu['hidden']['subitems']['notifications'] = array( |
| 851 | 'title' => __( 'Notifications', 'zero-bs-crm' ), |
| 852 | 'url' => $zbs->slugs['notifications'], |
| 853 | 'perms' => 'admin_zerobs_notifications', |
| 854 | 'order' => 1, |
| 855 | 'wpposition' => 1, |
| 856 | 'callback' => 'zeroBSCRM_pages_admin_notifications', |
| 857 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 858 | ); |
| 859 | |
| 860 | // Team (hidden) |
| 861 | $menu['hidden']['subitems']['team'] = array( |
| 862 | 'title' => __( 'Team', 'zero-bs-crm' ), |
| 863 | 'url' => $zbs->slugs['team'], |
| 864 | 'perms' => 'manage_options', |
| 865 | 'order' => 1, |
| 866 | 'wpposition' => 1, |
| 867 | 'callback' => 'zeroBSCRM_pages_admin_team', |
| 868 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 869 | ); |
| 870 | |
| 871 | // Send Email (hidden) |
| 872 | $menu['hidden']['subitems']['sendemail'] = array( |
| 873 | 'title' => __( 'Send Email', 'zero-bs-crm' ), |
| 874 | 'url' => $zbs->slugs['sendmail'], |
| 875 | 'perms' => 'admin_zerobs_customers', |
| 876 | 'order' => 1, |
| 877 | 'wpposition' => 1, |
| 878 | 'callback' => 'zeroBSCRM_pages_emailsend', |
| 879 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_email_styles' ), |
| 880 | ); |
| 881 | |
| 882 | // Emails (hidden) |
| 883 | $menu['hidden']['subitems']['emails'] = array( |
| 884 | 'title' => __( 'Emails', 'zero-bs-crm' ), |
| 885 | 'url' => $zbs->slugs['emails'], |
| 886 | 'perms' => 'admin_zerobs_sendemails_contacts', |
| 887 | 'order' => 1, |
| 888 | 'wpposition' => 1, |
| 889 | 'callback' => 'zeroBSCRM_pages_emailbox', |
| 890 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_email_styles' ), |
| 891 | ); |
| 892 | |
| 893 | // Email Templates (hidden) |
| 894 | $menu['hidden']['subitems']['emailtemplates'] = array( |
| 895 | 'title' => __( 'Email Templates', 'zero-bs-crm' ), |
| 896 | 'url' => $zbs->slugs['email-templates'], |
| 897 | 'perms' => 'admin_zerobs_manage_options', |
| 898 | 'order' => 1, |
| 899 | 'wpposition' => 1, |
| 900 | 'callback' => 'zeroBSCRM_pages_admin_system_emails', |
| 901 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 902 | ); |
| 903 | |
| 904 | // Deactivation Error (hidden) |
| 905 | $menu['hidden']['subitems']['deactivationerr'] = array( |
| 906 | 'title' => __( 'Deactivation error', 'zero-bs-crm' ), |
| 907 | 'url' => $zbs->slugs['extensions-active'], |
| 908 | 'perms' => 'admin_zerobs_manage_options', |
| 909 | 'order' => 1, |
| 910 | 'wpposition' => 1, |
| 911 | 'callback' => 'zeroBSCRM_pages_admin_deactivate_error', |
| 912 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 913 | ); |
| 914 | |
| 915 | // Your Profile (hidden) |
| 916 | $menu['hidden']['subitems']['yourprofile'] = array( |
| 917 | 'title' => __( 'Your Profile', 'zero-bs-crm' ), |
| 918 | 'url' => $zbs->slugs['your-profile'], |
| 919 | 'perms' => 'admin_zerobs_customers', |
| 920 | 'order' => 1, |
| 921 | 'wpposition' => 1, |
| 922 | 'callback' => 'zeroBSCRM_pages_admin_your_profile', |
| 923 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 924 | ); |
| 925 | |
| 926 | // Reminders (hidden) |
| 927 | $menu['hidden']['subitems']['reminders'] = array( |
| 928 | 'title' => __( 'Reminders', 'zero-bs-crm' ), |
| 929 | 'url' => $zbs->slugs['reminders'], |
| 930 | 'perms' => 'admin_zerobs_customers', |
| 931 | 'order' => 1, |
| 932 | 'wpposition' => 1, |
| 933 | 'callback' => 'zeroBSCRM_pages_admin_reminders', |
| 934 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 935 | ); |
| 936 | |
| 937 | // No Permissions (hidden) |
| 938 | $menu['hidden']['subitems']['norights'] = array( |
| 939 | 'title' => __( 'No Permission', 'zero-bs-crm' ), |
| 940 | 'url' => $zbs->slugs['zbs-noaccess'], |
| 941 | 'perms' => 'admin_zerobs_customers', |
| 942 | 'order' => 1, |
| 943 | 'wpposition' => 1, |
| 944 | 'callback' => 'zeroBSCRM_pages_norights', |
| 945 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 946 | ); |
| 947 | |
| 948 | // Tasks - Listview (sub) |
| 949 | $menu['hidden']['subitems']['tasklist'] = array( |
| 950 | 'title' => __( 'Task List', 'zero-bs-crm' ), |
| 951 | 'url' => $zbs->slugs['manage-tasks-list'], |
| 952 | 'perms' => 'admin_zerobs_view_events', |
| 953 | 'order' => 1, |
| 954 | 'wpposition' => 3, |
| 955 | 'callback' => 'zeroBSCRM_render_tasks_list_page', |
| 956 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles', 'zeroBSCRM_admin_styles_ui2_listview' ), |
| 957 | ); |
| 958 | |
| 959 | // Tasks - Tags (sub) |
| 960 | $menu['hidden']['subitems']['tasktags'] = array( |
| 961 | 'title' => __( 'Task Tags', 'zero-bs-crm' ), |
| 962 | 'url' => 'admin.php?page=' . $zbs->slugs['tagmanager'] . '&tagtype=event', |
| 963 | 'perms' => 'admin_zerobs_view_events', |
| 964 | 'order' => 3, |
| 965 | 'wpposition' => 3, |
| 966 | 'callback' => '', |
| 967 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 968 | ); |
| 969 | |
| 970 | // =================================================== |
| 971 | // ======= / Hidden |
| 972 | // =================================================== |
| 973 | |
| 974 | return $menu; |
| 975 | } |
| 976 | |
| 977 | // takes ZBS formatted menu items + adds via wp menu system. |
| 978 | function zeroBSCRM_menu_applyWPMenu( $menu = array() ) { |
| 979 | // takeover mode, if active |
| 980 | $menu = zeroBSCRM_menu_applyTakeover( $menu ); |
| 981 | |
| 982 | // cycle through menu + submenus + add to wp |
| 983 | if ( is_array( $menu ) ) { |
| 984 | foreach ( $menu as $menuItemKey => $menuItem ) { |
| 985 | // pump em through |
| 986 | zeroBSCRM_menu_add_toplevel( $menuItemKey, $menuItem ); |
| 987 | } |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | // Takeover mode |
| 992 | // v3.0 + |
| 993 | // identify if takeover mode on, if so, murder the wp menus other than zbs (this setting needs a WARNING!) |
| 994 | function zeroBSCRM_menu_applyTakeover( $menu = false ) { |
| 995 | |
| 996 | global $zbs; |
| 997 | |
| 998 | // Get the admin layout option 1 = Full, 2 = Slimline, 3 = CRM Only |
| 999 | $crm_menu_mode = zeroBSCRM_getSetting( 'menulayout' ); |
| 1000 | if ( ! isset( $crm_menu_mode ) || ! in_array( $crm_menu_mode, array( 1, 2, 3 ) ) ) { |
| 1001 | $crm_menu_mode = 2; // Defaults to slimline |
| 1002 | } |
| 1003 | |
| 1004 | // Only for zbs custom user role users or all if flagged |
| 1005 | $takeoverModeAll = $zbs->settings->get( 'wptakeovermodeforall' ); |
| 1006 | $takeoverModeZBS = $zbs->settings->get( 'wptakeovermode' ); |
| 1007 | $takeoverMode = false; |
| 1008 | |
| 1009 | if ( $takeoverModeAll || ( zeroBSCRM_permsIsZBSUser() && $takeoverModeZBS ) ) { |
| 1010 | $takeoverMode = true; |
| 1011 | } |
| 1012 | |
| 1013 | // Menu mode specific overrides |
| 1014 | if ( $crm_menu_mode == ZBS_MENU_CRMONLY ) { |
| 1015 | $takeoverModeAll = true; |
| 1016 | $takeoverModeZBS = true; |
| 1017 | $takeoverMode = true; |
| 1018 | } |
| 1019 | |
| 1020 | if ( $takeoverMode ) { |
| 1021 | |
| 1022 | // if (isset($settings['wptakeovermode']) && $settings['wptakeovermode'] == 1 && zeroBSCRM_permsIsZBSUser()) { |
| 1023 | // https://codex.wordpress.org/Function_Reference/remove_menu_page |
| 1024 | remove_menu_page( 'index.php' ); // Dashboard |
| 1025 | remove_menu_page( 'edit-tags.php?taxonomy=category' ); // They appear to have for posts... |
| 1026 | |
| 1027 | // They wont have perms for all these anyhow :) |
| 1028 | /* |
| 1029 | remove_menu_page( 'edit.php' ); // Posts |
| 1030 | remove_menu_page( 'upload.php' ); // Media |
| 1031 | remove_menu_page( 'edit.php?post_type=page' ); // Pages |
| 1032 | remove_menu_page( 'edit-comments.php' ); // Comments |
| 1033 | remove_menu_page( 'themes.php' ); // Appearance |
| 1034 | remove_menu_page( 'plugins.php' ); // Plugins |
| 1035 | remove_menu_page( 'users.php' ); // Users |
| 1036 | remove_menu_page( 'tools.php' ); // Tools |
| 1037 | remove_menu_page( 'options-general.php' ); // Settings |
| 1038 | */ |
| 1039 | |
| 1040 | if ( $takeoverModeAll ) { |
| 1041 | |
| 1042 | remove_menu_page( 'edit-tags.php?taxonomy=category' ); // They appear to have for posts weirdly |
| 1043 | remove_menu_page( 'index.php' ); // Dashboard |
| 1044 | remove_menu_page( 'edit.php' ); // Posts |
| 1045 | remove_menu_page( 'upload.php' ); // Media |
| 1046 | remove_menu_page( 'edit.php?post_type=page' ); // Pages |
| 1047 | remove_menu_page( 'edit-comments.php' ); // Comments |
| 1048 | remove_menu_page( 'themes.php' ); // Appearance |
| 1049 | remove_menu_page( 'plugins.php' ); // Plugins |
| 1050 | remove_menu_page( 'users.php' ); // Users |
| 1051 | remove_menu_page( 'tools.php' ); // Tools |
| 1052 | remove_menu_page( 'options-general.php' ); // Settings |
| 1053 | |
| 1054 | } |
| 1055 | |
| 1056 | // Remove profile :) http://stackoverflow.com/questions/4524612/remove-profile-admin-menu-from-administrative-panel |
| 1057 | remove_menu_page( 'profile.php' ); |
| 1058 | |
| 1059 | // Logout :) |
| 1060 | // $adminMenuLogout = add_menu_page( __('Log Out',"zero-bs-crm"), __('Log Out',"zero-bs-crm"), 'read', $zbs->slugs['logout'], 'zeroBSCRM_pages_logout', 'dashicons-unlock',100); |
| 1061 | // add_action( "admin_print_styles-{$adminMenuLogout}", 'zeroBSCRM_global_admin_styles' ); |
| 1062 | |
| 1063 | // Add logout (Top Level) |
| 1064 | $menu['logout'] = array( |
| 1065 | 'ico' => 'dashicons-unlock', |
| 1066 | 'title' => __( 'Log Out', 'zero-bs-crm' ), |
| 1067 | 'url' => $zbs->slugs['logout'], |
| 1068 | 'perms' => 'read', |
| 1069 | 'order' => 999, |
| 1070 | 'wpposition' => 999, |
| 1071 | 'subitems' => array(), |
| 1072 | 'callback' => 'zeroBSCRM_pages_logout', |
| 1073 | 'stylefuncs' => array( 'zeroBSCRM_global_admin_styles' ), |
| 1074 | ); |
| 1075 | |
| 1076 | } |
| 1077 | |
| 1078 | return $menu; |
| 1079 | } |
| 1080 | |
| 1081 | // Works through each menu item + subitem and validates current user has perms to see it |
| 1082 | function zeroBSCRM_menu_securityGuard( $menu = array() ) { |
| 1083 | |
| 1084 | // WORTH NOTING: |
| 1085 | // 'hidden' array checks for zbs_dash permissions. So all hidden wp pages are not going to work |
| 1086 | // ... for users who can't 'zbs_dash' |
| 1087 | |
| 1088 | $nMenu = array(); |
| 1089 | $userCaps = zeroBSCRM_getCurrentUserCaps(); |
| 1090 | |
| 1091 | if ( is_array( $menu ) ) { |
| 1092 | |
| 1093 | foreach ( $menu as $topMenuKey => $topMenu ) { |
| 1094 | |
| 1095 | // got perms? |
| 1096 | if ( isset( $topMenu['perms'] ) && ! empty( $topMenu['perms'] ) ) { |
| 1097 | |
| 1098 | // user has perm for this top level menu? |
| 1099 | if ( in_array( $topMenu['perms'], $userCaps ) ) { |
| 1100 | |
| 1101 | // user has permissions, lets add, but check each sub item too |
| 1102 | $toAdd = $topMenu; |
| 1103 | $toAdd['subitems'] = array(); |
| 1104 | |
| 1105 | // check sub items |
| 1106 | if ( is_array( $topMenu['subitems'] ) ) { |
| 1107 | |
| 1108 | foreach ( $topMenu['subitems'] as $subMenuKey => $subMenu ) { |
| 1109 | |
| 1110 | // got perms? |
| 1111 | if ( isset( $subMenu['perms'] ) && ! empty( $subMenu['perms'] ) ) { |
| 1112 | |
| 1113 | // user has perm for this sub level menu? |
| 1114 | if ( in_array( $subMenu['perms'], $userCaps ) ) { |
| 1115 | |
| 1116 | // user has permissions, add to top menu subitems arr |
| 1117 | $toAdd['subitems'][ $subMenuKey ] = $subMenu; |
| 1118 | |
| 1119 | } |
| 1120 | } |
| 1121 | } |
| 1122 | } // / check sub items |
| 1123 | |
| 1124 | // add |
| 1125 | $nMenu[ $topMenuKey ] = $toAdd; |
| 1126 | |
| 1127 | } // / user has cap for top menu |
| 1128 | |
| 1129 | } // / top menu has perms attr |
| 1130 | |
| 1131 | } |
| 1132 | } // / top level menu item |
| 1133 | |
| 1134 | return $nMenu; |
| 1135 | } |
| 1136 | |
| 1137 | // Order menu items + subitems based on 'order' |
| 1138 | function zeroBSCRM_menu_order( $menu = array() ) { |
| 1139 | |
| 1140 | $nMenu = array(); |
| 1141 | |
| 1142 | // first sort subitems |
| 1143 | if ( is_array( $menu ) ) { |
| 1144 | |
| 1145 | foreach ( $menu as $topMenuKey => $topMenu ) { |
| 1146 | |
| 1147 | // user has permissions, lets add, but check each sub item too |
| 1148 | $toAdd = $topMenu; |
| 1149 | |
| 1150 | // got subitems? |
| 1151 | if ( isset( $topMenu['subitems'] ) && ! empty( $topMenu['subitems'] ) ) { |
| 1152 | |
| 1153 | // sort subitems |
| 1154 | uasort( $toAdd['subitems'], 'zeroBSCRM_menu_order_sort' ); |
| 1155 | |
| 1156 | } // / top menu has subitems attr |
| 1157 | |
| 1158 | // add |
| 1159 | $nMenu[ $topMenuKey ] = $toAdd; |
| 1160 | |
| 1161 | } |
| 1162 | } // / top level menu item (sort subitems) |
| 1163 | |
| 1164 | // Now sort toplevel: |
| 1165 | uasort( $nMenu, 'zeroBSCRM_menu_order_sort' ); |
| 1166 | |
| 1167 | // return ordered menu |
| 1168 | return $nMenu; |
| 1169 | } |
| 1170 | |
| 1171 | // Sort Func for: Order menu items + subitems based on 'order' |
| 1172 | function zeroBSCRM_menu_order_sort( $a, $b ) { |
| 1173 | // catch |
| 1174 | if ( ! is_array( $a ) || ! is_array( $b ) ) { |
| 1175 | return 0; |
| 1176 | } |
| 1177 | if ( ! isset( $a['order'] ) || ! isset( $b['order'] ) ) { |
| 1178 | return 0; |
| 1179 | } |
| 1180 | if ( $a['order'] == $b['order'] ) { |
| 1181 | return 0; |
| 1182 | } |
| 1183 | return ( $a['order'] < $b['order'] ) ? -1 : 1; |
| 1184 | } |
| 1185 | |
| 1186 | // adds a toplevel menu item, and its subitems to wp menus: |
| 1187 | function zeroBSCRM_menu_add_toplevel( $menuItemKey = '', $menuItem = -1 ) { |
| 1188 | if ( is_array( $menuItem ) ) { |
| 1189 | |
| 1190 | // echo 'adding '.$menuItemKey.' ('.count($menuItem['subitems']).')<br>'; |
| 1191 | |
| 1192 | // here's a catch, this catches all "hidden" (null) submenu items, |
| 1193 | // a hack which lets us add wp pages which are not menu-listed. |
| 1194 | if ( $menuItemKey == 'hidden' ) { |
| 1195 | |
| 1196 | // Hidden subitems only in this one. |
| 1197 | |
| 1198 | // Any (hidden) subpages to add? |
| 1199 | if ( isset( $menuItem['subitems'] ) && is_array( $menuItem['subitems'] ) ) { |
| 1200 | foreach ( $menuItem['subitems'] as $subMenuKey => $subMenuItem ) { |
| 1201 | |
| 1202 | // Add the item |
| 1203 | // ...passing false for toplevel item, which sets these to hidden |
| 1204 | zeroBSCRM_menu_add_sublevel( false, $subMenuKey, $subMenuItem ); |
| 1205 | |
| 1206 | } // / foreach subitem |
| 1207 | |
| 1208 | } // / if subitems |
| 1209 | |
| 1210 | } else { |
| 1211 | |
| 1212 | // NORMAL menu item + subitems |
| 1213 | |
| 1214 | // WP Menu add (traditional way) |
| 1215 | // ... this 'doubles' up on perms + ordering |
| 1216 | // https://developer.wordpress.org/reference/functions/add_menu_page/ |
| 1217 | $adminPage = add_menu_page( |
| 1218 | $menuItem['title'], // 'Jetpack CRM ' . __( 'Plugin', 'zero-bs-crm' ), |
| 1219 | $menuItem['title'], // $adminMenuTitle, |
| 1220 | $menuItem['perms'], // 'admin_zerobs_manage_options', |
| 1221 | $menuItem['url'], // $zbs->slugs['home'], |
| 1222 | $menuItem['callback'], // 'zeroBSCRM_pages_home' |
| 1223 | ( isset( $menuItem['ico'] ) ? $menuItem['ico'] : '' ), |
| 1224 | ( isset( $menuItem['wpposition'] ) ? $menuItem['wpposition'] : null ) |
| 1225 | ); |
| 1226 | |
| 1227 | // any style callbacks to enqueue? |
| 1228 | if ( isset( $menuItem['stylefuncs'] ) && is_array( $menuItem['stylefuncs'] ) ) { |
| 1229 | foreach ( $menuItem['stylefuncs'] as $styleFunc ) { |
| 1230 | add_action( "admin_print_styles-{$adminPage}", $styleFunc ); |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | // Any subpages to add? |
| 1235 | if ( isset( $menuItem['subitems'] ) && is_array( $menuItem['subitems'] ) ) { |
| 1236 | foreach ( $menuItem['subitems'] as $subMenuKey => $subMenuItem ) { |
| 1237 | |
| 1238 | // Add the item |
| 1239 | // this is split into subfunc as we also use it for null menus :) |
| 1240 | zeroBSCRM_menu_add_sublevel( $menuItem, $subMenuKey, $subMenuItem ); |
| 1241 | |
| 1242 | } // / foreach subitem |
| 1243 | |
| 1244 | } // / if subitems |
| 1245 | |
| 1246 | } // / NORMAL MENU |
| 1247 | |
| 1248 | } // if menuitem is array |
| 1249 | } |
| 1250 | |
| 1251 | // adds a sublevel menu item: |
| 1252 | // to add a "HIDDEN" secret menu, pass $menuItem = false, and rest correct |
| 1253 | function zeroBSCRM_menu_add_sublevel( $menuItem = -1, $subMenuKey = -1, $subMenuItem = -1 ) { |
| 1254 | if ( is_array( $subMenuItem ) ) { |
| 1255 | |
| 1256 | // https://developer.wordpress.org/reference/functions/add_submenu_page/ |
| 1257 | $adminSubPage = add_submenu_page( |
| 1258 | ( is_array( $menuItem ) && isset( $menuItem['url'] ) ) ? $menuItem['url'] : 'jpcrm-hidden', // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase |
| 1259 | $subMenuItem['title'], // __( 'Tags', 'zero-bs-crm' ), |
| 1260 | $subMenuItem['title'], // __( 'Tags', 'zero-bs-crm' ), |
| 1261 | $subMenuItem['perms'], // 'admin_zerobs_customers', |
| 1262 | $subMenuItem['url'], // $zbs->slugs['tagmanager'], |
| 1263 | $subMenuItem['callback'] // 'zeroBSCRM_pages_admin_tags' |
| 1264 | ); |
| 1265 | |
| 1266 | // any style callbacks to enqueue? |
| 1267 | if ( isset( $subMenuItem['stylefuncs'] ) && is_array( $subMenuItem['stylefuncs'] ) ) { |
| 1268 | foreach ( $subMenuItem['stylefuncs'] as $subStyleFunc ) { |
| 1269 | add_action( "admin_print_styles-{$adminSubPage}", $subStyleFunc ); |
| 1270 | } |
| 1271 | } |
| 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | // rather than using remove_Submenu_page |
| 1276 | // https://codex.wordpress.org/Function_Reference/remove_submenu_page |
| 1277 | // this just kills it out of the $submenu global (so page will still load if accessed directly) |
| 1278 | // zeroBSCRM_menus_removeWPSubMenu($zbs->slugs['datatools'],'zerobscrm-csvimporterlite-app'); |
| 1279 | function zeroBSCRM_menus_removeWPSubMenu( $slug = '', $subpage = '' ) { |
| 1280 | |
| 1281 | // Global |
| 1282 | global $submenu; |
| 1283 | |
| 1284 | if ( isset( $submenu[ $slug ] ) && is_array( $submenu[ $slug ] ) ) { |
| 1285 | |
| 1286 | $newArr = array(); |
| 1287 | foreach ( $submenu[ $slug ] as $ind => $page ) { |
| 1288 | if ( $page[2] != $subpage ) { |
| 1289 | $newArr[] = $page; |
| 1290 | } |
| 1291 | } |
| 1292 | $submenu[ $slug ] = $newArr; |
| 1293 | |
| 1294 | } |
| 1295 | } |