diff --git a/inc/admin-bar.php b/inc/admin-bar.php index 24be38087..079262f01 100644 --- a/inc/admin-bar.php +++ b/inc/admin-bar.php @@ -87,6 +87,23 @@ function spbc_admin__admin_bar__add_structure($wp_admin_bar) )); } + /** + * Link to project manager + */ + $project_manager_title_node = spbc__admin_bar__get_title_for_project_manager(); + if ( $project_manager_title_node ) { + $wp_admin_bar->add_node($project_manager_title_node); + $gf2db_title_node = spbc__admin_bar__add_gf2db_title(); + if ($gf2db_title_node) { + $wp_admin_bar->add_node($gf2db_title_node); + } else { + $gf2db_invite_to_install_title = spbc__admin_bar__get_title_for_gf2db_invite_to_install(); + if ($gf2db_invite_to_install_title) { + $wp_admin_bar->add_node($gf2db_invite_to_install_title); + } + } + } + /** * Adding FAQ node */ @@ -97,6 +114,86 @@ function spbc_admin__admin_bar__add_structure($wp_admin_bar) } } +/** + * Gets the title for the project manager admin bar node. + * + * This function constructs the title for the project manager admin bar node based on various conditions. + * The title includes a link to the project manager. + * + * @return array|false The node data for the project manager admin bar node, or false if the project manager admin bar is not enabled. + */ +function spbc__admin_bar__get_title_for_project_manager() +{ + if (!is_plugin_active('gravityforms/gravityforms.php')) { + return false; + } + + $title = '' . __('Project Manager', 'security-malware-firewall') . ''; + + return array( + 'parent' => 'cleantalk_admin_bar__parent_node', + 'id' => 'project_manager__parent_node', + 'title' => $title, + ); +} + +/** + * Adds the title for the Gravity Forms to doBoard / Settings admin bar node. + * + * This function constructs the title for the Gravity Forms to doBoard / Settings admin bar node based on various conditions. + * The title includes a link to the Gravity Forms to doBoard / Settings. + * + */ +function spbc__admin_bar__add_gf2db_title() +{ + if (!is_plugin_active('gf-doboard-addon/cleantalk-doboard-add-on-for-gravity-forms.php')) { + return false; + } + + $title = sprintf( + '%s', + admin_url('admin.php?page=gf_settings&subview=cleantalk-doboard-add-on-for-gravity-forms'), + esc_html__('Gravity Forms to doBoard / Settings', 'security-malware-firewall') + ); + + return array( + 'parent' => 'project_manager__parent_node', + 'id' => 'gf2db_title', + 'title' => $title, + ); +} + +/** + * Gets the title for the "Gravity Forms to doBoard" Add-On invite to install admin bar node. + * + * This function constructs the title for the "Gravity Forms to doBoard" Add-On invite to install admin bar node based on various conditions. + * The title includes a link to the "Gravity Forms to doBoard" Add-On invite to install. + * + * @return array|false The node data for the "Gravity Forms to doBoard" Add-On invite to install admin bar node, or false if the "Gravity Forms to doBoard" Add-On invite to install admin bar node is not enabled. + */ +function spbc__admin_bar__get_title_for_gf2db_invite_to_install() +{ + if (is_plugin_active('gf-doboard-addon/cleantalk-doboard-add-on-for-gravity-forms.php')) { + return false; + } + + $title = sprintf( + '%s', + admin_url('plugin-install.php?s=GF2DB&tab=search&type=term'), + esc_html__( + 'Organize and track all messages from your site. Gravity Forms, upgraded with project management.', + 'security-malware-firewall' + ), + esc_html__('Install "Gravity Forms to doBoard" Add-On', 'security-malware-firewall') + ); + + return array( + 'parent' => 'project_manager__parent_node', + 'id' => 'gf2db_invite_to_install_title', + 'title' => $title, + ); +} + /** * Prepares properties for counters in $apbct * Handles counter reset diff --git a/inc/spbc-admin.php b/inc/spbc-admin.php index 5812c6511..84706e3a7 100644 --- a/inc/spbc-admin.php +++ b/inc/spbc-admin.php @@ -68,8 +68,6 @@ function spbc_admin_init() add_action('cleantalk_admin_bar__parent_node__before', 'spbc_admin__admin_bar__prepare_counters'); add_action('cleantalk_admin_bar__add_icon_to_parent_node', 'spbc_admin__admin_bar__prepare_counters'); - // Temporary disable the icon - // add_filter( 'cleantalk_admin_bar__parent_node__before', 'spbc_admin__admin_bar__add_parent_icon', 10, 1 ); add_filter('cleantalk_admin_bar__parent_node__after', 'spbc_admin__admin_bar__add_counter', 10, 1); add_filter('admin_bar_menu', 'spbc_admin__admin_bar__add_child_nodes', 1000);