@@ -88,21 +88,32 @@ function perflab_get_dismissed_admin_pointer_ids(): array {
88
88
*
89
89
* @since n.e.x.t
90
90
*
91
- * @return array<non-empty-string, string> Admin pointer messages with the admin pointer IDs as the keys .
91
+ * @return array<non-empty-string, array{ content: string, plugin?: non-empty-string }> Keys are the admin pointer IDs.
92
92
*/
93
93
function perflab_get_admin_pointers (): array {
94
94
$ pointers = array (
95
- 'perflab-admin-pointer ' => __ ( 'You can now test upcoming WordPress performance features. ' , 'performance-lab ' ),
96
- 'perflab-feature-view-transitions ' => __ ( 'New <strong>View Transitions</strong> feature now available. ' , 'performance-lab ' ),
97
- 'perflab-feature-nocache-bfcache ' => __ ( 'New <strong>No-cache BFCache</strong> feature now available. ' , 'performance-lab ' ),
95
+ 'perflab-admin-pointer ' => array (
96
+ 'content ' => __ ( 'You can now test upcoming WordPress performance features. ' , 'performance-lab ' ),
97
+ ),
98
+ 'perflab-feature-view-transitions ' => array (
99
+ 'content ' => __ ( 'New <strong>View Transitions</strong> feature now available. ' , 'performance-lab ' ),
100
+ 'plugin ' => 'view-transitions ' ,
101
+ ),
102
+ 'perflab-feature-nocache-bfcache ' => array (
103
+ 'content ' => __ ( 'New <strong>No-cache BFCache</strong> feature now available. ' , 'performance-lab ' ),
104
+ 'plugin ' => 'nocache-bfcache ' ,
105
+ ),
98
106
);
99
107
100
108
if (
101
109
defined ( 'SPECULATION_RULES_VERSION ' )
102
110
&&
103
111
version_compare ( SPECULATION_RULES_VERSION , '1.6.0 ' , '>= ' )
104
112
) {
105
- $ pointers ['perflab-feature-speculation-rules-auth ' ] = __ ( '<strong>Speculative Loading</strong> now includes an opt-in setting for logged-in users. ' , 'performance-lab ' );
113
+ $ pointers ['perflab-feature-speculation-rules-auth ' ] = array (
114
+ 'content ' => __ ( '<strong>Speculative Loading</strong> now includes an opt-in setting for logged-in users. ' , 'performance-lab ' ),
115
+ 'plugin ' => 'speculation-rules ' ,
116
+ );
106
117
}
107
118
108
119
return $ pointers ;
@@ -149,11 +160,12 @@ function perflab_admin_pointer( ?string $hook_suffix = '' ): void {
149
160
}
150
161
151
162
// List of pointer IDs that are tied to feature plugin slugs.
152
- // TODO: Add this to perflab_get_admin_pointers().
153
- $ plugin_dependent_pointers = array (
154
- 'perflab-feature-view-transitions ' => 'view-transitions ' ,
155
- 'perflab-feature-nocache-bfcache ' => 'nocache-bfcache ' ,
156
- );
163
+ $ plugin_dependent_pointers = array ();
164
+ foreach ( $ admin_pointers as $ pointer_id => $ admin_pointer ) {
165
+ if ( isset ( $ admin_pointer ['plugin ' ] ) ) {
166
+ $ plugin_dependent_pointers [ $ pointer_id ] = $ admin_pointer ['plugin ' ];
167
+ }
168
+ }
157
169
158
170
// Preemptively dismiss plugin-specific pointers for plugins which are already installed.
159
171
$ plugin_dependent_pointers_undismissed = array_diff ( array_keys ( $ plugin_dependent_pointers ), $ dismissed_pointer_ids );
@@ -216,7 +228,7 @@ static function ( $name ) {
216
228
'' ,
217
229
array_map (
218
230
static function ( string $ needed_pointer ) use ( $ admin_pointers ): string {
219
- return '<p> ' . $ admin_pointers [ $ needed_pointer ] . '</p> ' ;
231
+ return '<p> ' . $ admin_pointers [ $ needed_pointer ][ ' content ' ] . '</p> ' ;
220
232
},
221
233
$ needed_pointer_ids
222
234
)
0 commit comments