Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 329 |
|
0.00% |
0 / 6 |
CRAP | n/a |
0 / 0 |
|
| zeroBSCRM_admin_menu_settings | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| zeroBSCRM_bodyClassMods | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |||
| zeroBSCRM_show_pending_number | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| zeroBSCRM_admin_top_menu | |
0.00% |
0 / 285 |
|
0.00% |
0 / 1 |
4970 | |||
| zeroBS_menu_active | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
30 | |||
| zeroBS_menu_active_type | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
90 | |||
| 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 | /* |
| 13 | ====================================================== |
| 14 | Breaking Checks ( stops direct access ) |
| 15 | ====================================================== */ |
| 16 | if ( ! defined( 'ZEROBSCRM_PATH' ) ) { |
| 17 | exit( 0 ); |
| 18 | } |
| 19 | /* |
| 20 | ====================================================== |
| 21 | / Breaking Checks |
| 22 | ====================================================== */ |
| 23 | |
| 24 | /* |
| 25 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 26 | |
| 27 | THIS FILE IS FOR JPCRM Top Menu related changes - later to be unified into one .Menu file |
| 28 | |
| 29 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 30 | |
| 31 | |
| 32 | */ |
| 33 | |
| 34 | /* |
| 35 | xxx |
| 36 | |
| 37 | // Top menu |
| 38 | add_action("wp_after_admin_bar_render","zeroBSCRM_admin_top_menu", 10); |
| 39 | |
| 40 | // Learn menu |
| 41 | function jpcrm_initialise_learn_menu(){ |
| 42 | |
| 43 | new Learn_Menu(); |
| 44 | |
| 45 | } |
| 46 | // Note the priority here. This causes the "learn" block to present after the top menu |
| 47 | add_action( "wp_after_admin_bar_render", "jpcrm_initialise_learn_menu", 11 ); |
| 48 | |
| 49 | */ |
| 50 | |
| 51 | // } Admin head for the top menu (i.e. remembering the toggle mode) - modified for custom admin |
| 52 | function zeroBSCRM_admin_menu_settings() { |
| 53 | |
| 54 | $cid = get_current_user_id(); |
| 55 | $hiding_wp = get_user_meta( $cid, 'zbs-hide-wp-menus', true ); |
| 56 | if ( zeroBSCRM_isAdminPage() ) { |
| 57 | |
| 58 | // if hiding, append class to body :)- this should be a single js call really, fudged for now :) |
| 59 | // jQuery('body').addClass('zbs-fullscreen'); - NOW NOT NEEDED (see zeroBSCRM_bodyClassMods - added via php for less visual lag) |
| 60 | // left in for cases like material admin not using proper admin_body_class |
| 61 | if ( $hiding_wp ) { |
| 62 | ?> |
| 63 | <script type="text/javascript">jQuery(function(){ jQuery('body').addClass('zbs-fullscreen'); jQuery('#wpcontent').addClass('zbs-menu-open'); });</script> |
| 64 | <?php |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | add_action( 'admin_head', 'zeroBSCRM_admin_menu_settings' ); |
| 69 | |
| 70 | add_filter( 'admin_body_class', 'zeroBSCRM_bodyClassMods' ); |
| 71 | function zeroBSCRM_bodyClassMods( $classes = '' ) { |
| 72 | |
| 73 | // show hide fullscreen mode |
| 74 | $hiding_wp = get_user_meta( get_current_user_id(), 'zbs-hide-wp-menus', true ); |
| 75 | if ( zeroBSCRM_isAdminPage() ) { |
| 76 | |
| 77 | $classes .= ' jpcrm-admin'; |
| 78 | |
| 79 | // if hiding, append class to body |
| 80 | if ( $hiding_wp ) { |
| 81 | $classes .= ' zbs-fullscreen '; |
| 82 | } |
| 83 | |
| 84 | if ( isset( $_GET['page'] ) && jpcrm_is_full_width_page( $_GET['page'] ) ) { //phpcs:ignore |
| 85 | $classes .= ' jpcrm-full-width '; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return $classes; |
| 90 | } |
| 91 | |
| 92 | // } THIS IS THE PENDING COUNT FOR ZBS DASHBOARD (akin to pending posts red number) |
| 93 | // } USED TO HIGHLIGHT NOTIFICATIONS - WHICH WILL ALSO BE IN TOP MENU UI - can use it here too |
| 94 | add_filter( 'add_menu_classes', 'zeroBSCRM_show_pending_number' ); |
| 95 | function zeroBSCRM_show_pending_number( $menu ) { |
| 96 | |
| 97 | $pending_count = 0; // update this with count of UNREAD notifications if we want to use here. |
| 98 | |
| 99 | // build string to match in $menu array |
| 100 | $menu_str = 'zerobscrm-dash'; |
| 101 | |
| 102 | // loop through $menu items, find match, add indicator |
| 103 | foreach ( $menu as $menu_key => $menu_data ) { |
| 104 | |
| 105 | if ( $menu_str != $menu_data[2] ) { |
| 106 | continue; |
| 107 | } |
| 108 | $menu[ $menu_key ][0] .= ' <span class="update-plugins count-' . $pending_count . '"><span class="plugin-count">' . number_format_i18n( $pending_count ) . '</span></span>'; |
| 109 | } |
| 110 | return $menu; |
| 111 | } |
| 112 | |
| 113 | // } This is NEW UI for the top menu. Helpful links in the top menu = Improved UI |
| 114 | function zeroBSCRM_admin_top_menu( $branding = 'zero-bs-crm', $page = 'dash' ) { |
| 115 | |
| 116 | // } restrict to ONLY Jetpack CRM pages - NOTE our EXTENSIONS will need to use the same |
| 117 | // } $zbs->slugs global. Some of mine use $zeroBSCRM_extension_slugs |
| 118 | // } will update the extensions to use the probably $zbs->slugs global |
| 119 | // } WH: All good. |
| 120 | if ( zeroBSCRM_isAdminPage() ) { |
| 121 | |
| 122 | global $zbs; |
| 123 | |
| 124 | // } Check whether we want to run the hopscotch tour |
| 125 | $uid = get_current_user_id(); |
| 126 | $zbs_hopscoth = get_user_meta( $uid, 'zbs-hopscotch-tour', true ); |
| 127 | if ( $zbs_hopscoth == '' && ! isset( $_GET['zbs-welcome-tour'] ) ) { |
| 128 | |
| 129 | // first load.. |
| 130 | update_user_meta( $uid, 'zbs-hopscotch-tour', 0 ); |
| 131 | ?> |
| 132 | <script type="text/javascript">var zbscrmjs_hopscotch_virgin=1;</script> |
| 133 | <?php |
| 134 | |
| 135 | } else { |
| 136 | |
| 137 | // not first time... |
| 138 | ?> |
| 139 | <script type="text/javascript">var zbscrmjs_hopscotch_virgin=0;</script> |
| 140 | <?php |
| 141 | |
| 142 | } |
| 143 | |
| 144 | if ( isset( $_GET['zbs-welcome-tour'] ) && $_GET['zbs-welcome-tour'] == 1 ) { |
| 145 | |
| 146 | // user-initiated: |
| 147 | ?> |
| 148 | <script type="text/javascript">var zbscrmjs_hopscotch_virgin=1;</script> |
| 149 | <?php |
| 150 | } |
| 151 | |
| 152 | // } passing "branding" for the logo top :-) |
| 153 | $branding = ''; |
| 154 | |
| 155 | ##WLREMOVE |
| 156 | $branding = 'zero-bs-crm'; |
| 157 | ##/WLREMOVE |
| 158 | |
| 159 | // } AJAX nonce, rest is dealt with in the admin global js :) |
| 160 | ?> |
| 161 | <script type="text/javascript">var zbscrmjs_topMenuSecToken = '<?php echo esc_js( wp_create_nonce( 'zbscrmjs-ajax-nonce-topmenu' ) ); ?>';</script> |
| 162 | <?php |
| 163 | |
| 164 | // } Menu hidden? - maybe we can cookie this? for now this is slick. |
| 165 | $hiding_wp = get_user_meta( $uid, 'zbs-hide-wp-menus', true ); |
| 166 | if ( $hiding_wp ) { |
| 167 | $admin_menu_state = 'menu-closed'; |
| 168 | } else { |
| 169 | $admin_menu_state = 'menu-open'; |
| 170 | } |
| 171 | |
| 172 | // } Other Prep |
| 173 | $currentUser = wp_get_current_user(); |
| 174 | $alsoCo = ''; // } WH added to fix php warnings - what\s this? |
| 175 | $b2bMode = zeroBSCRM_getSetting( 'companylevelcustomers' ); |
| 176 | |
| 177 | // pre-collate tools so can hide if none :) |
| 178 | $toolsMenu = array(); |
| 179 | |
| 180 | // calendar |
| 181 | if ( zeroBSCRM_perms_tasks() && zeroBSCRM_getSetting( 'feat_calendar' ) > 0 ) { |
| 182 | $toolsMenu[] = '<a href="' . zeroBSCRM_getAdminURL( $zbs->slugs['manage-tasks'] ) . '" class="item"><i class="icon calendar outline"></i> ' . __( 'Task Scheduler', 'zero-bs-crm' ) . '</a>'; |
| 183 | } |
| 184 | // forms |
| 185 | if ( zeroBSCRM_permsForms() && zeroBSCRM_getSetting( 'feat_forms' ) > 0 ) { |
| 186 | $toolsMenu[] = '<a href="' . zeroBSCRM_getAdminURL( $zbs->slugs['manageformscrm'] ) . '" class="item"><i class="icon file outline"></i> ' . __( 'Forms', 'zero-bs-crm' ) . '</a>'; |
| 187 | } |
| 188 | |
| 189 | // removes data-tools page for everyone except WP Admin + zbs admin |
| 190 | if ( zeroBSCRM_isZBSAdminOrAdmin() ) { |
| 191 | $toolsMenu[] = '<a href="' . zeroBSCRM_getAdminURL( $zbs->slugs['datatools'] ) . '" class="item"><i class="icon configure"></i> ' . __( 'Data Tools', 'zero-bs-crm' ) . '</a>'; |
| 192 | } |
| 193 | |
| 194 | // filter items (allows additions from ext etc.) |
| 195 | $toolsMenu = apply_filters( 'zbs-tools-menu', $toolsMenu ); |
| 196 | |
| 197 | // } Add extensions to base, always :) more upsell. |
| 198 | if ( zeroBSCRM_isZBSAdminOrAdmin() ) { |
| 199 | $toolsMenu[] = '<a class="item" id="zbs-manage-modules-tour" href="' . zeroBSCRM_getAdminURL( $zbs->slugs['modules'] ) . '"><i class="icon th" aria-hidden="true"></i> ' . __( 'Core Modules', 'zero-bs-crm' ) . '</a>'; |
| 200 | ##WLREMOVE |
| 201 | $toolsMenu[] = '<a class="item" id="zbs-manage-ext-tour" href="' . zeroBSCRM_getAdminURL( $zbs->slugs['extensions'] ) . '"><i class="icon plug" aria-hidden="true"></i> ' . __( 'Extensions', 'zero-bs-crm' ) . '</a>'; |
| 202 | ##/WLREMOVE |
| 203 | } |
| 204 | |
| 205 | ?> |
| 206 | |
| 207 | |
| 208 | <!--- mobile only menu --> |
| 209 | <div class="ui mobile tablet only" id="zbs-mobile-nav"> |
| 210 | <div id="zbs-main-logo-mobile"> |
| 211 | <div class="zbs-face-1-mobile"> |
| 212 | <img id="zbs-main-logo-mobby" alt="Jetpack CRM mobile logo" src="<?php echo esc_url( jpcrm_get_logo( false, 'white' ) ); ?>" style="cursor:pointer;"> |
| 213 | </div> |
| 214 | </div> |
| 215 | <?php |
| 216 | |
| 217 | // Dev mode? add ui label |
| 218 | if ( zeroBSCRM_isLocal() ) { |
| 219 | |
| 220 | // no id etc. to stop people hiding with css |
| 221 | ?> |
| 222 | <div class="item" style="float: right;color: #FFF;margin-top: -2.5em;"><?php esc_html_e( 'Developer Mode', 'zero-bs-crm' ); ?></div> |
| 223 | <?php |
| 224 | |
| 225 | } |
| 226 | |
| 227 | ?> |
| 228 | <div class="ui stackable menu inverted" id="zbs-mobile-navigation-toggle"> |
| 229 | |
| 230 | <!-- basic menu tabs for mobile --> |
| 231 | <a class="item<?php zeroBS_menu_active( $zbs->slugs['dash'] ); ?>" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['dash'] ) ); ?>"><i class="icon dashboard"></i><?php esc_html_e( 'Dashboard', 'zero-bs-crm' ); ?></a> |
| 232 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managecontacts'] ) ); ?>"><i class="icon users"></i> <?php esc_html_e( 'Contacts', 'zero-bs-crm' ); ?></a> |
| 233 | <?php if ( $b2bMode == 1 ) { ?> |
| 234 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managecompanies'] ) ); ?>"><i class="icon building outline"></i> <?php echo esc_html( jpcrm_label_company( true ) ); ?></a> |
| 235 | <?php } ?> |
| 236 | <?php if ( zeroBSCRM_permsViewQuotes() && zeroBSCRM_getSetting( 'feat_quotes' ) > 0 ) { ?> |
| 237 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managequotes'] ) ); ?>"><i class="icon file outline"></i> <?php esc_html_e( 'Quotes', 'zero-bs-crm' ); ?></a> |
| 238 | <?php } ?> |
| 239 | |
| 240 | <?php if ( zeroBSCRM_permsViewInvoices() && zeroBSCRM_getSetting( 'feat_invs' ) > 0 ) { ?> |
| 241 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['manageinvoices'] ) ); ?>"><i class="icon file alternate outline"></i> <?php esc_html_e( 'Invoices', 'zero-bs-crm' ); ?></a> |
| 242 | <?php } ?> |
| 243 | <?php if ( zeroBSCRM_permsViewTransactions() && zeroBSCRM_getSetting( 'feat_transactions' ) > 0 ) { ?> |
| 244 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managetransactions'] ) ); ?>"><i class="icon shopping cart"></i> <?php esc_html_e( 'Transactions', 'zero-bs-crm' ); ?></a> |
| 245 | <?php } ?> |
| 246 | |
| 247 | <?php |
| 248 | // tools menu added 29/6/18, because Brian needs access to his, maybe we need to rethink this whole menu setup |
| 249 | |
| 250 | if ( count( $toolsMenu ) > 0 ) { |
| 251 | foreach ( $toolsMenu as $menuItem ) { |
| 252 | |
| 253 | // wh quick hack to avoid clashing ID's |
| 254 | $menuItemHTML = str_replace( 'id="', 'id="mob-', $menuItem ); |
| 255 | $menuItemHTML = str_replace( "id='", "id='mob-", $menuItemHTML ); |
| 256 | |
| 257 | echo $menuItemHTML; |
| 258 | |
| 259 | } |
| 260 | } |
| 261 | ?> |
| 262 | |
| 263 | |
| 264 | |
| 265 | </div> |
| 266 | |
| 267 | </div> |
| 268 | <script type="text/javascript"> |
| 269 | jQuery(function(){ |
| 270 | jQuery('#zbs-main-logo-mobby').on("click",function(e){ |
| 271 | jQuery("#zbs-mobile-navigation-toggle").toggle(); |
| 272 | }); |
| 273 | }) |
| 274 | </script> |
| 275 | <!--- // mobile only menu --> |
| 276 | <div id="jpcrm-top-menu"> |
| 277 | <div class="logo-cube <?php echo esc_attr( $admin_menu_state ); ?>"> |
| 278 | <div class="cube-side side1"> |
| 279 | <img alt="Jetpack CRM logo" src="<?php echo esc_url( jpcrm_get_logo( false ) ); ?>"> |
| 280 | </div> |
| 281 | <div class="cube-side side2"> |
| 282 | <i class="expand icon fa-flip-horizontal"></i> |
| 283 | </div> |
| 284 | </div> |
| 285 | |
| 286 | <menu-bar> |
| 287 | |
| 288 | <menu-section> |
| 289 | <a class="item<?php esc_attr( zeroBS_menu_active( $zbs->slugs['dash'] ) ); ?>" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['dash'] ) ); ?>"><?php esc_html_e( 'Dashboard', 'zero-bs-crm' ); ?></a> |
| 290 | <div class="ui simple dropdown item select<?php esc_attr( zeroBS_menu_active_type( 'contact' ) ); ?>" id="zbs-contacts-topmenu" style="min-width:114px;z-index:5"> |
| 291 | <span class="text"><?php esc_html_e( 'Contacts', 'zero-bs-crm' ); ?></span> |
| 292 | <i class="dropdown icon"></i> |
| 293 | <div class="menu ui"> |
| 294 | |
| 295 | <?php |
| 296 | if ( zeroBSCRM_permsCustomers() ) { // ADD CUSTOMER //esc_url( 'post-new.php?post_type=zerobs_customer'.$alsoCo ) |
| 297 | echo ' <a href="' . jpcrm_esc_link( 'create', -1, 'zerobs_customer', false ) . $alsoCo . '" class="item"><i class="icon plus"></i> ' . esc_html__( 'Add New', 'zero-bs-crm' ) . '</a>'; |
| 298 | } |
| 299 | ?> |
| 300 | |
| 301 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managecontacts'] ) ); ?>"><i class="icon list"></i> <?php esc_html_e( 'View all', 'zero-bs-crm' ); ?></a> |
| 302 | |
| 303 | <?php if ( zeroBSCRM_permsCustomers() ) { // CONTACT TAGS AND SEGMENTS ?> |
| 304 | <a class="item" href="<?php echo jpcrm_esc_link( 'tags', -1, 'zerobs_customer', false, 'contact' ); ?>"><i class="icon tags"></i> <?php esc_html_e( 'Tags', 'zero-bs-crm' ); ?></a> |
| 305 | <a class="item" href="<?php echo jpcrm_esc_link( $zbs->slugs['segments'], -1, 'zerobs_customer', false, 'contact' ); ?>"><i class="chart pie icon"></i> <?php esc_html_e( 'Segments', 'zero-bs-crm' ); ?></a> |
| 306 | <?php } ?> |
| 307 | |
| 308 | <?php if ( $b2bMode == 1 ) { ?> |
| 309 | |
| 310 | <div class="ui divider"></div> |
| 311 | |
| 312 | <div class="ui simple dropdown item " id="zbs-companies-topmenu"> |
| 313 | <?php echo esc_html( jpcrm_label_company( true ) ); ?><i class="dropdown icon zbs-subsub-ico"></i> |
| 314 | <div class="menu ui"> |
| 315 | <?php |
| 316 | if ( zeroBSCRM_permsCustomers() ) { |
| 317 | echo ' <a href="' . jpcrm_esc_link( 'create', -1, 'zerobs_company', false ) . '" class="item"><i class="icon plus"></i> ' . esc_html__( 'Add New', 'zero-bs-crm' ) . '</a>'; |
| 318 | } |
| 319 | ?> |
| 320 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managecompanies'] ) ); ?>"><i class="icon list"></i> <?php esc_html_e( 'View all', 'zero-bs-crm' ); ?></a> |
| 321 | <a class="item" href="<?php echo jpcrm_esc_link( 'tags', -1, 'zerobs_company', false, 'zerobscrm_companytag' ); ?>"><i class="icon tags"></i> <?php esc_html_e( 'Tags', 'zero-bs-crm' ); ?></a> |
| 322 | </div> |
| 323 | </div> |
| 324 | |
| 325 | <?php } ?> |
| 326 | |
| 327 | <div class="ui divider"></div> |
| 328 | |
| 329 | <?php if ( ! zeroBSCRM_isExtensionInstalled( 'csvpro' ) && zeroBSCRM_isExtensionInstalled( 'csvimporterlite' ) ) { ?> |
| 330 | <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=' . $zbs->slugs['csvlite'] ) ); ?>"><i class="icon cloud upload"></i> <?php esc_html_e( 'Import', 'zero-bs-crm' ); ?></a> |
| 331 | <?php |
| 332 | } else { |
| 333 | |
| 334 | // if csvpro installed |
| 335 | if ( zeroBSCRM_isExtensionInstalled( 'csvpro' ) ) { |
| 336 | |
| 337 | global $zeroBSCRM_CSVImporterslugs; |
| 338 | |
| 339 | // got slug |
| 340 | if ( isset( $zeroBSCRM_CSVImporterslugs ) && is_array( $zeroBSCRM_CSVImporterslugs ) && isset( $zeroBSCRM_CSVImporterslugs['app'] ) ) { |
| 341 | ?> |
| 342 | <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=' . $zeroBSCRM_CSVImporterslugs['app'] ) ); ?>"><i class="icon cloud upload"></i> <?php esc_html_e( 'Import', 'zero-bs-crm' ); ?></a> |
| 343 | <?php |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | ?> |
| 348 | |
| 349 | |
| 350 | |
| 351 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['export-tools'] ) ); ?>"><i class="icon cloud download"></i> <?php esc_html_e( 'Export', 'zero-bs-crm' ); ?></a> |
| 352 | <?php |
| 353 | |
| 354 | // filter items (allows additions from ext etc.) |
| 355 | // for now empty (could contain the above) - so can add custom for log report (miguel) |
| 356 | $contactsMenu = array(); |
| 357 | $contactsMenu = apply_filters( 'zbs-contacts-menu', $contactsMenu ); |
| 358 | if ( count( $contactsMenu ) > 0 ) { |
| 359 | |
| 360 | // show divider? |
| 361 | ?> |
| 362 | <div class="ui divider"></div> |
| 363 | <?php |
| 364 | |
| 365 | foreach ( $contactsMenu as $menuItem ) { |
| 366 | echo $menuItem; } |
| 367 | } |
| 368 | |
| 369 | ?> |
| 370 | |
| 371 | </div> |
| 372 | </div> |
| 373 | |
| 374 | |
| 375 | <?php |
| 376 | if ( zeroBSCRM_permsViewQuotes() && zeroBSCRM_getSetting( 'feat_quotes' ) > 0 ) { |
| 377 | ?> |
| 378 | <div class="ui simple dropdown item select<?php zeroBS_menu_active_type( 'quote' ); ?>" id="zbs-quotes-topmenu" style="z-index:5"> |
| 379 | <span class="text"><?php esc_html_e( 'Quotes', 'zero-bs-crm' ); ?></span> |
| 380 | <i class="dropdown icon"></i> |
| 381 | <div class="menu ui"> |
| 382 | <?php |
| 383 | if ( zeroBSCRM_permsQuotes() ) { |
| 384 | echo ' <a href="' . jpcrm_esc_link( 'create', -1, 'zerobs_quote', false ) . $alsoCo . '" class="item"><i class="icon plus"></i> ' . esc_html__( 'Add New', 'zero-bs-crm' ) . '</a>'; |
| 385 | } |
| 386 | ?> |
| 387 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managequotes'] ) ); ?>"><i class="icon list"></i> <?php esc_html_e( 'View all', 'zero-bs-crm' ); ?></a> |
| 388 | |
| 389 | <?php if ( zeroBSCRM_permsQuotes() ) { // TAGS ?> |
| 390 | <a class="item" href="<?php echo jpcrm_esc_link( 'tags', -1, ZBS_TYPE_QUOTE, false, 'quote' ); ?>"><i class="icon tags"></i> <?php esc_html_e( 'Tags', 'zero-bs-crm' ); ?></a> |
| 391 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['quote-templates'] ) ); ?>"><i class="icon file text"></i> <?php esc_html_e( 'Templates', 'zero-bs-crm' ); ?></a> |
| 392 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['export-tools'] ) ); ?>&zbstype=quote"><i class="icon cloud download"></i> <?php esc_html_e( 'Export', 'zero-bs-crm' ); ?></a> |
| 393 | <?php } ?> |
| 394 | |
| 395 | <?php |
| 396 | |
| 397 | // filter items (allows additions from ext etc.) |
| 398 | // for now empty (could contain the above) |
| 399 | $quotesMenu = array(); |
| 400 | $quotesMenu = apply_filters( 'zbs-quotes-menu', $quotesMenu ); |
| 401 | if ( count( $quotesMenu ) > 0 ) { |
| 402 | |
| 403 | // show divider? |
| 404 | ?> |
| 405 | <div class="ui divider"></div> |
| 406 | <?php |
| 407 | |
| 408 | foreach ( $quotesMenu as $menuItem ) { |
| 409 | echo $menuItem; } |
| 410 | } |
| 411 | |
| 412 | ?> |
| 413 | </div> |
| 414 | </div> |
| 415 | <?php } ?> |
| 416 | |
| 417 | <?php if ( zeroBSCRM_permsViewInvoices() && zeroBSCRM_getSetting( 'feat_invs' ) > 0 ) { ?> |
| 418 | <div class="ui simple dropdown item select<?php zeroBS_menu_active_type( 'invoice' ); ?>" id="zbs-invoices-topmenu" style="z-index:5"> |
| 419 | <span class="text"><?php esc_html_e( 'Invoices', 'zero-bs-crm' ); ?></span> |
| 420 | <i class="dropdown icon"></i> |
| 421 | <div class="menu ui"> |
| 422 | <?php |
| 423 | if ( zeroBSCRM_permsInvoices() ) { |
| 424 | echo ' <a href="' . jpcrm_esc_link( 'create', -1, 'zerobs_invoice', false ) . $alsoCo . '" class="item"><i class="icon plus"></i> ' . esc_html__( 'Add New', 'zero-bs-crm' ) . '</a>'; |
| 425 | } |
| 426 | ?> |
| 427 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['manageinvoices'] ) ); ?>"><i class="icon list"></i> <?php esc_html_e( 'View all', 'zero-bs-crm' ); ?></a> |
| 428 | |
| 429 | <?php if ( zeroBSCRM_permsInvoices() ) { // TAGS ?> |
| 430 | <a class="item" href="<?php echo jpcrm_esc_link( 'tags', -1, ZBS_TYPE_INVOICE, false, 'invoice' ); ?>"><i class="icon tags"></i> <?php esc_html_e( 'Tags', 'zero-bs-crm' ); ?></a> |
| 431 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['export-tools'] ) ); ?>&zbstype=invoice"><i class="icon cloud download"></i> <?php esc_html_e( 'Export', 'zero-bs-crm' ); ?></a> |
| 432 | <?php } ?> |
| 433 | |
| 434 | <?php |
| 435 | // filter items (allows additions from ext etc.) |
| 436 | // for now empty (could contain the above) |
| 437 | $invoicesMenu = array(); |
| 438 | $invoicesMenu = apply_filters( 'zbs-invoices-menu', $invoicesMenu ); |
| 439 | if ( count( $invoicesMenu ) > 0 ) { |
| 440 | |
| 441 | // show divider? |
| 442 | ?> |
| 443 | <div class="ui divider"></div> |
| 444 | <?php |
| 445 | |
| 446 | foreach ( $invoicesMenu as $menuItem ) { |
| 447 | echo $menuItem; } |
| 448 | } |
| 449 | |
| 450 | ?> |
| 451 | </div> |
| 452 | </div> |
| 453 | <?php } ?> |
| 454 | |
| 455 | <?php |
| 456 | if ( zeroBSCRM_permsViewTransactions() && zeroBSCRM_getSetting( 'feat_transactions' ) > 0 ) { |
| 457 | $transactions_menu = array(); |
| 458 | ?> |
| 459 | <div class="ui simple dropdown item select<?php zeroBS_menu_active_type( 'transaction' ); ?>" id="zbs-transactions-topmenu" style="z-index:5"> |
| 460 | <span class="text"><?php esc_html_e( 'Transactions', 'zero-bs-crm' ); ?></span> |
| 461 | <i class="dropdown icon"></i> |
| 462 | <div class="menu ui"> |
| 463 | <?php |
| 464 | if ( zeroBSCRM_permsTransactions() ) { |
| 465 | echo ' <a href="' . jpcrm_esc_link( 'create', -1, 'zerobs_transaction', false ) . $alsoCo . '" class="item"><i class="icon plus"></i> ' . esc_html__( 'Add New', 'zero-bs-crm' ) . '</a>'; |
| 466 | } |
| 467 | ?> |
| 468 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['managetransactions'] ) ); ?>"><i class="icon list"></i> <?php esc_html_e( 'View all', 'zero-bs-crm' ); ?></a> |
| 469 | <?php |
| 470 | if ( zeroBSCRM_permsTransactions() ) { |
| 471 | ?> |
| 472 | <a class="item" href="<?php echo jpcrm_esc_link( 'tags', -1, 'zerobs_transaction', false, 'zerobscrm_transactiontag' ); ?>"><i class="icon tags"></i> <?php esc_html_e( 'Tags', 'zero-bs-crm' ); ?></a> |
| 473 | <?php |
| 474 | // If CSV Pro is installed and active it will add an Import menu item to the zbs-transactions-menu filter - we'll then add that here |
| 475 | $transactions_menu = apply_filters( 'zbs-transactions-menu', $transactions_menu ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 476 | $import_menu_item = preg_grep( '/\bpage\=zerobscrm\-csvimporter\-app\b/i', $transactions_menu ); |
| 477 | if ( count( $import_menu_item ) > 0 ) { |
| 478 | echo wp_kses( $import_menu_item[0], $zbs->acceptable_html ); |
| 479 | $transactions_menu = array_diff( $transactions_menu, $import_menu_item ); |
| 480 | } |
| 481 | ?> |
| 482 | <a class="item" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['export-tools'] ) ); ?>&zbstype=transaction"><i class="icon cloud download"></i> <?php esc_html_e( 'Export', 'zero-bs-crm' ); ?></a> |
| 483 | <?php } ?> |
| 484 | |
| 485 | <?php |
| 486 | |
| 487 | // Display remaining menu items added via the zbs-transactions-menu filter |
| 488 | if ( count( $transactions_menu ) > 0 ) { |
| 489 | // show divider? |
| 490 | ?> |
| 491 | <div class="ui divider"></div> |
| 492 | <?php |
| 493 | foreach ( $transactions_menu as $menu_item ) { |
| 494 | echo wp_kses( $menu_item, $zbs->acceptable_html ); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | ?> |
| 499 | </div> |
| 500 | </div> |
| 501 | <?php |
| 502 | } |
| 503 | |
| 504 | // tools menu added to mobile menu above, so collated at top now ^^ |
| 505 | |
| 506 | if ( count( $toolsMenu ) > 0 ) { |
| 507 | ?> |
| 508 | <div class="ui simple dropdown item" id="top-bar-tools-menu"> |
| 509 | <span class="text"><?php esc_html_e( 'Tools', 'zero-bs-crm' ); ?></span> |
| 510 | <i class="dropdown icon"></i> |
| 511 | <div class="menu ui"> |
| 512 | |
| 513 | <?php |
| 514 | foreach ( $toolsMenu as $menuItem ) { |
| 515 | echo $menuItem; } |
| 516 | ?> |
| 517 | |
| 518 | </div> |
| 519 | </div> |
| 520 | <?php |
| 521 | } |
| 522 | |
| 523 | ?> |
| 524 | |
| 525 | |
| 526 | </menu-section> |
| 527 | |
| 528 | <menu-section> |
| 529 | <?php |
| 530 | |
| 531 | do_action( 'zbs-crm-notify' ); |
| 532 | ?> |
| 533 | |
| 534 | <div class="ui simple dropdown item" id="jpcrm-user-menu-item"> |
| 535 | <span class="text"> |
| 536 | <?php |
| 537 | $uid = get_current_user_id(); |
| 538 | echo jpcrm_get_avatar( $uid, 30 ); |
| 539 | ?> |
| 540 | </span> |
| 541 | <i class="dropdown icon"></i> |
| 542 | </div> |
| 543 | |
| 544 | <?php |
| 545 | // } Build pop-out |
| 546 | |
| 547 | $popout_menu = array( |
| 548 | 'col1' => array(), |
| 549 | ##WLREMOVE |
| 550 | 'col2' => array(), |
| 551 | ##/WLREMOVE |
| 552 | 'col3' => array(), |
| 553 | ); |
| 554 | |
| 555 | // if admin, settings + datatools |
| 556 | if ( zeroBSCRM_isZBSAdminOrAdmin() ) { |
| 557 | $popout_menu['col1'][] = sprintf( |
| 558 | '<div class="jpcrm-user-menu-link"><a id="zbs-settings2-top-menu" href="%s" class="item"><i class="settings icon"></i> %s</a></div>', |
| 559 | zeroBSCRM_getAdminURL( $zbs->slugs['settings'] ), |
| 560 | __( 'Settings', 'zero-bs-crm' ) |
| 561 | ); |
| 562 | ##WLREMOVE |
| 563 | $popout_menu['col1'][] = sprintf( |
| 564 | '<div class="jpcrm-user-menu-link"><a id="zbs-datatools-top-menu" href="%s" class="item"><i class="wrench icon"></i> %s</a></div>', |
| 565 | zeroBSCRM_getAdminURL( $zbs->slugs['datatools'] ), |
| 566 | __( 'Data Tools', 'zero-bs-crm' ) |
| 567 | ); |
| 568 | ##/WLREMOVE |
| 569 | } |
| 570 | // teams page for WP Admin or Jetpack CRM Full Admin. |
| 571 | if ( current_user_can( 'manage_options' ) ) { |
| 572 | $popout_menu['col1'][] = sprintf( |
| 573 | '<div class="jpcrm-user-menu-link"><a id="zbs-team-top-menu" href="%s" class="item"><i class="icon users"></i> %s</a></div>', |
| 574 | zeroBSCRM_getAdminURL( $zbs->slugs['team'] ), |
| 575 | __( 'Team', 'zero-bs-crm' ) |
| 576 | ); |
| 577 | } |
| 578 | |
| 579 | // if admin, system status + extensions |
| 580 | if ( zeroBSCRM_isZBSAdminOrAdmin() ) { |
| 581 | $popout_menu['col1'][] = sprintf( |
| 582 | '<div class="jpcrm-user-menu-link"><a class="item" href="%s"><i class="server icon" aria-hidden="true"></i> %s</a></div>', |
| 583 | zeroBSCRM_getAdminURL( $zbs->slugs['systemstatus'] ), |
| 584 | __( 'System Assistant', 'zero-bs-crm' ) |
| 585 | ); |
| 586 | $popout_menu['col1'][] = sprintf( |
| 587 | '<div class="jpcrm-user-menu-link"><a class="item" href="%s"><i class="envelope icon" aria-hidden="true"></i> %s</a></div>', |
| 588 | zeroBSCRM_getAdminURL( $zbs->slugs['emails'] ), |
| 589 | __( 'Emails', 'zero-bs-crm' ) |
| 590 | ); |
| 591 | $popout_menu['col1'][] = sprintf( |
| 592 | '<div class="jpcrm-user-menu-link"><a class="item" href="%s"><i class="icon th" aria-hidden="true"></i> %s</a></div>', |
| 593 | zeroBSCRM_getAdminURL( $zbs->slugs['modules'] ), |
| 594 | __( 'Core Modules', 'zero-bs-crm' ) |
| 595 | ); |
| 596 | ##WLREMOVE |
| 597 | $popout_menu['col1'][] = sprintf( |
| 598 | '<div class="jpcrm-user-menu-link"><a class="item" href="%s"><i class="icon plug" aria-hidden="true"></i> %s</a></div>', |
| 599 | zeroBSCRM_getAdminURL( $zbs->slugs['extensions'] ), |
| 600 | __( 'Extensions', 'zero-bs-crm' ) |
| 601 | ); |
| 602 | ##/WLREMOVE |
| 603 | |
| 604 | } |
| 605 | |
| 606 | // remove the col if nothing in there |
| 607 | if ( count( $popout_menu['col1'] ) === 0 ) { |
| 608 | unset( $popout_menu['col1'] ); |
| 609 | } |
| 610 | |
| 611 | ?> |
| 612 | <div class="ui popup" id="jpcrm-user-menu"> |
| 613 | <?php |
| 614 | switch ( count( $popout_menu ) ) { |
| 615 | case 3: |
| 616 | $menu_style = 'three'; |
| 617 | break; |
| 618 | case 2: |
| 619 | $menu_style = 'two'; |
| 620 | break; |
| 621 | default: |
| 622 | $menu_style = 'one'; |
| 623 | } |
| 624 | ?> |
| 625 | <div class="ui <?php echo esc_attr( $menu_style ); ?> column equal height divided grid"> |
| 626 | <?php if ( isset( $popout_menu['col1'] ) && count( $popout_menu['col1'] ) > 0 ) { ?> |
| 627 | <div class="column"> |
| 628 | <h4 class="ui header"><?php esc_html_e( 'CRM Admin', 'zero-bs-crm' ); ?></h4> |
| 629 | <div class="ui link list"> |
| 630 | <?php |
| 631 | foreach ( $popout_menu['col1'] as $link ) { |
| 632 | echo $link; } |
| 633 | ?> |
| 634 | </div> |
| 635 | </div> |
| 636 | <?php |
| 637 | } |
| 638 | ##WLREMOVE |
| 639 | // no need for support column if white label |
| 640 | ?> |
| 641 | <div class="column"> |
| 642 | <h4 class="ui header"><?php esc_html_e( 'Support', 'zero-bs-crm' ); ?></h4> |
| 643 | <div class="ui link list"> |
| 644 | <div class="jpcrm-user-menu-link"> |
| 645 | <a href="<?php echo esc_url( $zbs->urls['docs'] ); ?>" class="item" target="_blank"><i class="file text outline icon"></i> <?php esc_html_e( 'Knowledge base', 'zero-bs-crm' ); ?></a> |
| 646 | </div> |
| 647 | <div class="jpcrm-user-menu-link"> |
| 648 | <a href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['support'] ) ); ?>" class="item"><i class="icon user md"></i> <?php esc_html_e( 'Support', 'zero-bs-crm' ); ?></a> |
| 649 | </div> |
| 650 | <div class="jpcrm-user-menu-link"> |
| 651 | <a href="<?php echo esc_url( $zbs->urls['twitter'] ); ?>" class="item" target="_blank"><i class="icon twitter"></i> <?php esc_html_e( '@jetpackcrm', 'zero-bs-crm' ); ?></a> |
| 652 | </div> |
| 653 | <div class="jpcrm-user-menu-link"> |
| 654 | <a class="item" href="<?php echo esc_url( $zbs->urls['rateuswporg'] ); ?>"><i class="star icon" aria-hidden="true"></i> <?php esc_html_e( 'Leave a review', 'zero-bs-crm' ); ?></a> |
| 655 | </div> |
| 656 | <?php |
| 657 | // welcome tour and crm resources page for admins :) |
| 658 | if ( zeroBSCRM_isZBSAdminOrAdmin() ) { |
| 659 | ?> |
| 660 | <div class="jpcrm-user-menu-link"> |
| 661 | <a id="zbs-tour-top-menu-dash" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['dash'] ) ); ?>&zbs-welcome-tour=1" class="item"><i class="icon magic"></i> <?php esc_html_e( 'Welcome Tour', 'zero-bs-crm' ); ?></a> |
| 662 | </div> |
| 663 | <div class="jpcrm-user-menu-link"> |
| 664 | <a id="crm-resources-top-menu-dash" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['crmresources'] ) ); ?>" class="item"><i class="icon building"></i> <?php esc_html_e( 'Resources', 'zero-bs-crm' ); ?></a> |
| 665 | </div> |
| 666 | <?php |
| 667 | } |
| 668 | ?> |
| 669 | </div> |
| 670 | </div> |
| 671 | <?php |
| 672 | ##/WLREMOVE |
| 673 | ?> |
| 674 | <div class="column"> |
| 675 | <h4 class="ui header"><?php echo esc_html( $currentUser->display_name ); ?></h4> |
| 676 | <div class="ui link list"> |
| 677 | |
| 678 | <div class="jpcrm-user-menu-link"> |
| 679 | <a id="zbs-profile-top-menu" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['your-profile'] ) ); ?>" class="item"><i class="icon user"></i> <?php esc_html_e( 'Your Profile', 'zero-bs-crm' ); ?></a> |
| 680 | </div> |
| 681 | |
| 682 | <?php |
| 683 | if ( zeroBSCRM_getSetting( 'feat_calendar' ) > 0 ) { |
| 684 | $cID = get_current_user_id(); |
| 685 | ?> |
| 686 | <div class="jpcrm-user-menu-link"> |
| 687 | <a id="jpcrm-tasks-top-menu" href="<?php echo esc_url( zeroBSCRM_getAdminURL( $zbs->slugs['manage-tasks'] ) ); ?>&zbsowner=<?php echo esc_attr( $cID ); // phpcs:ignore ?>" class="item"><i class="icon tasks"></i> <?php esc_html_e( 'Your Tasks', 'zero-bs-crm' ); ?></a> |
| 688 | </div> |
| 689 | <?php } ?> |
| 690 | |
| 691 | <?php |
| 692 | ##WLREMOVE //upsell |
| 693 | if ( ! zeroBSCRM_hasPaidExtensionActivated() && zeroBSCRM_isZBSAdminOrAdmin() ) { |
| 694 | ?> |
| 695 | |
| 696 | <div class="jpcrm-user-menu-link"> |
| 697 | <a class="item" href="<?php echo esc_url( $zbs->urls['pricing'] ); ?>" target="_blank"><i class="rocket icon" aria-hidden="true"></i> <?php esc_html_e( 'Plans', 'zero-bs-crm' ); ?></a> |
| 698 | </div> |
| 699 | <?php } ##/WLREMOVE ?> |
| 700 | |
| 701 | <div class="ui divider"></div> |
| 702 | |
| 703 | <div class="jpcrm-user-menu-link"> |
| 704 | <a href="<?php echo esc_url( wp_logout_url() ); ?>" class="item"><i class="icon sign out"></i> <?php esc_html_e( 'Log Out', 'zero-bs-crm' ); ?></a> |
| 705 | </div> |
| 706 | </div> |
| 707 | </div> |
| 708 | </div> |
| 709 | </div> |
| 710 | </menu-section> |
| 711 | </menu-bar><!-- end .menu-bar --> |
| 712 | |
| 713 | </div> |
| 714 | <?php |
| 715 | |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | // dumps out 'active' class if slug matches loaded page |
| 720 | // note 'active' seems to open drop downs, so now using: current_menu_item |
| 721 | function zeroBS_menu_active( $slug = '' ) { |
| 722 | |
| 723 | if ( ( isset( $_GET['page'] ) && $_GET['page'] == $slug ) || ( isset( $_GET['zbsslug'] ) && $_GET['zbsslug'] == $slug ) ) { |
| 724 | echo ' current_menu_item'; |
| 725 | } |
| 726 | } |
| 727 | // dumps out 'active' class if slug is within a 'section' |
| 728 | // note 'active' seems to open drop downs, so now using: current_menu_item |
| 729 | function zeroBS_menu_active_type( $type = '' ) { |
| 730 | |
| 731 | switch ( $type ) { |
| 732 | |
| 733 | case 'contact': |
| 734 | if ( zeroBSCRM_isAnyContactPage() ) { |
| 735 | echo ' current_menu_item'; |
| 736 | } |
| 737 | break; |
| 738 | case 'quote': |
| 739 | if ( zeroBSCRM_isAnyQuotePage() ) { |
| 740 | echo ' current_menu_item'; |
| 741 | } |
| 742 | break; |
| 743 | case 'invoice': |
| 744 | if ( zeroBSCRM_isAnyInvoicePage() ) { |
| 745 | echo ' current_menu_item'; |
| 746 | } |
| 747 | break; |
| 748 | case 'transaction': |
| 749 | if ( zeroBSCRM_isAnyTransactionPage() ) { |
| 750 | echo ' current_menu_item'; |
| 751 | } |
| 752 | break; |
| 753 | |
| 754 | } |
| 755 | } |