Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
43 changes: 3 additions & 40 deletions inc/cleantalk-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -751,17 +751,10 @@ function apbct_admin__admin_bar__add_structure($wp_admin_bar)
* Link to project manager
*/
$project_manager_title_node = apbct__admin_bar__get_title_for_project_manager();
if ( $project_manager_title_node ) {
$gf2db_title_node = apbct__admin_bar__add_gf2db_title();
if ( $project_manager_title_node && $gf2db_title_node) {
$wp_admin_bar->add_node($project_manager_title_node);
Comment thread
alexander-b-clean marked this conversation as resolved.
$gf2db_title_node = apbct__admin_bar__add_gf2db_title();
if ($gf2db_title_node) {
$wp_admin_bar->add_node($gf2db_title_node);
} else {
$gf2db_invite_to_install_title = apbct__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);
}
}
$wp_admin_bar->add_node($gf2db_title_node);
}

/**
Expand Down Expand Up @@ -823,36 +816,6 @@ function apbct__admin_bar__add_gf2db_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 apbct__admin_bar__get_title_for_gf2db_invite_to_install()
{
if (is_plugin_active('cleantalk-doboard-add-on-for-gravity-forms/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.',
'cleantalk-spam-protect'
),
esc_html__('Install "Gravity Forms to doBoard" Add-On', 'cleantalk-spam-protect')
);

return array(
'parent' => 'project_manager__parent_node',
'id' => 'gf2db_invite_to_install_title',
'title' => $title,
);
}

/**
* Gets the title for the APBCT admin bar node.
Expand Down
1 change: 0 additions & 1 deletion templates/apbct_settings__footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function apbct_settings__footer()
];
$block2_links = [
['text' => 'Security plugin by CleanTalk', 'url' => admin_url('plugin-install.php') . '?s=spbct&tab=search&type=term'],
['text' => esc_html__('Forms to CRM / Gravity Add-On'), 'url' => admin_url('plugin-install.php') . '?s=cleantalk-doboard-add-on-for-gravity-forms&tab=search&type=term'],
];

?>
Expand Down
4 changes: 0 additions & 4 deletions tests/StandaloneFunctions/TestSettingsFooterLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public function testBlock2LinksJsonStructureIsValid(): void
$this->assertArrayHasKey('text', $decoded[0]);
$this->assertArrayHasKey('url', $decoded[0]);
$this->assertEquals('Security plugin by CleanTalk', $decoded[0]['text']);

$this->assertArrayHasKey('text', $decoded[1]);
$this->assertArrayHasKey('url', $decoded[1]);
$this->assertStringContainsString('Gravity Add-On', $decoded[1]['text']);
} else {
$this->fail('JSON for Recommended plugins not found');
}
Expand Down
16 changes: 16 additions & 0 deletions tests/StandaloneFunctions/TestWPAdminBarTitleNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,20 @@ function testArrayContentSPBC($array, $test)
$this->assertStringContainsString('product_id=4', $title);
$this->assertStringNotContainsString('apbct-icon-attention-alt', $title);
}

public function testProjectManagerNodeIndependentOfGf2dbNode()
{

$project_manager_node = apbct__admin_bar__get_title_for_project_manager();
$gf2db_node = apbct__admin_bar__add_gf2db_title();

$this->assertFalse($project_manager_node );
$this->assertFalse($gf2db_node);

$shouldAddParentNode = (bool) $project_manager_node;
$shouldAddChildNode = (bool) $gf2db_node;

$this->assertFalse($shouldAddParentNode);
$this->assertFalse($shouldAddChildNode);
}
}
Loading