plugin using preg_replace_callback
-
Hi,
I want to write a plugin to display programming code and do some syntax highlighting. However, when I try the very simple code below (which extracts code blocks and adds a string for testing purposes), the contents of my posts is not displayed anymore. What am I doing wrong?<?php
/*
Plugin Name: Code Plugin
*/function processcode($matches)
{
$temp = $matches[2].’ tarara’;
return $temp;
}function extractcode($text)
{
$newtext = preg_replace_callback(‘/()(.*)(
)/’,’processcode’,$text);
return $newtext;
}add_filter(‘the_content’, ‘extractcode’);
?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘plugin using preg_replace_callback’ is closed to new replies.