Skip to content

Commit 2e40dad

Browse files
Merge pull request #1387 from equalizedigital/codex/find-and-fix-bugs-in-plugin
Fix admin toolbar pro link UTM content
2 parents b52c1aa + a8235e9 commit 2e40dad

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

includes/classes/class-admin-toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function get_default_menu_items(): array {
110110
// Add Get Pro submenu item (only show if pro is not installed or license is not valid).
111111
if ( ! defined( 'EDACP_VERSION' ) || ! EDAC_KEY_VALID ) {
112112
$pro_link = function_exists( 'edac_generate_link_type' )
113-
? edac_generate_link_type( [ 'utm-content' => 'admin-toolbar' ] )
113+
? edac_generate_link_type( [ 'utm_content' => 'admin-toolbar' ] )
114114
: 'https://equalizedigital.com/accessibility-checker/pricing/';
115115

116116
$menu_items[] = [

tests/phpunit/includes/classes/AdminToolbarTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,31 @@ public function test_get_default_menu_items_returns_array() {
9494
$this->assertNotEmpty( $items );
9595
$this->assertArrayHasKey( 'id', $items[0] );
9696
}
97+
98+
/**
99+
* Test pro menu link uses the expected UTM content parameter key.
100+
*/
101+
public function test_get_default_menu_items_pro_link_uses_utm_content() {
102+
if ( ! function_exists( 'edac_generate_link_type' ) ) {
103+
$this->markTestSkipped( 'edac_generate_link_type is not available in this test environment.' );
104+
}
105+
106+
$reflection = new \ReflectionClass( Admin_Toolbar::class );
107+
$method = $reflection->getMethod( 'get_default_menu_items' );
108+
$method->setAccessible( true );
109+
$toolbar = new Admin_Toolbar();
110+
$items = $method->invoke( $toolbar );
111+
112+
$pro_item = null;
113+
foreach ( $items as $item ) {
114+
if ( 'accessibility-checker-pro' === $item['id'] ) {
115+
$pro_item = $item;
116+
break;
117+
}
118+
}
119+
120+
$this->assertNotNull( $pro_item );
121+
$this->assertStringContainsString( 'utm_content=admin-toolbar', $pro_item['href'] );
122+
$this->assertStringNotContainsString( 'utm-content=admin-toolbar', $pro_item['href'] );
123+
}
97124
}

0 commit comments

Comments
 (0)