ddw_gftb_admin_bar_menu

Plugin's main function.

Description

ddw_gftb_admin_bar_menu(); 

Add new menu items to the WordPress Toolbar / Admin Bar.


Usage

  1. if ( !function_exists( 'ddw_gftb_admin_bar_menu' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-forms-toolbar/gravity-forms-toolbar.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ddw_gftb_admin_bar_menu(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/gravity-forms-toolbar.php  
  1. function ddw_gftb_admin_bar_menu() { 
  2.  
  3. global $wp_admin_bar; 
  4.  
  5. /** 
  6. * Allows for filtering the general user role/capability to display main & sub-level items 
  7. * Default capability: 'gravityforms_edit_forms' or 'gform_full_access' (set by Gravity Forms plugin itself!) 
  8. * @since 1.4.0 
  9. */ 
  10. $gftb_init_cap_check = current_user_can( 'gravityforms_edit_forms' ) ? 'gravityforms_edit_forms' : 'gform_full_access'; 
  11.  
  12. $gftb_filter_capability = apply_filters( 'gftb_filter_capability_all', $gftb_init_cap_check ); 
  13.  
  14. /** 
  15. * Required Gravity Forms/ WordPress cabability to display new admin bar entry 
  16. * Only showing items if toolbar / admin bar is activated and user is logged in! 
  17. * @since 1.3.0 
  18. */ 
  19. if ( ! is_user_logged_in() 
  20. || ! is_admin_bar_showing() 
  21. || ! current_user_can( esc_attr( $gftb_filter_capability ) ) // allows for custom filtering the required role/capability 
  22. || ( defined( 'GFTB_DISPLAY' ) && ! GFTB_DISPLAY ) // allows for custom disabling 
  23. ) { 
  24.  
  25. return; 
  26.  
  27. } // end if 
  28.  
  29. /** Defaults for plugin's options */ 
  30. $options = ddw_gftb_get_options(); 
  31.  
  32. if ( ( is_admin() && ! $options[ 'toolbar_admin' ] ) 
  33. || ( ! is_admin() && ! $options[ 'toolbar_frontend' ] ) 
  34. ) { 
  35.  
  36. return; 
  37.  
  38. } // end if 
  39.  
  40. $update = $options[ 'update_notification' ] ? ddw_gftb_update_available() : false; 
  41.  
  42. $forms = array(); 
  43. $count = 0; 
  44.  
  45. if ( class_exists( 'RGForms' ) 
  46. && $options[ 'forms_details' ] 
  47. && ( current_user_can( 'gform_full_access' ) || current_user_can( 'gravityforms_edit_forms' ) ) 
  48.  
  49. ) { 
  50.  
  51. $forms = RGFormsModel::get_form_summary(); 
  52.  
  53.  
  54. /** Set unique prefix */ 
  55. $prefix = 'ddw-gravityforms-'; 
  56.  
  57. /** Create parent menu item references */ 
  58. $gravitybar = $prefix . 'toolbar'; // root level 
  59. $gfsupport = $prefix . 'gfsupport'; // sub level: support 
  60. $gfdocs = $prefix . 'gfdocs'; // sub level: documentation 
  61. $gffaq = $prefix . 'gffaq'; // sub level: faq 
  62. $gfsites = $prefix . 'gfsites'; // sub level: gf websites 
  63. $gfsettings = $prefix . 'gfsettings'; // sub level: main settings 
  64. $gfsubsettings = $prefix . 'gfsubsettings'; // third level: sub main settings 
  65. $gfforms = $prefix . 'gfforms'; // sub level: forms 
  66. $gfformlist = $prefix . 'gfformlist'; // third level: forms listing 
  67. $gfentries = $prefix . 'gfentries'; // sub level: entries 
  68. $gftpaogfstyler = $prefix . 'gftpaogfstyler'; // sub level third-party add-on: gravity forms styler 
  69. $gfimportexport = $prefix . 'gfimportexport'; // sub level: import/export 
  70. $gfaddonsinstalled = $prefix . 'gfaddonsinstalled'; // sub level: add-ons (dummy) 
  71. $gfaoauthorizenet = $prefix . 'gfaoauthorizenet'; // third level add-on: authorize.net 
  72. $gfaoaweber = $prefix . 'gfaoaweber'; // third level add-on: aweber 
  73. $gfaocampaignmonitor = $prefix . 'gfaocampaignmonitor'; // third level add-on: campaign monitor 
  74. $gfaocoupons = $prefix . 'gfaocoupons'; // third level add-on: coupons 
  75. $gfaofreshbooks = $prefix . 'gfaofreshbooks'; // third level add-on: freshbooks 
  76. $gfaomailchimp = $prefix . 'gfaomailchimp'; // third level add-on: mailchimp 
  77. $gfaopaypal = $prefix . 'gfaopaypal'; // third level add-on: payal 
  78. $gfaopaypalpaymentspro = $prefix . 'gfaopaypalpaymentspro'; // third level add-on: payal payments pro 
  79. $gfaopaypalpro = $prefix . 'gfaopaypalpro'; // third level add-on: payal pro 
  80. $gfaotwilio = $prefix . 'gfaotwilio'; // third level add-on: twilio 
  81. $gfaouserreg = $prefix . 'gfaouserreg'; // third level add-on: user reg. 
  82. $gftpaopideal = $prefix . 'gftpaopideal'; // third level third-party add-on: pronamic ideal 
  83. $gftpaostripe = $prefix . 'gftpaostripe'; // third level third-party add-on: stripe 
  84. $gftpaowysija = $prefix . 'gftpaowysija'; // third level third-party add-on: mp/wysija 
  85. $gftpaoshootq = $prefix . 'gftpaoshootq'; // third level third-party add-on: shootq 
  86. $gftpaoconstantcontact = $prefix . 'gftpaoconstantcontact'; // third level third-party add-on: constant contact 
  87. $gftpaoicontact = $prefix . 'gftpaoicontact'; // third level third-party add-on: icontact 
  88. $gftpaomadmimi = $prefix . 'gftpaomadmimi'; // third level third-party add-on: madmimi 
  89. $gftpaoexacttarget = $prefix . 'gftpaoexacttarget'; // third level third-party add-on: exacttarget 
  90. $gftpaoinfusionsoft = $prefix . 'gftpaoinfusionsoft'; // third level third-party add-on: infusionsoft 
  91. $gftpaoymlp = $prefix . 'gftpaoymlp'; // third level third-party add-on: ymlp 
  92. $gftpaodpspxpay = $prefix . 'gftpaodpspxpay'; // third level third-party add-on: dpspx pay 
  93. $gftpaoqlimit = $prefix . 'gftpaoqlimit'; // third level third-party add-on: quantity limit 
  94. $gftpaobluepay = $prefix . 'gftpaobluepay'; // third level third-party add-on: bluepay 
  95. $gftpaopaystation = $prefix . 'gftpaopaystation'; // third level third-party add-on: paystation 
  96. $gftpaogffdgg = $prefix . 'gftpaogffdgg'; // third level third-party add-on: first data 
  97. $gftpaomarketo = $prefix . 'gftpaomarketo'; // third level third-party add-on: marketo 
  98. $gftpaohighrisecrm = $prefix . 'gftpaohighrisecrm'; // third level third-party add-on: highrise crm 
  99. $gftpaoconvio = $prefix . 'gftpaoconvio'; // third level third-party add-on: convio 
  100. $gftpaohighrisekatz = $prefix . 'gftpaohighrisekatz'; // third level third-party add-on: highrise 
  101. $gftpaogfperiodicmails = $prefix . 'gftpaogfperiodicmails'; // third level third-party add-on: periodic 
  102. $gfextensions = $prefix . 'gfextensions'; // sub level: extensions group 
  103. $extensions = $prefix . 'extensions'; // sub level: extensions (very last main entry) 
  104. $extpideal = $prefix . 'extpideal'; // third level third-party add-on: pronamic ideal 
  105. $extpidealpayments = $prefix . 'extpidealpayments'; // fourth level: ideal payments 
  106. $extpidealconfigurations = $prefix . 'extpidealconfigurations'; // fourth level: ideal configs 
  107. $extgfsolve360 = $prefix . 'extgfsolve360'; // third level third-party add-on: solve360 
  108. $gftpaogravityperks = $prefix . 'gftpaogravityperks'; // third level third-party add-on: gravity perks 
  109. $gfperksgroup = $prefix . 'gfperksgroup'; // third level third-party add-on: gravity perks group 
  110. $gfgroup = $prefix . 'gfgroup'; // sub level: gf group (resources) 
  111.  
  112.  
  113. /** Display these items also when Gravity Forms plugin is not installed */ 
  114. $menu_items = array(); 
  115.  
  116. /** Display items depending on plugin setting */ 
  117. if ( $options[ 'help_and_support' ] && ( defined( 'GFTB_RESOURCES_DISPLAY' ) && GFTB_RESOURCES_DISPLAY ) ) { 
  118.  
  119. /** Include plugin file with resources links */ 
  120. require_once( GFTB_PLUGIN_DIR . 'lib/gftb-resources.php' ); 
  121.  
  122. } // end if help & support items 
  123.  
  124.  
  125. /** 
  126. * Display these support links only for users who can view Gravity Forms Settings. 
  127. * Hook in as children of "Support" entry. 
  128. * @since 1.1.0 
  129. */ 
  130. if ( current_user_can( 'gravityforms_view_settings' ) || current_user_can( 'gform_full_access' ) ) { 
  131.  
  132. /** Support at Gravity Help */ 
  133. $menu_items[ 'gfregular' ] = array( 
  134. 'parent' => $gfsupport,  
  135. 'title' => __( 'Request Support', 'gravity-forms-toolbar' ),  
  136. 'href' => 'http://www.gravityhelp.com/request-support/',  
  137. 'meta' => array( 'title' => __( 'Request Support', 'gravity-forms-toolbar' ) ) 
  138. ); 
  139.  
  140. /** Priority support at Gravity Help */ 
  141. $menu_items[ 'gfpriority' ] = array( 
  142. 'parent' => $gfsupport,  
  143. 'title' => __( 'Priority Support (Dev License Only)', 'gravity-forms-toolbar' ),  
  144. 'href' => 'http://www.gravityhelp.com/priority-support/',  
  145. 'meta' => array( 'title' => __( 'Priority Support (Dev License Only)', 'gravity-forms-toolbar' ) ) 
  146. ); 
  147.  
  148. /** User profile at Gravity Help */ 
  149. $menu_items[ 'gfuprofile' ] = array( 
  150. 'parent' => $gfsupport,  
  151. 'title' => __( 'Your User Profile at Gravity Help', 'gravity-forms-toolbar' ),  
  152. 'href' => 'http://www.gravityhelp.com/forums/profile/',  
  153. 'meta' => array( 'title' => __( 'Your User Profile at Gravity Help', 'gravity-forms-toolbar' ) ) 
  154. ); 
  155.  
  156. } // end if children of support entry 
  157.  
  158.  
  159. /** Include plugin file with language specific items/ links */ 
  160. if ( ! ddw_gftb_detect_locales( array( 'en_US', 'en_GB', 'en_CA', 'en_NZ', 'en_AU' ) ) ) { 
  161.  
  162. require_once( GFTB_PLUGIN_DIR . 'lib/gftb-languages.php' ); 
  163.  
  164. } // end if 
  165.  
  166.  
  167. /** Show these items only if Gravity Forms main plugin is actually installed */ 
  168. if ( class_exists( 'RGForms' ) ) { 
  169.  
  170. /** Main Settings */ 
  171. if ( current_user_can( 'gravityforms_view_settings' ) || current_user_can( 'gform_full_access' ) ) { 
  172.  
  173. $menu_items[ 'gfsettings' ] = array( 
  174. 'parent' => $gravitybar,  
  175. 'title' => __( 'Plugin Settings', 'gravity-forms-toolbar' ),  
  176. 'href' => admin_url( 'admin.php?page=gf_settings' ),  
  177. 'meta' => array( 
  178. 'target' => '',  
  179. 'title' => _x( 'Plugin Settings', 'Translators: For the tooltip', 'gravity-forms-toolbar' ) 
  180. ); 
  181.  
  182. $menu_items[ 'gfs-toolbar' ] = array( 
  183. 'parent' => $gfsettings,  
  184. 'title' => __( 'Toolbar Menu', 'gravity-forms-toolbar' ),  
  185. 'href' => admin_url( 'options-general.php?page=ddw_gftb_options_page' ),  
  186. 'meta' => array( 
  187. 'target' => '',  
  188. 'title' => _x( 'Toolbar Menu', 'Translators: For the tooltip', 'gravity-forms-toolbar' ) 
  189. ); 
  190.  
  191. $menu_items[ 'gfs-widgets' ] = array( 
  192. 'parent' => $gfsettings,  
  193. 'title' => __( 'Manage Widgets', 'gravity-forms-toolbar' ),  
  194. 'href' => admin_url( 'widgets.php' ),  
  195. 'meta' => array( 
  196. 'target' => '',  
  197. 'title' => __( 'Manage Widgets', 'gravity-forms-toolbar' ) 
  198. ); 
  199.  
  200. /** Check for "Members" plugin + appropiate capabilities, then display settings if activated */ 
  201. if ( ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'members/members.php' ) ) 
  202. && current_user_can( 'edit_roles' ) 
  203. ) { 
  204.  
  205. $menu_items[ 'gfs-pmembers' ] = array( 
  206. 'parent' => $gfsettings,  
  207. 'title' => __( 'Adjust User Roles & Capabilities (Plugin: Members)', 'gravity-forms-toolbar' ),  
  208. 'href' => admin_url( 'users.php?page=roles' ),  
  209. 'meta' => array( 
  210. 'target' => '',  
  211. 'title' => __( 'Adjust User Roles & Capabilities (Plugin: Members)', 'gravity-forms-toolbar' ) 
  212. ); 
  213.  
  214. } // end if members plugin check 
  215.  
  216. /** Get translated API string */ 
  217. $gftb_api_string_l10n = ddw_gftb_l10n_global_string_output( 'Gravity Forms API Settings' ); 
  218. $gftb_api_string = ( ! empty( $gftb_api_string_l10n ) ) ? str_replace( ' ', '+', $gftb_api_string_l10n ) : 'Gravity+Forms+API+Settings'; 
  219.  
  220. /** API Setting */ 
  221. $menu_items[ 'gfs-gfapi' ] = array( 
  222. 'parent' => $gfsubsettings,  
  223. 'title' => __( 'API Configuration', 'gravity-forms-toolbar' ),  
  224. 'href' => admin_url( 'admin.php?page=gf_settings&subview=' ) . $gftb_api_string,  
  225. 'meta' => array( 
  226. 'target' => '',  
  227. 'title' => __( 'API Configuration', 'gravity-forms-toolbar' ) 
  228. ); 
  229.  
  230. /** Uninstall setting */ 
  231. $menu_items[ 'gfs-uninstall' ] = array( 
  232. 'parent' => $gfsubsettings,  
  233. 'title' => __( 'Uninstall', 'gravity-forms-toolbar' ),  
  234. 'href' => admin_url( 'admin.php?page=gf_settings&subview=uninstall' ),  
  235. 'meta' => array( 
  236. 'target' => '',  
  237. 'title' => __( 'Uninstall', 'gravity-forms-toolbar' ) 
  238. ); 
  239.  
  240. } // end if main settings 
  241.  
  242. /** Edit Forms */ 
  243. if ( current_user_can( 'gravityforms_edit_forms' ) || current_user_can( 'gform_full_access' ) ) { 
  244.  
  245. $menu_items[ 'gfforms' ] = array( 
  246. 'parent' => $gravitybar,  
  247. 'title' => __( 'Edit Forms', 'gravity-forms-toolbar' ),  
  248. 'href' => admin_url( 'admin.php?page=gf_edit_forms' ),  
  249. 'meta' => array( 
  250. 'target' => '',  
  251. 'title' => __( 'Edit Forms', 'gravity-forms-toolbar' ) 
  252. ); 
  253.  
  254. } // end if 
  255.  
  256. /** Add New Forms */ 
  257. if ( current_user_can( 'gravityforms_create_form' ) || current_user_can( 'gform_full_access' ) ) { 
  258.  
  259. $menu_items[ 'gff-add-form' ] = array( 
  260. 'parent' => $gfforms,  
  261. 'title' => __( 'Add new Form', 'gravity-forms-toolbar' ),  
  262. 'href' => admin_url( 'admin.php?page=gf_new_form' ),  
  263. 'meta' => array( 
  264. 'target' => '',  
  265. 'title' => __( 'Add new Form', 'gravity-forms-toolbar' ) 
  266. ); 
  267.  
  268. } // end if 
  269.  
  270. /** 
  271. * Dynamically add existing Forms and/or Entries at their sub-levels 
  272. * @since 1.2.0 
  273. */ 
  274. if ( ! empty( $forms ) ) { 
  275.  
  276. $class_first = 'ddw_gftb-first-form'; 
  277.  
  278. foreach ( $forms as $form ) { 
  279.  
  280. $view_title = $form[ 'title' ]; 
  281.  
  282. if ( $form[ 'unread_count' ] > 0 ) { 
  283.  
  284. $count+= $form[ 'unread_count' ]; 
  285. $view_title .= ' (' . $form[ 'unread_count' ] . ')'; 
  286.  
  287. } // end if 
  288.  
  289. /** Hook in existing Forms at "Form" entry */ 
  290. $menu_items[ 'gff-edit-form-' . $form[ 'id' ] ] = array( 
  291. 'parent' => $gfformlist,  
  292. 'title' => $form[ 'title' ],  
  293. 'href' => admin_url( 'admin.php?page=gf_edit_forms&id=' . $form[ 'id' ] ),  
  294. 'meta' => array( 
  295. 'class' => $class_first,  
  296. 'target' => '',  
  297. 'title' => $form[ 'title' ] 
  298. ); 
  299.  
  300. /** Hook in existing Form Entries at "Entries" entry */ 
  301. $menu_items[ 'gff-view-form-entries-' . $form[ 'id' ] ] = array( 
  302. 'parent' => $gfentries,  
  303. 'title' => $view_title,  
  304. 'href' => admin_url( 'admin.php?page=gf_entries&view=entries&id=' . $form[ 'id' ] ),  
  305. 'meta' => array( 
  306. 'class' => $class_first,  
  307. 'target' => '',  
  308. 'title' => $form['title'] 
  309. ); 
  310.  
  311. $class_first = ''; 
  312.  
  313. } // end foreach 
  314.  
  315. } // end if !empty forms 
  316.  
  317.  
  318. /** View Entries */ 
  319. if ( current_user_can( 'gravityforms_view_entries' ) || current_user_can( 'gform_full_access' ) ) { 
  320.  
  321. $menu_items[ 'gfentries' ] = array( 
  322. 'parent' => $gravitybar,  
  323. 'title' => __( 'View Entries', 'gravity-forms-toolbar' ),  
  324. 'href' => admin_url( 'admin.php?page=gf_entries' ),  
  325. 'meta' => array( 
  326. 'target' => '',  
  327. 'title' => __( 'View Entries', 'gravity-forms-toolbar' ) 
  328. ); 
  329.  
  330. } // end if view entries 
  331.  
  332.  
  333. /** 
  334. * Gravity Forms Styler (premium, by WordPress Gurus) 
  335. * @since 1.6.1 
  336. */ 
  337. if ( class_exists( 'Gravity_Forms_Styler' ) ) { 
  338.  
  339. /** Include code part for Gravity Forms Styler plugin support */ 
  340. require_once( GFTB_PLUGIN_DIR . 'lib/gftb-plugins-gravityformsstyler.php' ); 
  341.  
  342. } // end if GF Styler 
  343.  
  344.  
  345. /** Import & Export stuff */ 
  346. if ( current_user_can( 'gravityforms_export_entries' ) || current_user_can( 'gform_full_access' ) ) { 
  347.  
  348. $menu_items[ 'gfimportexport' ] = array( 
  349. 'parent' => $gravitybar,  
  350. 'title' => __( 'Import & Export', 'gravity-forms-toolbar' ),  
  351. 'href' => admin_url( 'admin.php?page=gf_export' ),  
  352. 'meta' => array( 
  353. 'target' => '',  
  354. 'title' => __( 'Import & Export', 'gravity-forms-toolbar' ) 
  355. ); 
  356.  
  357. $menu_items[ 'gfie-entries-export' ] = array( 
  358. 'parent' => $gfimportexport,  
  359. 'title' => __( 'Export Entries', 'gravity-forms-toolbar' ),  
  360. 'href' => admin_url( 'admin.php?page=gf_export&view=export_entry' ),  
  361. 'meta' => array( 
  362. 'target' => '',  
  363. 'title' => __( 'Export Entries', 'gravity-forms-toolbar' ) 
  364. ); 
  365.  
  366. $menu_items[ 'gfie-forms-export' ] = array( 
  367. 'parent' => $gfimportexport,  
  368. 'title' => __( 'Export Forms', 'gravity-forms-toolbar' ),  
  369. 'href' => admin_url( 'admin.php?page=gf_export&view=export_form' ),  
  370. 'meta' => array( 
  371. 'target' => '',  
  372. 'title' => __( 'Export Forms', 'gravity-forms-toolbar' ) 
  373. ); 
  374.  
  375. $menu_items[ 'gfie-forms-import' ] = array( 
  376. 'parent' => $gfimportexport,  
  377. 'title' => __( 'Import Forms', 'gravity-forms-toolbar' ),  
  378. 'href' => admin_url( 'admin.php?page=gf_export&view=import_form' ),  
  379. 'meta' => array( 
  380. 'target' => '',  
  381. 'title' => __( 'Import Forms', 'gravity-forms-toolbar' ) 
  382. ); 
  383.  
  384. } // end if import/export 
  385.  
  386.  
  387. /** Official Add-Ons */ 
  388. if ( $options[ 'add_ons' ] && ( defined( 'GFTB_ADDONS_DISPLAY' ) && GFTB_ADDONS_DISPLAY ) ) { 
  389.  
  390. /** Include plugin file with add-on support links */ 
  391. require_once( GFTB_PLUGIN_DIR . 'lib/gftb-addons.php' ); 
  392.  
  393. } // end of Add-On level entry - back to more main level entries: 
  394.  
  395.  
  396. /** 
  397. * Gravity Perks (premium, by David Smith/ gravitywiz.com) 
  398. * @since 1.6.0 
  399. */ 
  400. if ( class_exists( 'GWPerks' ) ) { 
  401.  
  402. /** Include code part for Gravity Perks plugin support */ 
  403. require_once( GFTB_PLUGIN_DIR . 'lib/gftb-plugins-gravityperks.php' ); 
  404.  
  405. } // end if Gravity Perks 
  406.  
  407.  
  408. /** Updates */ 
  409. if ( current_user_can( 'gravityforms_view_updates' ) || current_user_can( 'gform_full_access' ) ) { 
  410.  
  411. $update_title = $update ? __( 'Update Is Available', 'gravity-forms-toolbar' ) : __( 'Check for Update', 'gravity-forms-toolbar' ); 
  412. $update_class = $update ? 'ddw_gftb-update-available' : ''; 
  413.  
  414. $menu_items[ 'gfupdates' ] = array( 
  415. 'parent' => $gravitybar,  
  416. 'title' => $update_title,  
  417. 'href' => admin_url( 'admin.php?page=gf_update' ),  
  418. 'meta' => array( 
  419. 'class' => $update_class,  
  420. 'target' => '',  
  421. 'title' => $update_title 
  422. ); 
  423.  
  424. } // end if updates 
  425.  
  426.  
  427. /** Help (for all capabalities) */ 
  428. $menu_items[ 'gfhelp' ] = array( 
  429. 'parent' => $gravitybar,  
  430. 'title' => __( 'Help & Links', 'gravity-forms-toolbar' ),  
  431. 'href' => admin_url( 'admin.php?page=gf_help' ),  
  432. 'meta' => array( 
  433. 'target' => '',  
  434. 'title' => __( 'Help & Links', 'gravity-forms-toolbar' ) 
  435. ); 
  436.  
  437.  
  438. /** 
  439. * Display last main item in the menu for active extensions/plugins 
  440. * ATTENTION: This is where plugins/extensions hook in on the sub-level hierarchy 
  441. * @since 1.0.0 
  442. */  
  443. if ( $options[ 'extensions' ] && ( defined( 'GFTB_EXTENSIONS_DISPLAY' ) && GFTB_EXTENSIONS_DISPLAY ) ) { 
  444.  
  445. $menu_items[ 'extensions' ] = array( 
  446. 'parent' => $gfextensions,  
  447. 'title' => __( 'Active Extensions', 'gravity-forms-toolbar' ),  
  448. 'href' => is_network_admin() ? network_admin_url( 'plugins.php' ) : admin_url( 'plugins.php' ),  
  449. 'meta' => array( 
  450. 'target' => '',  
  451. 'title' => __( 'Active Extensions', 'gravity-forms-toolbar' ) 
  452. ); 
  453.  
  454. } // end if extensions 
  455.  
  456. /** 
  457. * Action Hook 'gftb_custom_extension_items' 
  458. * allows for hooking other extension-related items in 
  459. * @since 1.4.0 
  460. */ 
  461.  
  462. } else { 
  463.  
  464. /** If Gravity Forms is not active, to avoid PHP notices */ 
  465. $menu_items = $gfgroup_menu_items; 
  466.  
  467. /** If Gravity Forms is not active and no icon filter is active, then display no icon */ 
  468. if ( ! has_filter( 'gftb_filter_main_icon' ) ) { 
  469.  
  470.  
  471.  
  472. } // end if Gravity Forms conditional (if it is active!) 
  473.  
  474.  
  475. /** 
  476. * Display links to active plugins/extensions settings' pages 
  477. * @since 1.0.0 
  478. */ 
  479. /** Include plugin file with plugin support links */ 
  480. require_once( GFTB_PLUGIN_DIR . 'lib/gftb-plugins.php' ); 
  481.  
  482.  
  483. /** Allow menu items to be filtered, but pass in parent menu item IDs */ 
  484. $menu_items = (array) apply_filters( 'ddw_gftb_menu_items', $menu_items,  
  485. $prefix,  
  486. $gravitybar,  
  487. $gfsupport,  
  488. $gfdocs,  
  489. $gffaq,  
  490. $gfsites,  
  491. $gfsettings,  
  492. $gfsubsettings,  
  493. $gfforms,  
  494. $gfformlist,  
  495. $gfentries,  
  496. $gfimportexport,  
  497. $gfaddonsinstalled,  
  498. $gfaoauthorizenet,  
  499. $gfaoaweber,  
  500. $gfaocampaignmonitor,  
  501. $gfaocoupons,  
  502. $gfaofreshbooks,  
  503. $gfaomailchimp,  
  504. $gfaopaypal,  
  505. $gfaopaypalpaymentspro,  
  506. $gfaopaypalpro,  
  507. $gfaotwilio,  
  508. $gfaouserreg,  
  509. $gftpaopideal,  
  510. $gftpaostripe,  
  511. $gftpaowysija,  
  512. $gftpaoshootq,  
  513. $gftpaoconstantcontact,  
  514. $gftpaoicontact,  
  515. $gftpaomadmimi,  
  516. $gftpaoexacttarget,  
  517. $gftpaoinfusionsoft,  
  518. $gftpaoymlp,  
  519. $gftpaodpspxpay,  
  520. $gftpaoqlimit,  
  521. $gftpaobluepay,  
  522. $gftpaopaystation,  
  523. $gftpaogffdgg,  
  524. $gftpaomarketo,  
  525. $gftpaohighrisecrm,  
  526. $gftpaoconvio,  
  527. $gftpaohighrisekatz,  
  528. $gftpaogfperiodicmails,  
  529. $gfextensions,  
  530. $extensions,  
  531. $extpideal,  
  532. $extpidealpayments,  
  533. $extpidealconfigurations,  
  534. $extgfsolve360,  
  535. $gftpaogravityperks,  
  536. $gftpaogfstyler,  
  537. $gfgroup 
  538. ); // end of array 
  539.  
  540.  
  541. /** 
  542. * Top level title, unread entries count display/styling, plus update info/check 
  543. * @since 1.0.0 
  544. */ 
  545. /** Main item menu title */ 
  546. $menu_item_title = apply_filters( 
  547. 'gftb_filter_main_item',  
  548. __( 'Gravity Forms', 'gravity-forms-toolbar' ) 
  549. ); 
  550.  
  551. /** Filter the main item name's tooltip */ 
  552. $gftb_main_item_title_tooltip = apply_filters( 
  553. 'gftb_filter_main_item_tooltip',  
  554. _x( 'Gravity Forms', 'Translators: Main item - for the tooltip', 'gravity-forms-toolbar' ) 
  555. ); 
  556.  
  557. /** Filter the main item icon's class/display */ 
  558. $gftb_main_item_icon_display = apply_filters( 
  559. 'gftb_filter_main_item_icon_display', 'icon-gravityforms' 
  560. ); 
  561.  
  562. /** CSS styling */ 
  563. $css = 'background: none repeat scroll 0 0 #EEEEEE; border-radius: 10px 10px 10px 10px; color: #333333; display: inline; font-size: 10px; font-weight: bold; padding: 2px 5px; text-shadow: none;'; 
  564.  
  565. /** Menu URL */ 
  566. $menu_item_url = defined( 'GF_MIN_WP_VERSION' ) ? admin_url( 'admin.php?page=gf_edit_forms' ) : FALSE; 
  567.  
  568. /** Logic for unread entries */ 
  569. if ( $options[ 'unread_notification' ] && $count > 0 ) { 
  570.  
  571. $to_add = sprintf( ' <span style="%s">%s</span>', $css, $count ); 
  572. $menu_item_title .= '<span title="' . __( 'Unread Entries', 'gravity-forms-toolbar' ) . '">' . $to_add . '</span>'; 
  573.  
  574. } // end if 
  575.  
  576. /** Logic for updates */ 
  577. if ( $update ) { 
  578.  
  579. $to_add = sprintf( ' <span style="%s">U</span>', $css ); 
  580. $menu_item_title .= '<span title="' . __( 'Update Is Available', 'gravity-forms-toolbar' ) . '">' . $to_add . '</span>'; 
  581. $menu_item_url = admin_url( 'admin.php?page=gf_update' ); 
  582.  
  583. } // end if 
  584.  
  585. /** Add the Gravity Forms top-level menu item */ 
  586. $wp_admin_bar->add_node( array( 
  587. 'id' => $gravitybar,  
  588. 'title' => $menu_item_title,  
  589. 'href' => $menu_item_url,  
  590. 'meta' => array( 
  591. 'class' => esc_attr( $gftb_main_item_icon_display ),  
  592. 'title' => esc_attr__( $gftb_main_item_title_tooltip ) 
  593. ) ); 
  594.  
  595.  
  596. /** Loop through the (main) menu items */ 
  597. foreach ( $menu_items as $id => $menu_item ) { 
  598.  
  599. /** Add in the item ID */ 
  600. $menu_item[ 'id' ] = $prefix . $id; 
  601.  
  602. /** Add meta target to each item where it's not already set, so links open in new window/tab */ 
  603. if ( ! isset( $menu_item[ 'meta' ][ 'target' ] ) ) { 
  604.  
  605. $menu_item[ 'meta' ][ 'target' ] = '_blank'; 
  606.  
  607. } // end if 
  608.  
  609. /** Add class to links that open up in a new window/tab */ 
  610. if ( '_blank' === $menu_item[ 'meta' ][ 'target' ] ) { 
  611.  
  612. if ( ! isset( $menu_item[ 'meta' ][ 'class' ] ) ) { 
  613.  
  614. $menu_item[ 'meta' ][ 'class' ] = ''; 
  615.  
  616. } // end if 
  617.  
  618. $menu_item[ 'meta' ][ 'class' ] .= $prefix . 'gftb-new-tab'; 
  619.  
  620. } // end if 
  621.  
  622. /** Add menu items */ 
  623. $wp_admin_bar->add_node( $menu_item ); 
  624.  
  625. } // end foreach 
  626.  
  627.  
  628. /** 
  629. * Add sub group for Gravity Forms settings 
  630. * @since 1.6.0 
  631. */ 
  632. $wp_admin_bar->add_group( array( 
  633. 'parent' => $gfsettings,  
  634. 'id' => $gfsubsettings 
  635. ) ); 
  636.  
  637.  
  638. /** 
  639. * Add sub group for Gravity Perks Add-On 
  640. * @since 1.6.0 
  641. */ 
  642. $wp_admin_bar->add_group( array( 
  643. 'parent' => $gftpaogravityperks,  
  644. 'id' => $gfperksgroup 
  645. ) ); 
  646.  
  647.  
  648. /** 
  649. * Action Hook 'gftb_custom_main_items' 
  650. * allows for hooking other main items in 
  651. * @since 1.4.0 
  652. */ 
  653. do_action( 'gftb_custom_main_items' ); 
  654.  
  655.  
  656. /** 
  657. * Add sub group for Extension Plugins. 
  658. * @since 1.6.0 
  659. */ 
  660. $wp_admin_bar->add_group( array( 
  661. 'parent' => $gravitybar,  
  662. 'id' => $gfextensions 
  663. ) ); 
  664.  
  665.  
  666. /** 
  667. * Add sub group for forms listings. 
  668. * @since 1.6.0 
  669. */ 
  670. $wp_admin_bar->add_group( array( 
  671. 'parent' => $gfforms,  
  672. 'id' => $gfformlist,  
  673. 'meta' => array( 'class' => 'ab-sub-secondary' ) 
  674. ) ); 
  675.  
  676.  
  677. /** 
  678. * Add resource links group. 
  679. * @since 1.3.0 
  680. */ 
  681. $wp_admin_bar->add_group( array( 
  682. 'parent' => $gravitybar,  
  683. 'id' => $gfgroup,  
  684. 'meta' => array( 'class' => 'ab-sub-secondary' ) 
  685. ) ); 
  686.  
  687.  
  688. /** Gravity Forms Group: Loop through the resources group menu items */ 
  689. foreach ( $gfgroup_menu_items as $id => $gfgroup_menu_item ) { 
  690.  
  691. /** Gravity Forms Group: Add in the item ID */ 
  692. $gfgroup_menu_item[ 'id' ] = $prefix . $id; 
  693.  
  694. /** 
  695. * Gravity Forms Group: Add meta target to each item where it's not 
  696. * already set, so links open in new window/tab 
  697. */ 
  698. if ( ! isset( $gfgroup_menu_item[ 'meta' ][ 'target' ] ) ) { 
  699.  
  700. $gfgroup_menu_item[ 'meta' ][ 'target' ] = '_blank'; 
  701.  
  702. } // end if 
  703.  
  704. /** Gravity Forms Group: Add class to links that open up in a new window/tab */ 
  705. if ( '_blank' === $gfgroup_menu_item[ 'meta' ][ 'target' ] ) { 
  706.  
  707. if ( ! isset( $gfgroup_menu_item[ 'meta' ][ 'class' ] ) ) { 
  708.  
  709. $gfgroup_menu_item[ 'meta' ][ 'class' ] = ''; 
  710.  
  711. } // end if 
  712.  
  713. $gfgroup_menu_item[ 'meta' ][ 'class' ] .= $prefix . 'gftb-new-tab'; 
  714.  
  715. } // end if 
  716.  
  717. /** Gravity Forms Group: Add menu items */ 
  718. $wp_admin_bar->add_node( $gfgroup_menu_item ); 
  719.  
  720. } // end foreach Gravity Forms Group 
  721.  
  722.  
  723. /** 
  724. * Action Hook 'gftb_custom_group_items' 
  725. * allows for hooking other Gravity Forms Group items in 
  726. * @since 1.4.0 
  727. */ 
  728. do_action( 'gftb_custom_group_items' ); 
  729.  
  730. } // end of main function