Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions inc/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 = '<span><a>' . __('Project Manager', 'security-malware-firewall') . '</a></span>';

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(
'<a href="%s" target="_blank">%s</a>',
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(
'<a href="%s" target="_blank" title="%s">%s</a>',
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
Expand Down
2 changes: 0 additions & 2 deletions inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down