Last active
May 17, 2020 11:18
-
-
Save yankiara/1ad097b378eed3a4cffe639cf67a7b21 to your computer and use it in GitHub Desktop.
Remove imported alt text from Oxygen builder images in all posts/templates
This file contains hidden or 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
<?php | |
/* WARNING: Advanced SQL table modifications, USE AT YOUR OWN RISKS */ | |
/* IMPORTANT: You need to RESIGN SHORTCODES after executing this script */ | |
global $wpdb; | |
$sql = 'SELECT meta_id, meta_value | |
FROM ' . $wpdb->postmeta . ' | |
WHERE meta_key = "ct_builder_shortcodes"'; | |
if ($results = $wpdb->get_results($sql)) { | |
foreach ($results as $result) { | |
$new_shortcode = preg_replace( '@,"alt":"[^\"]*"@', '', $result->meta_value); | |
$sql = 'UPDATE ' . $wpdb->postmeta . ' | |
SET meta_value = "' . esc_sql( $new_shortcode ) . '" | |
WHERE meta_id = ' . $result->meta_id; | |
$wpdb->query($sql); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment