enabled( 'remove_tag_cloud_titles' ) ) { add_filter( 'wp_generate_tag_cloud', array( $this, 'strip_tag_cloud_titles' ) ); } if ( $this->enabled( 'visible_focus' ) || $this->enabled( 'underline_links' ) ) { add_action( 'wp_head', array( $this, 'print_css' ) ); } if ( $this->enabled( 'skip_link' ) ) { add_action( 'wp_body_open', array( $this, 'print_skip_link' ) ); } } /** * Strip `title="..."` attributes from tag/category cloud links (added * by older WordPress versions and by some themes and plugins). * * The cloud is a string by default but an array of links when it's * requested with `format => array`, so both are handled; anything * else is passed through untouched. * * @param mixed $cloud Generated tag cloud: HTML, or an array of link HTML. * @return mixed */ public function strip_tag_cloud_titles( mixed $cloud ): mixed { $strip = static fn( $html ) => is_string( $html ) ? (string) preg_replace( '/\s+title="[^"]*"/', '', $html ) : $html; return is_array( $cloud ) ? array_map( $strip, $cloud ) : $strip( $cloud ); } /** * Print the CSS for whichever of the two CSS-based toggles are on. * * @return void */ public function print_css(): void { $rules = ''; if ( $this->enabled( 'visible_focus' ) ) { $rules .= 'a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #2271b1 !important; outline-offset: 2px !important; }'; } if ( $this->enabled( 'underline_links' ) ) { $rules .= ':is(.entry-content, .post-content, .wp-block-post-content) a:not(.wp-block-button__link, .button) { text-decoration: underline !important; }'; } if ( '' === $rules ) { return; } echo '' . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- a fixed, hardcoded CSS string with no user input. } /** * Print the skip-to-content link, first thing after
. * * Themes name their main region differently (#main, #content, * #site-content, a bare