After upgrading to php 5.6.4 my widgets file causes:
Parse error: syntax error, unexpected 'class' (T_CLASS) in /home/path/fss-widgets.php on line 1
I’m mystified – several hours research has yielded nothing. The problem doesn’t appear to be quoting, escaping, or anything else you would expect in this situation and the code looks ok to me.
<?php
/*
Plugin Name: FSS Vacancy Widget
Plugin URI: http://www.url.com/
Description: Shows recent vacancies
Author: Name
Version: 1.0
Author URI: http://www.url.com/
*/
class FSSVacancyWidget extends WP_Widget
{
function FSSVacancyWidget()
{
$widget_ops = array('classname' => 'FSSVacancyWidget', 'description' => 'Displays Recent FSS Jobs on the homepage and all other pages' );
$this->WP_Widget('FSSVacancyWidget', 'FSS Vacancies', $widget_ops);
}
function form($instance)
{
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$title = $instance['title'];
$fss_numposts = $instance['fss_numposts'];
$fss_vacurl = $instance['fss_vacurl'];
$fss_morevac = $instance['fss_morevac'];
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('fss_numposts'); ?>">Number of Posts (Default is 10): <input class="widefat" id="<?php echo $this->get_field_id('fss_numposts'); ?>" name="<?php echo $this->get_field_name('fss_numposts'); ?>" type="text" value="<?php echo attribute_escape($fss_numposts); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('fss_vacurl'); ?>">Vacancy URL: <input class="widefat" id="<?php echo $this->get_field_id('fss_vacurl'); ?>" name="<?php echo $this->get_field_name('fss_vacurl'); ?>" type="text" value="<?php echo attribute_escape($fss_vacurl); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('fss_morevac'); ?>">More Vacancies Title: <input class="widefat" id="<?php echo $this->get_field_id('fss_morevac'); ?>" name="<?php echo $this->get_field_name('fss_morevac'); ?>" type="text" value="<?php echo attribute_escape($fss_morevac); ?>" /></label></p>
<?php
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = $new_instance['title'];
$instance['fss_numposts'] = $new_instance['fss_numposts'];
$instance['fss_vacurl'] = $new_instance['fss_vacurl'];
$instance['fss_morevac'] = $new_instance['fss_morevac'];
return $instance;
}
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
/* User-selected settings. */
$fss_numposts = $instance['fss_numposts'];
$fss_vacurl = $instance['fss_vacurl'];
$fss_morevac = $instance['fss_morevac'];
echo $before_widget;
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
if (!empty($title))
echo $before_title . $title . $after_title;;
echo "<ul class="items">";
query_posts( array( 'showposts' => $fss_numposts ) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
echo "<li><a href="".get_permalink().""><span class="job-title">".get_the_title()."</span><span class="job-date">".get_the_date('d m Y')."</span></a></li>";
endwhile; endif; wp_reset_query();
echo "</ul>";
echo"<a href="".$fss_vacurl."" class="view">".$fss_morevac."</a>";
echo $after_widget;
}
}
add_action( 'widgets_init', create_function('', 'return register_widget("FSSVacancyWidget");') );