I'm working on a function which will insert 'first item' and 'last item' into the class attributes of the first and last list-item elements returned by the wp_list_pages() function. This is what I wrote to do it:
function onw_first_and_last($the_string) {
$class_position = stripos($the_string,'page_item');
$string1 = substr($the_string,0,$class_position);
$string2 = substr($the_string,$class_position);
$string1 .= 'first_item ';
$the_string = $string1.$string2;
$last_class_position = strripos($the_string,'page_item');
$string3 = substr($the_string,0,$last_class_position);
$string4 = substr($the_string,$last_class_position);
$string3 .= 'last_item ';
$the_string = $string3.$string4;
return $the_string;
}
Then I add it to the 'wp_list_pages' filter hook. I have other plugins hooking onto 'wp_list_pages' and they work just fine. But whenever I activate this plugin, I get an internal server error on the front end of my website (the wp-admin directory, etc. all works fine). Does anybody have any idea what the problem is?