File: /home/dwauav0tm6jp/public_html/wp-content/themes/photographer-wp/admin/widget-flickr.php
<?php
class pixelwars_Flickr_Widget extends WP_Widget
{
public function __construct()
{
parent::__construct('pixelwars_flickr_widget',
__( '- Flickr', 'read' ),
array( 'description' => __( 'Flickr widget.', 'read' ) ) );
}
public function form( $instance )
{
if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { $title = ""; }
if ( isset( $instance[ 'user' ] ) ) { $user = $instance[ 'user' ]; } else { $user = ""; }
if ( isset( $instance[ 'number_of_items' ] ) ) { $number_of_items = $instance[ 'number_of_items' ]; } else { $number_of_items = '8'; }
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php echo __( 'Title:', 'read' ); ?></label>
<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $title ); ?>">
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'user' ) ); ?>"><?php echo __( 'User:', 'read' ); ?></label>
<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'user' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'user' ) ); ?>" value="<?php echo esc_attr( $user ); ?>">
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'number_of_items' ) ); ?>"><?php echo __( 'Number of items to show:', 'read' ); ?></label>
<input type="text" id="<?php echo esc_attr( $this->get_field_id( 'number_of_items' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_of_items' ) ); ?>" size="3" value="<?php echo esc_attr( $number_of_items ); ?>">
</p>
<?php
}
public function update( $new_instance, $old_instance )
{
$instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['user'] = strip_tags( $new_instance['user'] );
$instance['number_of_items'] = strip_tags( $new_instance['number_of_items'] );
return $instance;
}
public function widget( $args, $instance )
{
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$user = apply_filters( 'widget_user', $instance['user'] );
$number_of_items = apply_filters( 'widget_number_of_items', $instance['number_of_items'] );
echo $before_widget;
if ( ! empty( $title ) )
{
echo $before_title . $title . $after_title;
}
?>
<div class="flickr-badges flickr-badges-s">
<script src="http://www.flickr.com/badge_code_v2.gne?size=s&count=<?php echo $number_of_items; ?>&display=random&layout=x&source=user&user=<?php echo $user; ?>"></script>
</div>
<?php
echo $after_widget;
}
}
add_action('widgets_init', function() { register_widget('pixelwars_Flickr_Widget'); });
?>