function dynamic_output_check_front( &$cachedata = 0 ) {
if ( defined( 'DYNAMIC_CHECK_FRONT_OB_TEXT' ) )
return str_replace( DYNAMIC_OUTPUT_CHECK_FRONT_BUFFER_TAG, DYNAMIC_CHECK_FRONT_OB_TEXT, $cachedata );
ob_start();
// call the sidebar function, do something dynamic
if( is_front_page() ) {
echo 'homepage: true';
} else {
echo 'homepage: false';
}
$text = ob_get_contents();
ob_end_clean();
if ( $cachedata === 0 ) // called directly from the theme so store the output
define( 'DYNAMIC_CHECK_FRONT_OB_TEXT', $text );
else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php
return str_replace( DYNAMIC_OUTPUT_CHECK_FRONT_BUFFER_TAG, $text, $cachedata );
}
add_cacheaction( 'wpsc_cachedata', 'dynamic_output_check_front' );
On first page load, will print "homepage: true", but on every subsequent load, will print "homepage: false". Why is this and is there a way around it?
-Paul