/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Replace all tags matching a regexp with value of callback function * (passes grouped subpatterns to callback as params) */ function my_wp_plugin_tag_action($content,$tag,$function,$args = FALSE) { // match all regular expressions // filter duplicates // loop through foreach ($matches as $idx => $match) { //build arg array //call function, adding function output and full tag text to replacement array $tag_results[] = my_wp_plugin_buffer_func($function,$match); $found_tags[] = $full_tag; } // replace all tags with corresponding text } return $content; }