I have a widget in Wordpress which uses eval() in the code but this is switched off on the server and so can’t be used. I was wondering if anyone could give me some assistance with respect to changing the following code so that it doens’t use eval. I’m just a beginner but am willing to learn so any help would be appreciated.
function widget( $args, $instance ) {
extract($args);
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
$text = apply_filters( 'widget_execphp', $instance['text'], $instance );
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
ob_start();
eval('?>'.$text);
$text = ob_get_contents();
ob_end_clean();
?>
<div class="execphpwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
<?php
echo $after_widget;
}