Daaaaaayuuum, Rank Math.

I was using Rank Math for a while after switching over from the SEO Framework. Then I decided to give TSF another try after reading some unfavorable reviews about Rank Math.

But apparently! Even if you uninstall Rank Math, it will still leave traces of itself on your site. Not just the database, but looking at the HTML of some pages:

The content from the /about/ page from the editor side

I mean, they probably had a purpose when I was actually using the plugin, but can they (and plugins in general) please have an option to clean up after themselves when we want to uninstall said plugin?

The official docs has some info on how to clean up this sort of thing, but it hasn’t worked for me (yet? Maybe I’m just not doing it right).

Here’s a solution/band-aid btw, if you’re an ex-Rank Math user and don’t want their class names cluttering up your pages (that actually worked for me).

  1. add_filter( 'the_content', function ( $content ) {
  2. // remove .rank-math-link classname
  3. //
  4. // this regex will remove only the string
  5. // "rank-math-link" found in attributes
  6. // but will leave other instances alone
  7. // ex. if you wanted to mention in your page/post
  8. // content for instance
  9. $content = preg_replace("#class=\"([^\"]*)(rank\-math\-link)([^\"]*)\"#", 'class="\\1\\3"', $content);
  10. // remove empty [class] attrs
  11. $content = preg_replace("#( class=[\"'][\"'])#", "", $content);
  12. return $content;
  13. }, 1);

This only cleans them up from the front end, but you’ll still see them from the editor. I’m trying to figure out how to banish them from GPORG permanently (without going through 100+ posts and other content). 😩