title: remove attribute class and id and style from posts wordpress
body: <p>i want remove attribute class and id and style from posts wordpress</p>
  <p>i see in all posts class and id and same of style attribute</p>
  <p><code>&lt;h2 id=&quot;gydde&quot; style=&quot;color:#fff&quot; class=&quot;iyjf&quot;&gt;&lt;span id=&quot;tttu&quot; class=&quot;jfrrg&quot;&gt;&lt;b class=&quot;gr5&quot; id=&quot;krttn&quot; style=&quot;color:#fff&quot;&gt;text&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt; </code></p>
  <p>i want after save post clean code in posts saved in database like this</p>
  <pre><code>&lt;h2&gt;&lt;span&gt;&lt;b&gt;text&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;
  </code></pre>
  <p>any way to do check and filter posts after publish and update and remove id and class</p>
  <p>i see for php</p>
  <pre><code>    &lt;?php
  function stripUnwantedTagsAndAttrs($html_str){
    $xml = new DOMDocument();
  //Suppress warnings: proper error handling is beyond scope of example
    libxml_use_internal_errors(true);
  //List the tags you want to allow here, NOTE you MUST allow html and body otherwise entire string will be cleared
    $allowed_tags = array(&quot;html&quot;, &quot;body&quot;, &quot;b&quot;, &quot;br&quot;, &quot;em&quot;, &quot;hr&quot;, &quot;i&quot;, &quot;li&quot;, &quot;ol&quot;, &quot;p&quot;, &quot;s&quot;, &quot;span&quot;, &quot;table&quot;, &quot;tr&quot;, &quot;td&quot;, &quot;u&quot;, &quot;ul&quot;);
  //List the attributes you want to allow here
    $allowed_attrs = array (&quot;class&quot;, &quot;id&quot;, &quot;style&quot;);
    if (!strlen($html_str)){return false;}
    if ($xml-&gt;loadHTML($html_str, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD)){
      foreach ($xml-&gt;getElementsByTagName(&quot;*&quot;) as $tag){
        if (!in_array($tag-&gt;tagName, $allowed_tags)){
          $tag-&gt;parentNode-&gt;removeChild($tag);
        }else{
          foreach ($tag-&gt;attributes as $attr){
            if (!in_array($attr-&gt;nodeName, $allowed_attrs)){
              $tag-&gt;removeAttribute($attr-&gt;nodeName);
            }
          }
        }
      }
    }
    return $xml-&gt;saveHTML();
  }
  ?&gt;
  </code></pre>
  <p>i dont know how to it for wordpress with remove attributes class id and style</p>