Remove style tags from Drupal node


/ Published in: PHP
Save to your folder(s)

A simple script to run with [drush](http://drupal.org/project/drush) to clean all Drupal nodes containing style tags.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.