@@ -284,9 +284,7 @@ function plsr_render_settings_field( array $args ): void {
284
284
return ; // @codeCoverageIgnore
285
285
}
286
286
287
- $ value = $ option [ $ args ['field ' ] ];
288
- $ show_notice = 'authentication ' === $ args ['field ' ] && ! wp_using_ext_object_cache ();
289
- $ show_warning = $ show_notice && 'logged_out ' !== $ value ;
287
+ $ value = $ option [ $ args ['field ' ] ];
290
288
?>
291
289
<fieldset id="<?php echo esc_attr ( 'plsr- ' . $ args ['field ' ] . '-setting ' ); ?> ">
292
290
<legend class="screen-reader-text"><?php echo esc_html ( $ args ['title ' ] ); ?> </legend>
@@ -304,8 +302,8 @@ function plsr_render_settings_field( array $args ): void {
304
302
</p>
305
303
<?php endforeach ; ?>
306
304
307
- <?php if ( $ show_notice ) : ?>
308
- <div id="plsr-auth-notice" class="notice <?php echo esc_attr ( $ show_warning ? 'notice-warning ' : 'notice-info ' ); ?> inline">
305
+ <?php if ( ' authentication ' === $ args [ ' field ' ] && ! wp_using_ext_object_cache () ) : ?>
306
+ <div id="plsr-auth-notice" class="notice <?php echo esc_attr ( ' logged_out ' !== $ value ? 'notice-warning ' : 'notice-info ' ); ?> inline">
309
307
<p>
310
308
<?php
311
309
echo wp_kses (
@@ -324,6 +322,26 @@ function plsr_render_settings_field( array $args ): void {
324
322
?>
325
323
</p>
326
324
</div>
325
+ <?php
326
+ // phpcs:ignore Squiz.PHP.Heredoc.NotAllowed -- Part of the PCP ruleset. Appealed in <https://github.com/WordPress/plugin-check/issues/792#issuecomment-3214985527>.
327
+ $ js = <<<'JS'
328
+ const authOptions = document.getElementById( 'plsr-authentication-setting' );
329
+ const noticeDiv = document.getElementById( 'plsr-auth-notice' );
330
+ if ( authOptions && noticeDiv ) {
331
+ authOptions.addEventListener( 'change', ( /** @type {Event} */ event ) => {
332
+ const target = event.target;
333
+ if ( ! ( target instanceof HTMLInputElement && 'radio' === target.type ) ) {
334
+ return;
335
+ }
336
+ const isLoggedOut = ( target.value === 'logged_out' );
337
+ noticeDiv.classList.toggle( 'notice-info', isLoggedOut );
338
+ noticeDiv.classList.toggle( 'notice-warning', ! isLoggedOut );
339
+ } );
340
+ }
341
+ JS;
342
+ // 👆 This 'JS;' line can only be indented two tabs when minimum PHP version is increased to 7.3+.
343
+ wp_print_inline_script_tag ( $ js , array ( 'type ' => 'module ' ) );
344
+ ?>
327
345
<?php endif ; ?>
328
346
329
347
<p class="description" style="max-width: 800px;">
@@ -341,28 +359,7 @@ function plsr_render_settings_field( array $args ): void {
341
359
?>
342
360
</p>
343
361
</fieldset>
344
-
345
362
<?php
346
- if ( $ show_notice ) {
347
- // phpcs:ignore Squiz.PHP.Heredoc.NotAllowed -- Part of the PCP ruleset. Appealed in <https://github.com/WordPress/plugin-check/issues/792#issuecomment-3214985527>.
348
- $ js = <<<'JS'
349
- const authOptions = document.getElementById( 'plsr-authentication-setting' );
350
- const noticeDiv = document.getElementById( 'plsr-auth-notice' );
351
- if ( authOptions && noticeDiv ) {
352
- authOptions.addEventListener( 'change', ( /** @type {Event} */ event ) => {
353
- const target = event.target;
354
- if ( ! ( target instanceof HTMLInputElement && 'radio' === target.type ) ) {
355
- return;
356
- }
357
- const isLoggedOut = ( target.value === 'logged_out' );
358
- noticeDiv.classList.toggle( 'notice-info', isLoggedOut );
359
- noticeDiv.classList.toggle( 'notice-warning', ! isLoggedOut );
360
- } );
361
- }
362
- JS;
363
- // 👆 This 'JS;' line can only be indented two tabs when minimum PHP version is increased to 7.3+.
364
- wp_print_inline_script_tag ( $ js , array ( 'type ' => 'module ' ) );
365
- }
366
363
}
367
364
368
365
/**
0 commit comments