All pastes #879960 Raw Edit

Anonymous

public text v1 · immutable
#879960 ·published 2008-01-29 18:46 UTC
rendered paste body
// --------------------------------------------
// FILTER POST CONTENT TO ADD PHP RESULTS
// --------------------------------------------
//
// Use <!--badgecode--> in a post to see the code.

function gv_add_badgecode($content) {
	// we get the content as a parameter
	
	// if we find the replacement text in the content
	if (strpos($content, '<!--badgecode-->') !== FALSE) {
		
		// set up the output we want
		$badgecode .= a_function_that_outputs_desired_result();
		
		// replace the text replacement with the $badgecode content. 
		$content = str_replace('<!--badgecode-->', $badgecode, $content);

	}
	// send teh content back to be used
	return $content;
}

// we use the the_content filter with our fucntion we just set up
add_filter('the_content', 'gv_add_badgecode');