Skip to content

Instantly share code, notes, and snippets.

@yankiara
Last active May 17, 2020 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yankiara/1ad097b378eed3a4cffe639cf67a7b21 to your computer and use it in GitHub Desktop.
Save yankiara/1ad097b378eed3a4cffe639cf67a7b21 to your computer and use it in GitHub Desktop.
Remove imported alt text from Oxygen builder images in all posts/templates
<?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