Posted By

mongolito404 on 03/12/10


Tagged

php html clean drupal Drush


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mbria


Remove style tags from Drupal node


 / Published in: PHP
 

A simple script to run with drush to clean all Drupal nodes containing style tags.

  1. <?php
  2.  
  3. $results = db_query("SELECT DISTINCT nid from node_revisions WHERE body REGEXP '<style>.*</style>' OR body REGEXP '<style>.*</style>'");
  4.  
  5. while($nid = db_result($results)) {
  6. $node = node_load($nid);
  7. unset($node->teaser);
  8. $node->body = preg_replace('@<style[^>]*?>.*?</style>@siu', '',$node->body);
  9. node_save($node);
  10. }
  11. ?>

Report this snippet  

You need to login to post a comment.