我正在开发flickr Wp小部件。下面是获取flickr图片的代码。
class imperia_flickr extends WP_Widget {
function imperia_flickr() {
$widget_ops = array(\'description\' => \'This Flickr widget populates photos from a Flickr ID.\' );
parent::WP_Widget(false, __(\'imperia - Flickr\', \'imperiathemes\'),$widget_ops);
}
function widget($args, $instance) {
extract( $args );
$id = $instance[\'id\'];
$number = $instance[\'number\'];
echo $before_widget;
echo $before_title; ?>
<div class="flickr-icon"></div>
<?php _e(\'Photostream\'); ?>
<?php echo $after_title; ?>
<script type="text/javascript">
$(document).ready(function() {
$(\'#flickr\').jflickrfeed({
limit: <?php echo $number; ?>,
qstrings: {
id: \'<?php echo $id; ?>\'
},
itemTemplate: \'<li><a href="{{image_b}}" rel="prettyPhoto[pp_gal]"><img class="flickr" src="{{image_s}}" alt="{{title}}" width="45" height="45"></a></li>\'
}, function(data) {
$(\'#flickr a\').prettyPhoto();
});
});
</script>
<ul id="flickr"></ul>
<div class="clear"></div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
return $new_instance;
}
function form($instance) {
****** $id = esc_attr($instance[\'id\']);
****** $number = esc_attr($instance[\'number\']);
?>
<p>
<label for="<?php echo $this->get_field_id(\'id\'); ?>"><?php _e(\'Flickr ID (<a href="http://www.idgettr.com">idGettr</a>):\',\'imperiathemes\'); ?></label>
<input type="text" name="<?php echo $this->get_field_name(\'id\'); ?>" value="<?php echo $id; ?>" class="widefat" id="<?php echo $this->get_field_id(\'id\'); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id(\'number\'); ?>"><?php _e(\'Number:\',\'imperiathemes\'); ?></label>
<select name="<?php echo $this->get_field_name(\'number\'); ?>" class="widefat" id="<?php echo $this->get_field_id(\'number\'); ?>">
<?php for ( $i = 1; $i <= 12; $i += 1) { ?>
<option value="<?php echo $i; ?>" <?php if($number == $i){ echo "selected=\'selected\'";} ?>><?php echo $i; ?></option>
<?php } ?>
</select>
</p>
<?php
}
}
register_widget(\'imperia_flickr\');
此小部件工作正常,但出现以下错误
-- Debug: Undefined index: id on line 54 of /wp-content/themes/imperia/includes/widgets/widget-imperia-flickr.php
-- Debug: Undefined index: number on line 55 of /wp-content/themes/imperia/includes/widgets/widget-imperia-flickr.php
我已经用
** 在上面
我错在哪里?需要修复什么?
谢谢