Skip to content

Commit a6a3b26

Browse files
committed
Restore context to use absolute URL in View Only pointer.
1 parent 53eac8d commit a6a3b26

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

includes/Core/Dashboard_Sharing/Dashboard_Sharing.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace Google\Site_Kit\Core\Dashboard_Sharing;
1212

13+
use Google\Site_Kit\Context;
14+
1315
/**
1416
* Class for handling Dashboard Sharing.
1517
*
@@ -31,9 +33,12 @@ class Dashboard_Sharing {
3133
*
3234
* @since 1.82.0
3335
* @since 1.158.0 Remove $user_options and $context params.
36+
* @since n.e.x.t Restore $context param.
37+
*
38+
* @param Context $context Plugin context.
3439
*/
35-
public function __construct() {
36-
$this->view_only_pointer = new View_Only_Pointer();
40+
public function __construct( Context $context ) {
41+
$this->view_only_pointer = new View_Only_Pointer( $context );
3742
}
3843

3944
/**

includes/Core/Dashboard_Sharing/View_Only_Pointer.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Google\Site_Kit\Core\Dashboard_Sharing;
1212

13+
use Google\Site_Kit\Context;
1314
use Google\Site_Kit\Core\Admin\Pointer;
1415
use Google\Site_Kit\Core\Permissions\Permissions;
1516

@@ -24,6 +25,25 @@ final class View_Only_Pointer {
2425

2526
const SLUG = 'googlesitekit-view-only-pointer';
2627

28+
/**
29+
* Plugin context.
30+
*
31+
* @since n.e.x.t
32+
* @var Context
33+
*/
34+
private $context;
35+
36+
/**
37+
* Constructor.
38+
*
39+
* @since n.e.x.t
40+
*
41+
* @param Context $context Plugin context.
42+
*/
43+
public function __construct( Context $context ) {
44+
$this->context = $context;
45+
}
46+
2747
/**
2848
* Registers functionality through WordPress hooks.
2949
*
@@ -88,7 +108,8 @@ private function get_view_only_pointer() {
88108
'class' => 'googlesitekit-view-only-pointer',
89109
'buttons' =>
90110
sprintf(
91-
'<a class="googlesitekit-pointer-cta button-primary" href="admin.php?page=googlesitekit-dashboard" data-action="dismiss">%s</a>',
111+
'<a class="googlesitekit-pointer-cta button-primary" href="%s" data-action="dismiss">%s</a>',
112+
esc_attr( $this->context->admin_url( 'dashboard' ) ),
92113
esc_html__( 'View dashboard', 'google-site-kit' )
93114
),
94115
),

includes/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function () use ( $options, $activation_flag ) {
222222
( new Core\Util\Migration_1_129_0( $this->context, $options ) )->register();
223223
( new Core\Util\Migration_1_150_0( $this->context, $options ) )->register();
224224
( new Core\Util\Migration_1_163_0( $this->context, $options ) )->register();
225-
( new Core\Dashboard_Sharing\Dashboard_Sharing() )->register();
225+
( new Core\Dashboard_Sharing\Dashboard_Sharing( $this->context ) )->register();
226226
( new Core\Key_Metrics\Key_Metrics( $this->context, $user_options, $options ) )->register();
227227
( new Core\Prompts\Prompts( $this->context, $user_options ) )->register();
228228
( new Core\Consent_Mode\Consent_Mode( $this->context, $modules, $options ) )->register();

tests/phpunit/integration/Core/Dashboard_Sharing/View_Only_PointerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function set_up() {
5151

5252
$this->context = new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE );
5353

54-
$pointer = new View_Only_Pointer();
54+
$pointer = new View_Only_Pointer( $this->context );
5555
$pointer->register();
5656
}
5757

0 commit comments

Comments
 (0)