@@ -152,7 +152,11 @@ function perflab_admin_pointer( ?string $hook_suffix = '' ): void {
152
152
return ;
153
153
}
154
154
155
- // Get installed plugins to check if these feature plugins are already installed.
155
+ /**
156
+ * Installed plugin slugs.
157
+ *
158
+ * @var non-empty-string[] $installed_plugin_slugs
159
+ */
156
160
$ installed_plugin_slugs = array_map (
157
161
static function ( $ name ) {
158
162
return strtok ( $ name , '/ ' );
@@ -166,14 +170,14 @@ static function ( $name ) {
166
170
'perflab-feature-nocache-bfcache ' => 'nocache-bfcache ' ,
167
171
);
168
172
173
+ // Make sure that the dismissed pointers include any plugins that are already installed.
169
174
$ dismissed_pointers_updated = false ;
170
175
foreach ( $ plugin_dependent_pointers as $ pointer_id => $ slug ) {
171
176
if ( in_array ( $ slug , $ installed_plugin_slugs , true ) && ! in_array ( $ pointer_id , $ dismissed_pointer_ids , true ) ) {
172
177
$ dismissed_pointer_ids [] = $ pointer_id ;
173
178
$ dismissed_pointers_updated = true ;
174
179
}
175
180
}
176
-
177
181
if ( $ dismissed_pointers_updated ) {
178
182
update_user_meta (
179
183
get_current_user_id (),
@@ -182,21 +186,22 @@ static function ( $name ) {
182
186
);
183
187
}
184
188
185
- if ( count ( array_diff ( $ admin_pointer_ids , $ dismissed_pointer_ids ) ) === 0 ) {
186
- return ;
187
- }
188
-
189
- // Enqueue pointer CSS and JS.
190
- wp_enqueue_style ( 'wp-pointer ' );
191
- wp_enqueue_script ( 'wp-pointer ' );
192
-
193
189
$ new_install_pointer_id = 'perflab-admin-pointer ' ;
194
190
if ( ! in_array ( $ new_install_pointer_id , $ dismissed_pointer_ids , true ) ) {
195
191
$ needed_pointer_ids = array ( $ new_install_pointer_id );
196
192
} else {
197
193
$ needed_pointer_ids = array_diff ( $ admin_pointer_ids , $ dismissed_pointer_ids );
198
194
}
199
195
196
+ // No admin pointers are needed, so abort.
197
+ if ( count ( $ needed_pointer_ids ) === 0 ) {
198
+ return ;
199
+ }
200
+
201
+ // Enqueue pointer CSS and JS.
202
+ wp_enqueue_style ( 'wp-pointer ' );
203
+ wp_enqueue_script ( 'wp-pointer ' );
204
+
200
205
$ args = array (
201
206
'heading ' => __ ( 'Performance Lab ' , 'performance-lab ' ),
202
207
);
@@ -231,8 +236,8 @@ static function ( string $needed_pointer ) use ( $admin_pointers ): string {
231
236
?>
232
237
<script>
233
238
jQuery( function() {
234
- const pointerIdsToDismiss = <?php echo wp_json_encode ( $ pointer_ids_to_dismiss , JSON_OBJECT_AS_ARRAY ); ?> ;
235
- const nonce = <?php echo wp_json_encode ( wp_create_nonce ( 'dismiss_pointer ' ) ); ?> ;
239
+ const pointerIdsToDismiss = <?php echo wp_json_encode ( $ pointer_ids_to_dismiss , JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_OBJECT_AS_ARRAY ); ?> ;
240
+ const nonce = <?php echo wp_json_encode ( wp_create_nonce ( 'dismiss_pointer ' ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> ;
236
241
237
242
function dismissNextPointer() {
238
243
const pointerId = pointerIdsToDismiss.shift();
@@ -252,7 +257,7 @@ function dismissNextPointer() {
252
257
253
258
// Pointer Options.
254
259
const options = {
255
- content: <?php echo wp_json_encode ( '<h3> ' . esc_html ( $ args ['heading ' ] ) . '</h3> ' . wp_kses ( $ args ['content ' ], $ wp_kses_options ) ); ?> ,
260
+ content: <?php echo wp_json_encode ( '<h3> ' . esc_html ( $ args ['heading ' ] ) . '</h3> ' . wp_kses ( $ args ['content ' ], $ wp_kses_options ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> ,
256
261
position: {
257
262
edge: 'left',
258
263
align: 'right',
0 commit comments