register_widget( 'latest_mag_issues_widget' );
should be
register_widget( 'latest_mag_issue_widget' );
Update
After fixing that though, there are a couple of other errors. Here’s the complete updated copy of your code that I could get working:
class latest_mag_issue_widget extends WP_Widget {
function latest_mag_issue_widget() {
$widget_ops = array( 'classname' => 'widget_latest_issues', 'description' => 'Latest Mag Issues Widget for Media24 Business & Customs' );
$this->WP_Widget( 'latest_issues', 'Latest Issues', $widget_ops );
} //end constructor
function widget( $args, $instance ) {
extract( $args );
// widget options
$title = apply_filters( 'widget_title', $instance['title'] );
$pastissues = $instance['pastissues'];
$thisissue = $instance['thisissue'];
echo $before_widget;
echo '<div class="widget widget-latest-issue">';
if ( $title ) {
echo $before_title . $title . $after_title;
}
$wp_query = new WP_Query();
$wp_query->query( array( 'post_type' => 'mag-issue', 'post_status' => 'publish', 'paged' => 1, 'posts_per_page' => 1 ) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
$image_url = get_post_meta( $post->ID, 'press_smart', true );
$image_title = the_title();
$image_thumbnail = the_post_thumbnail( array(125,166) );
echo '
<div id="latest-issue">
<h3>Latest Issue</h3>
<a class="fl" href="' . $image_url . '" title="' . $image_title .'">' . $image_thumbnail . '</a> <br/>
</div>
';
if ( $thisissue == true ) {
echo '
<div id="this-issue">
<h3>In This Issue</h3>
<ul>';
for ( $i = 1; $i < 10; $i++ ) {
$headline_meta = get_post_meta( $post->ID , 'headline_' . $i , true );
if ( $headline_meta ) { echo '<li>' . $headline_meta . '</li><hr>';}
}
echo '
</ul>
</div>
';
}
if ( $pastissues == true ) {
$wp_query->query(array( 'post_type' => 'mag-issue', 'post_status' => 'publish', 'paged' => 1, 'posts_per_page' => 9, 'offset' => 1 ));
if ( have_posts() ) : while ( have_posts() ) : the_post();
$post_url = get_post_meta( $post->ID, 'press_smart', true );
$post_title = the_title();
echo '
<div id="past-issues">
<h3>Past Issues</h3>
<ul>
<li>
<a href="' . $post_url . '">' . $post_title . '</a>
</li>';
echo '
</ul>
</div>
';
endwhile; endif; wp_reset_postdata();
}
echo '</div>';
echo $after_widget;
endwhile; endif; wp_reset_query();
} //end function widget()
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['thisissue'] = strip_tags( $new_instance['thisissue'] );
$instance['pastissues'] = strip_tags( $new_instance['pastissues'] );
return $instance;
} //end function update()
function form($instance) {
$title = esc_attr( $instance['title'] );
$thisissue = esc_attr( $instance['thisissue'] );
$pastissues = esc_attr( $instance['pastissues'] );
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
</p>
<p>
<input id="<?php echo $this->get_field_id('thisissue'); ?>" name="<?php echo $this->get_field_name('thisissue'); ?>" type="checkbox" value="1" <?php checked( '1', $thisissue ); ?>/>
<label for="<?php echo $this->get_field_id('thisissue'); ?>"><?php _e('Display headlines?'); ?></label>
</p>
<p>
<input id="<?php echo $this->get_field_id('pastissues'); ?>" name="<?php echo $this->get_field_name('pastissues'); ?>" type="checkbox" value="1" <?php checked( '1', $pastissues ); ?>/>
<label for="<?php echo $this->get_field_id('pastissues'); ?>"><?php _e('Display past issues?'); ?></label>
</p>
<?php
} //end function form()
}
// Register the widget
add_action( 'widgets_init', 'register_mag_issues_widget' );
function register_mag_issues_widget() {
register_widget( 'latest_mag_issue_widget' );
}