Skip to content

Commit 1b22718

Browse files
committed
Replace set_up in data provider with initial_wp_pointers
1 parent 7008d8c commit 1b22718

File tree

4 files changed

+32
-40
lines changed

4 files changed

+32
-40
lines changed

plugins/performance-lab/includes/admin/load.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ function perflab_get_admin_pointers(): array {
131131
* ensure that `$hook_suffix` is a string when it calls `do_action( 'admin_enqueue_scripts', $hook_suffix )`.
132132
*/
133133
function perflab_admin_pointer( ?string $hook_suffix = '' ): void {
134-
$is_performance_screen = (
135-
'options-general.php' === $hook_suffix &&
136-
( isset( $_GET['page'] ) && PERFLAB_SCREEN === $_GET['page'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
137-
);
134+
// See get_plugin_page_hookname().
135+
$is_performance_screen = 'settings_page_' . PERFLAB_SCREEN === $hook_suffix;
138136

139137
// Do not show admin pointer in multisite Network admin, User admin UI, dashboard, or plugins list table. However,
140138
// do proceed on the Performance screen so that all pointers can be auto-dismissed.

plugins/performance-lab/tests/includes/admin/test-load.php

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -118,74 +118,68 @@ public function test_perflab_get_admin_pointers(): void {
118118
}
119119

120120
/**
121-
* @return array<string, array{ hook_suffix: string|null, expected: bool }>
121+
* @return array<string, array{
122+
* initial_wp_pointers: string,
123+
* hook_suffix: string|null,
124+
* expected: bool,
125+
* dismissed_wp_pointers: string,
126+
* }>
122127
*/
123128
public function data_provider_test_perflab_admin_pointer(): array {
124129
return array(
125130
'null' => array(
126-
'set_up' => null,
131+
'initial_wp_pointers' => '',
127132
'hook_suffix' => null,
128133
'expected' => false,
129134
'dismissed_wp_pointers' => '',
130135
),
131136
'edit.php' => array(
132-
'set_up' => null,
137+
'initial_wp_pointers' => '',
133138
'hook_suffix' => 'edit.php',
134139
'expected' => false,
135140
'dismissed_wp_pointers' => '',
136141
),
137142
'dashboard_not_dismissed' => array(
138-
'set_up' => null,
143+
'initial_wp_pointers' => '',
139144
'hook_suffix' => 'index.php',
140145
'expected' => true,
141146
'dismissed_wp_pointers' => 'perflab-feature-view-transitions',
142147
),
143148
'plugins_not_dismissed' => array(
144-
'set_up' => null,
149+
'initial_wp_pointers' => '',
145150
'hook_suffix' => 'plugins.php',
146151
'expected' => true,
147152
'dismissed_wp_pointers' => 'perflab-feature-view-transitions',
148153
),
149154
'dashboard_new_dismissed' => array(
150-
'set_up' => static function (): void {
151-
// Note: If the No-cache BFCache plugin (not part of the monorepo) is installed, then this test will likely fail and it should be skipped.
152-
update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', 'perflab-admin-pointer' );
153-
},
155+
// Note: If the No-cache BFCache plugin (not part of the monorepo) is installed, then this test will likely fail and it should be skipped.
156+
'initial_wp_pointers' => 'perflab-admin-pointer',
154157
'hook_suffix' => 'index.php',
155158
'expected' => true,
156159
'dismissed_wp_pointers' => 'perflab-admin-pointer,perflab-feature-view-transitions',
157160
),
158161
'dashboard_one_dismissed' => array(
159-
'set_up' => static function (): void {
160-
// Note: The No-cache BFCache plugin is not part of the monorepo, so it is not automatically installed in the dev environment.
161-
update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', 'perflab-admin-pointer,perflab-feature-nocache-bfcache' );
162-
},
162+
// Note: The No-cache BFCache plugin is not part of the monorepo, so it is not automatically installed in the dev environment.
163+
'initial_wp_pointers' => 'perflab-admin-pointer,perflab-feature-nocache-bfcache',
163164
'hook_suffix' => 'index.php',
164165
'expected' => false,
165166
'dismissed_wp_pointers' => 'perflab-admin-pointer,perflab-feature-nocache-bfcache,perflab-feature-view-transitions',
166167
),
167168
'dashboard_all_dismissed' => array(
168-
'set_up' => static function (): void {
169-
update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', implode( ',', array_keys( perflab_get_admin_pointers() ) ) );
170-
},
169+
'initial_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ),
171170
'hook_suffix' => 'index.php',
172171
'expected' => false,
173172
'dismissed_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ),
174173
),
175174
'perflab_screen_first_time' => array(
176-
'set_up' => static function (): void {
177-
$_GET['page'] = PERFLAB_SCREEN;
178-
},
179-
'hook_suffix' => 'options-general.php',
175+
'initial_wp_pointers' => '',
176+
'hook_suffix' => 'settings_page_' . PERFLAB_SCREEN,
180177
'expected' => false,
181178
'dismissed_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ),
182179
),
183180
'perflab_screen_second_time' => array(
184-
'set_up' => static function (): void {
185-
$_GET['page'] = PERFLAB_SCREEN;
186-
update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', 'perflab-admin-pointer' );
187-
},
188-
'hook_suffix' => 'options-general.php',
181+
'initial_wp_pointers' => 'perflab-admin-pointer',
182+
'hook_suffix' => 'settings_page_' . PERFLAB_SCREEN,
189183
'expected' => false,
190184
'dismissed_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ),
191185
),
@@ -196,17 +190,15 @@ public function data_provider_test_perflab_admin_pointer(): array {
196190
* @covers ::perflab_admin_pointer
197191
* @dataProvider data_provider_test_perflab_admin_pointer
198192
*
199-
* @param Closure|null $set_up Set up.
200-
* @param string|null $hook_suffix Hook suffix.
201-
* @param bool $expected Expected.
202-
* @param string $dismissed_wp_pointers Dismissed admin pointers.
193+
* @param string $initial_wp_pointers Set up.
194+
* @param string|null $hook_suffix Hook suffix.
195+
* @param bool $expected Expected.
196+
* @param string $dismissed_wp_pointers Dismissed admin pointers.
203197
*/
204-
public function test_perflab_admin_pointer( ?Closure $set_up, ?string $hook_suffix, bool $expected, string $dismissed_wp_pointers ): void {
198+
public function test_perflab_admin_pointer( string $initial_wp_pointers, ?string $hook_suffix, bool $expected, string $dismissed_wp_pointers ): void {
205199
$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
206200
wp_set_current_user( $user_id );
207-
if ( $set_up instanceof Closure ) {
208-
$set_up();
209-
}
201+
update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', $initial_wp_pointers );
210202
$this->assertFalse( is_network_admin() || is_user_admin() );
211203
perflab_admin_pointer( $hook_suffix );
212204

plugins/speculation-rules/load.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Enables browsers to speculatively prerender or prefetch pages to achieve near-instant loads based on user interaction.
66
* Requires at least: 6.6
77
* Requires PHP: 7.2
8-
* Version: 1.5.0
8+
* Version: 1.6.0
99
* Author: WordPress Performance Team
1010
* Author URI: https://make.wordpress.org/performance/
1111
* License: GPLv2 or later
@@ -65,7 +65,7 @@ static function ( string $global_var_name, string $version, Closure $load ): voi
6565
}
6666
)(
6767
'plsr_pending_plugin_info',
68-
'1.5.0',
68+
'1.6.0',
6969
static function ( string $version ): void {
7070

7171
// Define the constant.

plugins/speculation-rules/readme.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Contributors: wordpressdotorg
44
Tested up to: 6.8
5-
Stable tag: 1.5.0
5+
Stable tag: 1.6.0
66
License: GPLv2 or later
77
License URI: https://www.gnu.org/licenses/gpl-2.0.html
88
Tags: performance, javascript, speculation rules, prerender, prefetch
@@ -122,6 +122,8 @@ Contributions are always welcome! Learn more about how to get involved in the [C
122122

123123
== Changelog ==
124124

125+
= 1.6.0 =
126+
125127
= 1.5.0 =
126128

127129
**Enhancements**

0 commit comments

Comments
 (0)