Created
January 8, 2020 21:42
-
-
Save gormus/ea2d91ac27931063caf9feb3598799f9 to your computer and use it in GitHub Desktop.
Update WordPress posts which may contain broken code snippets for syntax highlighting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1. Reset all code snippets to use '<pre><code>' as opening tags. | |
UPDATE wp_posts | |
SET post_content = REGEXP_REPLACE(post_content, '<pre[^>]*>(<code[^>]*>)*', '<pre><code>') | |
WHERE post_status = 'publish' | |
AND post_type = 'post' | |
AND post_content RLIKE '<pre[^>]*>(<code[^>]*>)*'; | |
-- 2. Reset all closing tags. | |
UPDATE wp_posts | |
SET post_content = REGEXP_REPLACE(post_content, '(<\/code>)*<\/pre>>', '</code></pre>') | |
WHERE post_status = 'publish' | |
AND post_type = 'post' | |
AND post_content RLIKE '(<\/code>)*<\/pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment