Is there a similar way to select / perform DOM manipulation on the server-side (PHP) like the way jQuery works?
For example, if I wanted to modify content of each <pre class="raw">...</pre>
elements inside of a post content, in jQuery you can easily capture them all with:
//In jQuery, this will obtain a collection of <PRE> elements with class "raw":
$("pre.raw").each( function(index,tag) {
//Modify content of each PRE tags here...
tag.innerHTML = tag.innerHTML.replace( ..., ... );
});
In PHP however, I'm trying to do this by adding a filter to "the_content", which will then do some string replacements only inside each of those <pre class="raw">
elements.
Does WordPress already have some built-in utility method to grab elements this way? Or does some 3rd party PHP script exists that will do this?