Skip to content

Commit

Permalink
Add option to disable adminbar logout link
Browse files Browse the repository at this point in the history
The problem that made this necessary was resolved in WordPress 6.5. By me, so I really should have done this sooner...
  • Loading branch information
joedolson committed Aug 25, 2024
1 parent ca8a32e commit a3d5d6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/wp-accessibility-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ function wpa_update_settings() {
$wpa_search_alt = ( isset( $_POST['wpa_search_alt'] ) ) ? 'on' : '';
$wpa_diagnostics = ( isset( $_POST['wpa_diagnostics'] ) ) ? 'on' : '';
$wpa_disable_fullscreen = ( isset( $_POST['wpa_disable_fullscreen'] ) ) ? 'on' : '';
$wpa_disable_logout = ( isset( $_POST['wpa_disable_logout'] ) ) ? 'on' : '';
$wpa_track_stats = ( isset( $_POST['wpa_track_stats'] ) ) ? sanitize_text_field( $_POST['wpa_track_stats'] ) : '';
update_option( 'wpa_search_alt', $wpa_search_alt );
update_option( 'wpa_diagnostics', $wpa_diagnostics );
update_option( 'wpa_disable_fullscreen', $wpa_disable_fullscreen );
update_option( 'wpa_track_stats', $wpa_track_stats );
update_option( 'wpa_disable_logout', $wpa_disable_logout );
$message = __( 'Accessibility Tools Updated', 'wp-accessibility' );

return "<div class='updated'><p>" . $message . '</p></div>';
Expand Down Expand Up @@ -477,6 +479,10 @@ function wpa_admin_settings() {
<input type="checkbox" id="wpa_search_alt" name="wpa_search_alt" <?php checked( get_option( 'wpa_search_alt' ), 'on' ); ?> aria-describedby="wpa_search_alt_note" />
<label for="wpa_search_alt"><?php _e( 'Include alt attribute in media library searches', 'wp-accessibility' ); ?></label> <em class="wpa-note" id="wpa_search_alt_note"><?php _e( '* May cause slow searches on large media libraries.', 'wp-accessibility' ); ?></em>
</li>
<li>
<input type="checkbox" id="wpa_disable_logout" name="wpa_disable_logout" <?php checked( get_option( 'wpa_disable_logout' ), 'on' ); ?> aria-describedby="wpa_logout_note" />
<label for="wpa_disable_logout"><?php _e( 'Disable top-level adminbar logout link', 'wp-accessibility' ); ?></label> <em class="wpa-note" id="wpa_logout_note"><?php _e( '* Accessibility problems accessing adminbar dropdowns were fixed in WordPress 6.5.', 'wp-accessibility' ); ?></em>
</li>
<li>
<input type="checkbox" id="wpa_disable_fullscreen" name="wpa_disable_fullscreen" <?php checked( get_option( 'wpa_disable_fullscreen' ), 'on' ); ?>/>
<label for="wpa_disable_fullscreen"><?php _e( 'Disable fullscreen block editor by default', 'wp-accessibility' ); ?></label>
Expand Down
2 changes: 1 addition & 1 deletion src/wp-accessibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ function wpa_jquery_asl() {
* @param object $admin_bar Admin bar object.
*/
function wpa_logout_item( $admin_bar ) {
if ( ! is_user_logged_in() ) {
if ( ! is_user_logged_in() || 'on' === get_option( 'wpa_disable_logout', 'true' ) ) {
return;
}

Expand Down

0 comments on commit a3d5d6a

Please sign in to comment.