Skip to content

Instantly share code, notes, and snippets.

@eboyer
Created April 25, 2012 08:17
Show Gist options
  • Save eboyer/2488142 to your computer and use it in GitHub Desktop.
Save eboyer/2488142 to your computer and use it in GitHub Desktop.
WP Import Cleanup (Removing some inline styles after a import)
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="text-align: center;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="text-align: left;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, 'aligncenter', '');
UPDATE at_posts SET post_content = REPLACE(post_content, 'aligncenter ', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '<img class=" ', '<img class="');
UPDATE at_posts SET post_content = REPLACE(post_content, '<strong>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '</strong>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '<font>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '</font>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '<b>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '</b>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '<i>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '</i>', '');
UPDATE at_posts SET post_content = REPLACE(post_content, 'style="font-weight: normal;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #262626; font-family: Cambria; font-size: small;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="font-family: Cambria; font-size: small;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="font-family: Cambria;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #262626;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #339966;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #008000;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #003300;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #000000;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: black;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #0000ee;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="color: #000000; font-weight: normal;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="font-weight: normal; font-size: 13px;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="font-size: 13px; font-weight: normal;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, ' style="text-decoration: underline;"', '');
UPDATE at_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE at_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE at_posts SET post_content = REPLACE(post_content, '’', '’');
UPDATE at_posts SET post_content = REPLACE(post_content, '‘', '‘');
UPDATE at_posts SET post_content = REPLACE(post_content, '—', '–');
UPDATE at_posts SET post_content = REPLACE(post_content, '–', '—');
UPDATE at_posts SET post_content = REPLACE(post_content, '•', '-');
UPDATE at_posts SET post_content = REPLACE(post_content, '…', '…');
DELETE FROM at_terms WHERE term_id IN (SELECT term_id FROM at_term_taxonomy WHERE count = 0 );
DELETE FROM at_term_taxonomy WHERE term_id not IN (SELECT term_id FROM at_terms);
DELETE FROM at_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM at_term_taxonomy);
@eboyer
Copy link
Author

eboyer commented Apr 25, 2012

I NEED A CLEANER WAY TO DO THIS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment