Skip to content

Commit 7008d8c

Browse files
committed
Add plugin slugs to perflab_get_admin_pointers()
1 parent 98fe0b0 commit 7008d8c

File tree

1 file changed

+23
-11
lines changed
  • plugins/performance-lab/includes/admin

1 file changed

+23
-11
lines changed

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,32 @@ function perflab_get_dismissed_admin_pointer_ids(): array {
8888
*
8989
* @since n.e.x.t
9090
*
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.
9292
*/
9393
function perflab_get_admin_pointers(): array {
9494
$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+
),
98106
);
99107

100108
if (
101109
defined( 'SPECULATION_RULES_VERSION' )
102110
&&
103111
version_compare( SPECULATION_RULES_VERSION, '1.6.0', '>=' )
104112
) {
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+
);
106117
}
107118

108119
return $pointers;
@@ -149,11 +160,12 @@ function perflab_admin_pointer( ?string $hook_suffix = '' ): void {
149160
}
150161

151162
// 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+
}
157169

158170
// Preemptively dismiss plugin-specific pointers for plugins which are already installed.
159171
$plugin_dependent_pointers_undismissed = array_diff( array_keys( $plugin_dependent_pointers ), $dismissed_pointer_ids );
@@ -216,7 +228,7 @@ static function ( $name ) {
216228
'',
217229
array_map(
218230
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>';
220232
},
221233
$needed_pointer_ids
222234
)

0 commit comments

Comments
 (0)