How to Remove akismet-widget-style-inline-css from Your WordPress Theme

A recent update to Akismet is now adding the following code to the <head> section of every website Akismet is installed on.

Read more below on what is actually happening, or just copy the following into your functions.php to remove the code altogether!


// remove Akismet inline style
add_action( 'wp_print_styles', function()
{
// Remove previous inline style
wp_styles()->add_data( 'akismet-widget-style', 'after', '' );

} );

What is Akismet actually doing wrong here?

This is the code I’m seeing the infamous SPAM filter adding to sites:


<style id='akismet-widget-style-inline-css' type='text/css'>
.a-stats {
--akismet-color-mid-green: #357b49;
--akismet-color-white: #fff;
--akismet-color-light-grey: #f6f7f7;
max-width: 350px;
width: auto;
}
.a-stats * {
all: unset;
box-sizing: border-box;
}
.a-stats strong {
font-weight: 600;
}
.a-stats a.a-stats__link,
.a-stats a.a-stats__link:visited,
.a-stats a.a-stats__link:active {
background: var(--akismet-color-mid-green);
border: none;
box-shadow: none;
border-radius: 8px;
color: var(--akismet-color-white);
cursor: pointer;
display: block;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
font-weight: 500;
padding: 12px;
text-align: center;
text-decoration: none;
transition: all 0.2s ease;
}
/* Extra specificity to deal with TwentyTwentyOne focus style */
.widget .a-stats a.a-stats__link:focus {
background: var(--akismet-color-mid-green);
color: var(--akismet-color-white);
text-decoration: none;
}
.a-stats a.a-stats__link:hover {
filter: brightness(110%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
}
.a-stats .count {
color: var(--akismet-color-white);
display: block;
font-size: 1.5em;
line-height: 1.4;
padding: 0 13px;
white-space: nowrap;
}
</style>

Though I didn’t test it, the naming appears to have something to do with a widget, probably one engineered to simply display how many times Akismet has blocked SPAM on a given site. This seems like a widget that will be used 0 times outside of those employees who are forced to use it on their personal blogs, but the worst part is that it explicitly has code in it just for the TwentyTwentyOne theme.

Go ahead and load up the Akismet website, point your left index finger at the site and stroke that finger with your right index. This is the universal sign for “Shame on you.”

Removing this will also be included in the next version of my free Click Optimize plugin, should you employ that to help fight all of this rigamarole.

Up Next: How to Add Custom Post Types to wp-sitemap.xml