1st commit
This commit is contained in:
64
extends/widget-flickr.php
Normal file
64
extends/widget-flickr.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
// FLICKR WIDGET
|
||||
|
||||
add_action('widgets_init', create_function('', 'return register_widget("flickr_widget");'));
|
||||
|
||||
class flickr_widget extends WP_Widget{
|
||||
|
||||
function __construct() {
|
||||
$widget_ops = array(
|
||||
'classname' => 'flickr_widget',
|
||||
'description' => esc_html__('Display the Flickr photos','toppic')
|
||||
);
|
||||
parent::__construct('flickr_widget', esc_html__('Flickr widget','toppic'), $widget_ops);
|
||||
}
|
||||
|
||||
function widget( $args, $instance ){
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', $instance['title']); if(empty($title)) $title="Flickr";
|
||||
$display = $instance['display'];
|
||||
$id = $instance['id'];
|
||||
$number = $instance['number']; if(empty($number)) $number=10;
|
||||
|
||||
echo wp_kses_post( $before_widget);
|
||||
echo wp_kses_post( $before_title.$title.$after_title );?>
|
||||
|
||||
<div class="flickr-widget clearfix">
|
||||
<script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=<?php echo esc_js($number); ?>&display=latest&size=s&layout=x&source=user&user=<?php echo esc_js($id); ?>"></script>
|
||||
</div>
|
||||
|
||||
<?php echo wp_kses_post( $after_widget );
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance){
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['display'] = $new_instance['display'];
|
||||
$instance['id'] = $new_instance['id'];
|
||||
$instance['number'] = $new_instance['number'];
|
||||
return $instance;
|
||||
}
|
||||
|
||||
function form($instance){
|
||||
$instance = wp_parse_args((array)$instance, array('title'=>'', 'text'=>'', 'title_link'=>''));
|
||||
$title = strip_tags($instance['title']);
|
||||
$display = isset( $instance['display'] ) ? $instance['display'] : false;
|
||||
$id = isset( $instance['id'] ) ? $instance['id'] : false;
|
||||
$number = isset( $instance['number'] ) ? $instance['number'] : false;
|
||||
|
||||
$text = format_to_edit($instance['text']);?>
|
||||
<p>
|
||||
<label><?php esc_html_e('Title:','toppic')?><input class="widefat" id="<?php echo esc_attr( $this->get_field_id(strtolower('title'))) ?>" name="<?php echo esc_attr( $this->get_field_name(strtolower('title'))) ?>" type="text" value="<?php echo esc_attr($title)?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php printf( esc_html__( 'Flickr ID ( %s ):' , 'toppic' ), '<a href="http://www.idgettr.com" target="_blank">idGettr</a>' ) ?><input class="widefat" id="<?php echo esc_attr( $this->get_field_id(strtolower('id'))) ?>" name="<?php echo esc_attr( $this->get_field_name(strtolower('id'))) ?>" type="text" value="<?php echo esc_attr($id)?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('Number of photos:','toppic')?><input class="widefat" id="<?php echo esc_attr( $this->get_field_id(strtolower('number'))) ?>" name="<?php echo esc_attr( $this->get_field_name(strtolower('number'))) ?>" type="text" value="<?php echo esc_attr($number)?>" /></label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user